-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
34 lines (30 loc) · 1.07 KB
/
Copy pathscript.js
File metadata and controls
34 lines (30 loc) · 1.07 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
document.addEventListener("DOMContentLoaded", function () {
const smoothScrollLinks = document.querySelectorAll("nav a[href^='#']");
for (let link of smoothScrollLinks) {
link.addEventListener("click", function (e) {
e.preventDefault();
const targetId = this.getAttribute("href");
const targetSection = document.querySelector(targetId);
targetSection.scrollIntoView({
behavior: "smooth",
block: "start"
});
});
}
// Fade-in effect for sections
const fadeInSections = document.querySelectorAll(".fade-in");
const options = {
threshold: 0.1
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add("fade-in");
observer.unobserve(entry.target);
}
});
}, options);
fadeInSections.forEach(section => {
observer.observe(section);
});
});