-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
26 lines (23 loc) · 874 Bytes
/
Copy pathscript.js
File metadata and controls
26 lines (23 loc) · 874 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
// Navbar: solidify on scroll
const navbar = document.getElementById('navbar');
window.addEventListener('scroll', () => {
navbar.classList.toggle('scrolled', window.scrollY > 60);
}, { passive: true });
// Hero parallax (JS-driven for smoothness)
const heroBg = document.querySelector('.hero-bg');
window.addEventListener('scroll', () => {
if (window.scrollY < window.innerHeight) {
heroBg.style.transform = `translateY(${window.scrollY * 0.35}px)`;
}
}, { passive: true });
// Fade-in on scroll via IntersectionObserver
const fadeEls = document.querySelectorAll('.fade-in');
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
observer.unobserve(entry.target);
}
});
}, { threshold: 0.12 });
fadeEls.forEach(el => observer.observe(el));