From 6bdd0fa171ff6288b8c34f6dc876bfd907fec650 Mon Sep 17 00:00:00 2001 From: Moepchi Date: Sat, 22 Aug 2026 23:19:17 +0200 Subject: [PATCH] Stabilize landing navigation scroll state --- web/src/landing.tsx | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/web/src/landing.tsx b/web/src/landing.tsx index e0a1422..546dd0e 100644 --- a/web/src/landing.tsx +++ b/web/src/landing.tsx @@ -135,14 +135,21 @@ function Landing() { const sections = ["features", "architecture", "install"] .map(id => document.getElementById(id)) .filter((section): section is HTMLElement => section !== null); - const observer = new IntersectionObserver( - entries => entries.forEach(entry => { - if (entry.isIntersecting) setActiveNav(entry.target.id); - }), - { rootMargin: "-28% 0px -58%", threshold: 0 }, - ); - sections.forEach(section => observer.observe(section)); - return () => observer.disconnect(); + const updateActiveSection = () => { + const marker = window.innerHeight * 0.34; + let current = ""; + sections.forEach(section => { + if (section.getBoundingClientRect().top <= marker) current = section.id; + }); + setActiveNav(current); + }; + updateActiveSection(); + window.addEventListener("scroll", updateActiveSection, { passive: true }); + window.addEventListener("resize", updateActiveSection); + return () => { + window.removeEventListener("scroll", updateActiveSection); + window.removeEventListener("resize", updateActiveSection); + }; }, []); return