-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
29 lines (26 loc) · 923 Bytes
/
Copy pathscript.js
File metadata and controls
29 lines (26 loc) · 923 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
/**
* Minimal JavaScript for LEON Portfolio
* Implements subtle scroll fade-in animations via IntersectionObserver.
*/
document.addEventListener('DOMContentLoaded', () => {
// Intersection Observer for scroll fade-in animations
const fadeElements = document.querySelectorAll('.fade-in');
if ('IntersectionObserver' in window) {
const fadeObserver = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
observer.unobserve(entry.target); // Unobserve once animated
}
});
}, {
root: null,
rootMargin: '0px 0px -50px 0px',
threshold: 0.1
});
fadeElements.forEach(el => fadeObserver.observe(el));
} else {
// Fallback for browsers without IntersectionObserver support
fadeElements.forEach(el => el.classList.add('visible'));
}
});