feat: remove intersection observer for section highlighting and navigation state management

This commit is contained in:
Florian Sylvain
2025-09-09 17:50:52 +02:00
parent 2f67e06772
commit 8c8de5d38d
-25
View File
@@ -24,31 +24,6 @@ const sections = navLinks
.map((a) => document.querySelector(a.getAttribute("href")))
.filter(Boolean);
let currentSection = null;
const spy = new IntersectionObserver(
(entries) => {
entries.forEach((e) => {
if (e.isIntersecting) {
const id = "#" + e.target.id;
navLinks.forEach((a) => a.removeAttribute("aria-current"));
const active = navLinks.find(
(a) => a.getAttribute("href") === id
);
if (active) active.setAttribute("aria-current", "page");
if (currentSection !== id) {
currentSection = id;
history.replaceState(null, null, id);
}
}
});
},
{ rootMargin: "-40% 0% -50% 0%", threshold: 0.01 }
);
sections.forEach((s) => s && spy.observe(s));
const menuBtn = document.getElementById("menuToggle");
const nav = document.getElementById("primaryNav");
if (menuBtn && nav) {