Skip to content

Commit

Permalink
Fix issue with contact nav link not being active
Browse files Browse the repository at this point in the history
  • Loading branch information
kosserin committed Mar 30, 2024
1 parent 7576d52 commit ee669ab
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/components/Intro/Intro.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit ee669ab

Please sign in to comment.