2024-06-12 16:41:06 +02:00
|
|
|
window.addEventListener('scroll', () =>
|
|
|
|
|
{
|
2024-06-13 13:19:18 +02:00
|
|
|
// Add class to body when scrolled.
|
2024-06-07 22:11:11 +02:00
|
|
|
document.body.classList.toggle('is-scrolled', window.scrollY > 0);
|
2024-06-13 13:19:18 +02:00
|
|
|
|
|
|
|
|
// Parallax effect.
|
|
|
|
|
/**
|
|
|
|
|
* @type {HTMLVideoElement}
|
|
|
|
|
*/
|
|
|
|
|
const heroVid = document.querySelector('.hero video');
|
|
|
|
|
heroVid.style.top = `${window.scrollY / 3}px`;
|
|
|
|
|
|
|
|
|
|
// Highlight menu item when scrolled to section.
|
|
|
|
|
let current = '';
|
|
|
|
|
document.querySelectorAll('.section').forEach(section =>
|
|
|
|
|
{
|
|
|
|
|
const sectionTop = section.offsetTop;
|
|
|
|
|
|
|
|
|
|
if (window.scrollY >= sectionTop - 70)
|
|
|
|
|
{
|
|
|
|
|
current = section.getAttribute('id');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
document.querySelectorAll('.nav-link').forEach(link =>
|
|
|
|
|
{
|
|
|
|
|
link.classList.remove('active');
|
|
|
|
|
|
|
|
|
|
if (link.getAttribute('href') === `#${current}`)
|
|
|
|
|
{
|
|
|
|
|
link.classList.add('active');
|
|
|
|
|
}
|
|
|
|
|
});
|
2024-06-07 22:11:11 +02:00
|
|
|
});
|