Removed menu item highlighting due to one-pager.

This commit is contained in:
Bob Vandevliet 2024-06-19 15:08:04 +02:00
parent d40b5c30a3
commit 90873afb36

View file

@ -3,11 +3,6 @@
*/ */
const parallaxElems = document.querySelectorAll('.parallax'); const parallaxElems = document.querySelectorAll('.parallax');
/**
* @type {NodeListOf<HTMLAnchorElement>}
*/
const navlinks = document.querySelectorAll('a.nav-link');
/** /**
* @type {NodeListOf<HTMLElement>} * @type {NodeListOf<HTMLElement>}
*/ */
@ -31,29 +26,6 @@ window.addEventListener('scroll', () =>
parallaxElem.style.top = `${(windowScroll - parentScroll) / 4}px`; parallaxElem.style.top = `${(windowScroll - parentScroll) / 4}px`;
}); });
// Highlight menu item when scrolled to section.
let current = '';
sections.forEach(section =>
{
const rect = section.getBoundingClientRect();
const sectionTop = rect.top + window.scrollY;
if (window.scrollY >= sectionTop - 70)
{
current = section.getAttribute('id');
}
});
navlinks.forEach(link =>
{
link.classList.remove('active');
if (link.getAttribute('href') === `#${current}`)
{
link.classList.add('active');
}
});
}); });
sections.forEach(section => sections.forEach(section =>