-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
42 lines (37 loc) · 1.29 KB
/
script.js
File metadata and controls
42 lines (37 loc) · 1.29 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
/* Reveal-on-load + scroll-based reveal + sticky nav shadow */
(function () {
'use strict';
const nav = document.getElementById('nav');
const onScroll = () => {
if (window.scrollY > 4) nav.classList.add('is-scrolled');
else nav.classList.remove('is-scrolled');
};
window.addEventListener('scroll', onScroll, { passive: true });
onScroll();
// Hero lines — reveal on load
const heroReveals = document.querySelectorAll('.hero .reveal');
requestAnimationFrame(() => {
heroReveals.forEach((el) => el.classList.add('is-in'));
});
// Sections — fade up on scroll
const targets = document.querySelectorAll(
'.section__head, .role, .card, .pub, .fact-list, .skills, .contact__title, .contact__lede, .contact__links, .prose-lg, .prose'
);
targets.forEach((el) => el.classList.add('fade-up'));
if ('IntersectionObserver' in window) {
const io = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add('is-in');
io.unobserve(entry.target);
}
});
},
{ rootMargin: '0px 0px -8% 0px', threshold: 0.08 }
);
targets.forEach((el) => io.observe(el));
} else {
targets.forEach((el) => el.classList.add('is-in'));
}
})();