Skip to content

Commit ecf68e1

Browse files
committed
Site updated: 2025-11-27 18:09:03
1 parent aaa1425 commit ecf68e1

File tree

38 files changed

+3783
-581
lines changed

38 files changed

+3783
-581
lines changed

2013/07/09/How-Filmmakers-Get-Us-to-Root-for-Creeps-https-www-psychologytoday-com-us-blog-the-wide-wide-world-psychology-201307-how-filmmakers-get-us-root-creeps/index.html

Lines changed: 114 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
<!-- <div id="particles-js" style="margin: 0; padding: 0; height: 100%; width: 100%; position: fixed;"></div> -->
8282
<div id="app">
8383
<style>
84+
#magic-line { display: none; }
8485

8586
.navbar-toggler.collapsed ~ .navbar-collapse .navbar-nav {
8687
max-height: none;
@@ -134,6 +135,18 @@
134135
.nav-link {
135136
text-align: center; /* 让链接文字居中 */
136137
}
138+
139+
/* Mobile active state underline */
140+
.nav-item.active .nav-link:after {
141+
content: '';
142+
position: absolute;
143+
left: 0;
144+
right: 0;
145+
bottom: -3px;
146+
border-bottom: 3px solid #CC0000;
147+
width: 100%;
148+
z-index: 2;
149+
}
137150
}
138151

139152

@@ -150,30 +163,47 @@
150163
position: relative; /* 设置相对定位以支持绝对定位的伪元素 */
151164
display: inline-block; /* 确保链接的布局行为像块级元素一样 */
152165
}
166+
167+
.navbar-nav {
168+
position: relative;
169+
}
153170

171+
#magic-line {
172+
display: block;
173+
position: absolute;
174+
height: 3px;
175+
bottom: -3px; /* initial fallback */
176+
background-color: #CC0000;
177+
z-index: 2;
178+
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
179+
pointer-events: none;
180+
}
181+
182+
/*
154183
.navbar-nav .nav-link:hover:after {
155-
content: ''; /* 伪元素的内容为空 */
156-
position: absolute; /* 绝对定位 */
157-
left: 0; /* 从链接的左边缘开始 */
158-
right: 0; /* 伸展到链接的右边缘 */
159-
bottom: -3px; /* 在链接底部下方显示,调整以符合具体布局 */
160-
border-bottom: 3px solid rgb(255, 255, 255); /* 底部边框作为下划线 */
161-
width: 100%; /* 确保宽度与父元素(链接)一致 */
184+
content: '';
185+
position: absolute;
186+
left: 0;
187+
right: 0;
188+
bottom: -3px;
189+
border-bottom: 3px solid rgb(255, 255, 255);
190+
width: 100%;
162191
z-index: 2;
163192
}
193+
*/
164194

165195

