-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
38 lines (31 loc) · 1017 Bytes
/
script.js
File metadata and controls
38 lines (31 loc) · 1017 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
30
31
32
33
34
35
36
37
38
// Smooth scroll for in-page links (if any)
document.querySelectorAll('a.nav-link').forEach(a => {
a.addEventListener('click', e => {
const href = a.getAttribute('href');
if (href.startsWith('#')) {
e.preventDefault();
document.querySelector(href).scrollIntoView({ behavior: 'smooth' });
}
});
});
// Add to script.js
const faders = document.querySelectorAll('.fade-in');
const appearOptions = {
threshold: 0.1,
rootMargin: "0px 0px -50px 0px"
};
const appearOnScroll = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (!entry.isIntersecting) return;
entry.target.classList.add('visible');
observer.unobserve(entry.target);
});
}, appearOptions);
faders.forEach(fader => {
appearOnScroll.observe(fader);
});
const menuToggle = document.querySelector(".menu-toggle");
const nav = document.querySelector("nav");
menuToggle.addEventListener("click", () => {
nav.classList.toggle("open");
});