diff --git a/src/scripts/anim.ts b/src/scripts/anim.ts index 557ce5a..ea96503 100644 --- a/src/scripts/anim.ts +++ b/src/scripts/anim.ts @@ -118,8 +118,12 @@ function initNav(): void { for (const a of links) { a.addEventListener("pointerenter", () => under(a, true)); + // On leave, keep the underline only if this link IS the active scroll-spy + // section. Guard on activeIdx >= 0 so that when nothing is active — e.g. the + // Projects/Blog pages, where none of these sections exist and activeIdx stays + // -1 — a hovered tab doesn't stick lit via the -1 === indexOf(non-member) -1. a.addEventListener("pointerleave", () => - under(a, sectioned.indexOf(a) === activeIdx), + under(a, activeIdx >= 0 && sectioned.indexOf(a) === activeIdx), ); }