166196
}
167-
.nav-item.active .nav-link:after {
168-
content: ''; /* 伪元素的内容为空 */
169-
position: absolute; /* 绝对定位 */
170-
left: 0; /* 从链接的左边缘开始 */
171-
right: 0; /* 伸展到链接的右边缘 */
172-
bottom: -3px; /* 在链接底部下方显示 */
173-
border-bottom: 3px solid #CC0000; /* 红色底部边框作为下划线 */
174-
width: 100%; /* 确保宽度与父元素(链接)一致 */
197+
/*.nav-item.active .nav-link:after {
198+
content: '';
199+
position: absolute;
200+
left: 0;
201+
right: 0;
202+
bottom: -3px;
203+
border-bottom: 3px solid #CC0000;
204+
width: 100%;
175205
z-index: 2;
176-
}
206+
}*/
177207

178208
.nav-link {
179209
position: relative; /* 确保.nav-link支持绝对定位的子元素 */
@@ -215,6 +245,7 @@
215245
<a class="nav-link" style="padding: 0 !important;" href="/publications/">PUBLICATIONS</a>
216246
</li>
217247

248+
<li id="magic-line"></li>
218249
</ul>
219250
</div>
220251
</div>
@@ -242,6 +273,73 @@
242273
speed: 1.00,
243274
zoom: 0.50
244275
})
276+
277+
document.addEventListener("DOMContentLoaded", function() {
278+
const nav = document.querySelector('.navbar-nav');
279+
const magicLine = document.getElementById('magic-line');
280+
const navLinks = document.querySelectorAll('.navbar-nav .nav-link');
281+
282+
// Helper: find active item
283+
function getActiveItem() {
284+
return document.querySelector('.navbar-nav .nav-item.active .nav-link');
285+
}
286+
287+
function setPosition(element, color) {
288+
if (!element || !magicLine) return;
289+
290+
const rect = element.getBoundingClientRect();
291+
const navRect = nav.getBoundingClientRect();
292+
293+
const relativeLeft = rect.left - navRect.left;
294+
// Position top relative to nav
295+
// Original CSS had bottom: -3px on nav-link.
296+
// We want the magic line to be at the same vertical position.
297+
// Since nav-links are inline-block and aligned, we can just trust top/height.
298+
const relativeTop = rect.top - navRect.top + rect.height;
299+
300+
magicLine.style.width = `${rect.width}px`;
301+
magicLine.style.left = `${relativeLeft}px`;
302+
magicLine.style.top = `${relativeTop}px`; // Set explicit top
303+
304+
if (color) {
305+
magicLine.style.backgroundColor = color;
306+
}
307+
}
308+
309+
// Initial setup with delay to allow activeNav.js to run and layout to settle
310+
window.addEventListener('load', function() {
311+
const activeItem = getActiveItem();
312+
if (activeItem) {
313+
setPosition(activeItem, '#CC0000');
314+
} else {
315+
if (magicLine) magicLine.style.width = '0';
316+
}
317+
});
318+
319+
navLinks.forEach(link => {
320+
link.addEventListener('mouseenter', function() {
321+
// Always Red
322+
setPosition(link, '#CC0000');
323+
});
324+
});
325+
326+
if (nav) {
327+
nav.addEventListener('mouseleave', function() {
328+
const activeItem = getActiveItem();
329+
if (activeItem) {
330+
setPosition(activeItem, '#CC0000');
331+
} else {
332+
if (magicLine) magicLine.style.width = '0';
333+
}
334+
});
335+
}
336+
337+
// Handle resize
338+
window.addEventListener('resize', function() {
339+
const activeItem = getActiveItem();
340+
if (activeItem) setPosition(activeItem, '#CC0000');
341+
});
342+
});
245343
</script>
246344

247345
<!-- margin-top because the navbar is fixed -->

2015/09/14/Can-Your-Kids-Handle-the-Reading-Load-at-College-https-www-psychologytoday-com-us-blog-the-wide-wide-world-psychology-201509-can-your-kids-handle-the-reading-load-college/index.html

Lines changed: 114 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
<!-- <div id="particles-js" style="margin: 0; padding: 0; height: 100%; width: 100%; position: fixed;"></div> -->
8282
<div id="app">
8383
<style>
84+
#magic-line { display: none; }
8485

8586
.navbar-toggler.collapsed ~ .navbar-collapse .navbar-nav {
8687
max-height: none;
@@ -134,6 +135,18 @@
134135
.nav-link {
135136
text-align: center; /* 让链接文字居中 */
136137
}
138+
139+
/* Mobile active state underline */
140+
.nav-item.active .nav-link:after {
141+
content: '';
142+
position: absolute;
143+
left: 0;
144+
right: 0;
145+
bottom: -3px;
146+
border-bottom: 3px solid #CC0000;
147+
width: 100%;
148+
z-index: 2;
149+
}
137150
}
138151

139152

@@ -150,30 +163,47 @@
150163
position: relative; /* 设置相对定位以支持绝对定位的伪元素 */
151164
display: inline-block; /* 确保链接的布局行为像块级元素一样 */
152165
}
166+
167+
.navbar-nav {
168+
position: relative;
169+
}
153170

171+
#magic-line {
172+
display: block;
173+
position: absolute;
174+
height: 3px;
175+
bottom: -3px; /* initial fallback */
176+
background-color: #CC0000;
177+
z-index: 2;
178+
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
179+
pointer-events: none;
180+
}
181+
182+
/*
154183
.navbar-nav .nav-link:hover:after {
155-
content: ''; /* 伪元素的内容为空 */
156-
position: absolute; /* 绝对定位 */
157-
left: 0; /* 从链接的左边缘开始 */
158-
right: 0; /* 伸展到链接的右边缘 */
159-
bottom: -3px; /* 在链接底部下方显示,调整以符合具体布局 */
160-
border-bottom: 3px solid rgb(255, 255, 255); /* 底部边框作为下划线 */
161-
width: 100%; /* 确保宽度与父元素(链接)一致 */
184+
content: '';
185+
position: absolute;
186+
left: 0;
187+
right: 0;
188+
bottom: -3px;
189+
border-bottom: 3px solid rgb(255, 255, 255);
190+
width: 100%;
162191
z-index: 2;
163192
}
193+
*/
164194

