From ee669ab08f3b80ad5352f17761f6bd45b4c698e5 Mon Sep 17 00:00:00 2001 From: Andrija Kostic Date: Sat, 30 Mar 2024 19:58:21 +0100 Subject: [PATCH] Fix issue with contact nav link not being active --- src/components/Intro/Intro.jsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/Intro/Intro.jsx b/src/components/Intro/Intro.jsx index b86f49e..2e1c0b7 100644 --- a/src/components/Intro/Intro.jsx +++ b/src/components/Intro/Intro.jsx @@ -91,10 +91,20 @@ const Intro = () => { const handleScroll = () => { sections.forEach((s, sIndex) => { let top = window.scrollY; - let offset = s.offsetTop - 500; + let offset = s.offsetTop; let height = s.offsetHeight; + console.log(top >= offset && top < offset + height); - if (top >= offset && top < offset + height) { + const sectionId = s.getAttribute('id'); + if ( + sectionId === "contactSection" && + top + window.innerHeight >= s.offsetTop + ) { + links.forEach((l) => { + l.classList.remove("active"); + links[sIndex].classList.add("active"); + }); + } else if (top >= offset && top < offset + height) { links.forEach((l) => { l.classList.remove("active"); links[sIndex].classList.add("active");