-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
29 lines (27 loc) · 879 Bytes
/
Copy pathscript.js
File metadata and controls
29 lines (27 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// small helpers: year
document.getElementById('year').textContent = new Date().getFullYear();
// Reveal on scroll (IntersectionObserver)
const reveals = document.querySelectorAll('.reveal');
const io = new IntersectionObserver((entries) => {
entries.forEach(e => {
if (e.isIntersecting) {
e.target.classList.add('visible');
io.unobserve(e.target);
}
});
}, {threshold: 0.12});
reveals.forEach(r=>io.observe(r));
// Smooth scroll for internal links
document.querySelectorAll('a[href^="#"]').forEach(a=>{
a.addEventListener('click', (e) => {
const href = a.getAttribute('href');
if (href && href.startsWith('#')) {
const target = document.querySelector(href);
if(target){
e.preventDefault();
target.scrollIntoView({behavior:'smooth', block:'start'});
history.pushState(null,'',href);
}
}
});
});