165195

166196
}
167-
.nav-item.active .nav-link:after {
168-
content: ''; /* 伪元素的内容为空 */
169-
position: absolute; /* 绝对定位 */
170-
left: 0; /* 从链接的左边缘开始 */
171-
right: 0; /* 伸展到链接的右边缘 */
172-
bottom: -3px; /* 在链接底部下方显示 */
173-
border-bottom: 3px solid #CC0000; /* 红色底部边框作为下划线 */
174-
width: 100%; /* 确保宽度与父元素(链接)一致 */
197+
/*.nav-item.active .nav-link:after {
198+
content: '';
199+
position: absolute;
200+
left: 0;
201+
right: 0;
202+
bottom: -3px;
203+
border-bottom: 3px solid #CC0000;
204+
width: 100%;
175205
z-index: 2;
176-
}
206+
}*/
177207

178208
.nav-link {
179209
position: relative; /* 确保.nav-link支持绝对定位的子元素 */
@@ -215,6 +245,7 @@
215245
<a class="nav-link" style="padding: 0 !important;" href="/publications/">PUBLICATIONS</a>
216246
</li>
217247

248+
<li id="magic-line"></li>
218249
</ul>
219250
</div>
220251
</div>
@@ -242,6 +273,73 @@
242273
speed: 1.00,
243274
zoom: 0.50
244275
})
276+
277+
document.addEventListener("DOMContentLoaded", function() {
278+
const nav = document.querySelector('.navbar-nav');
279+
const magicLine = document.getElementById('magic-line');
280+
const navLinks = document.querySelectorAll('.navbar-nav .nav-link');
281+
282+
// Helper: find active item
283+
function getActiveItem() {
284+
return document.querySelector('.navbar-nav .nav-item.active .nav-link');
285+
}
286+
287+
function setPosition(element, color) {
288+
if (!element || !magicLine) return;
289+
290+
const rect = element.getBoundingClientRect();
291+
const navRect = nav.getBoundingClientRect();
292+
293+
const relativeLeft = rect.left - navRect.left;
294+
// Position top relative to nav
295+
// Original CSS had bottom: -3px on nav-link.
296+
// We want the magic line to be at the same vertical position.
297+
// Since nav-links are inline-block and aligned, we can just trust top/height.
298+
const relativeTop = rect.top - navRect.top + rect.height;
299+
300+
magicLine.style.width = `${rect.width}px`;
301+
magicLine.style.left = `${relativeLeft}px`;
302+
magicLine.style.top = `${relativeTop}px`; // Set explicit top
303+
304+
if (color) {
305+
magicLine.style.backgroundColor = color;
306+
}
307+
}
308+
309+
// Initial setup with delay to allow activeNav.js to run and layout to settle
310+
window.addEventListener('load', function() {
311+
const activeItem = getActiveItem();
312+
if (activeItem) {
313+
setPosition(activeItem, '#CC0000');
314+
} else {
315+
if (magicLine) magicLine.style.width = '0';
316+
}
317+
});
318+
319+
navLinks.forEach(link => {
320+
link.addEventListener('mouseenter', function() {
321+
// Always Red
322+
setPosition(link, '#CC0000');
323+
});
324+
});
325+
326+
if (nav) {
327+
nav.addEventListener('mouseleave', function() {
328+
const activeItem = getActiveItem();
329+
if (activeItem) {
330+
setPosition(activeItem, '#CC0000');
331+
} else {
332+
if (magicLine) magicLine.style.width = '0';
333+
}
334+
});
335+
}
336+
337+
// Handle resize
338+
window.addEventListener('resize', function() {
339+
const activeItem = getActiveItem();
340+
if (activeItem) setPosition(activeItem, '#CC0000');
341+
});
342+
});
245343
</script>
246344

247345
<!-- margin-top because the navbar is fixed -->

0 commit comments

Comments
 (0)