From 8c8de5d38d73155fde3d8c7748c457bb86474f62 Mon Sep 17 00:00:00 2001 From: Florian Sylvain Date: Tue, 9 Sep 2025 17:50:52 +0200 Subject: [PATCH] feat: remove intersection observer for section highlighting and navigation state management --- script.js | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/script.js b/script.js index 90d0301..c42e376 100644 --- a/script.js +++ b/script.js @@ -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) {