2024-06-13 14:26:33 +02:00
|
|
|
/**
|
2024-06-15 19:49:19 +02:00
|
|
|
* @type {NodeListOf<HTMLVideoElement>}
|
2024-06-13 14:26:33 +02:00
|
|
|
*/
|
2024-06-15 19:49:19 +02:00
|
|
|
const parallaxElems = document.querySelectorAll('.parallax');
|
2024-06-13 14:26:33 +02:00
|
|
|
|
|
|
|
|
// Handle scroll events.
|
|
|
|
|
window.addEventListener('scroll', () =>
|
|
|
|
|
{
|
|
|
|
|
// Add class to body when scrolled.
|
|
|
|
|
document.body.classList.toggle('is-scrolled', window.scrollY > 0);
|
|
|
|
|
|
|
|
|
|
// Parallax effect.
|
2024-06-15 19:49:19 +02:00
|
|
|
parallaxElems.forEach(parallaxElem =>
|
|
|
|
|
{
|
|
|
|
|
const parentElem = parallaxElem.parentElement;
|
|
|
|
|
|
|
|
|
|
const parentRect = parentElem.getBoundingClientRect();
|
|
|
|
|
const parentScroll = parentRect.top + (parentRect.height / 2);
|
|
|
|
|
|
|
|
|
|
const windowScroll = window.scrollY + (window.innerHeight / 2);
|
|
|
|
|
|
|
|
|
|
parallaxElem.style.top = `${(windowScroll - parentScroll) / 4}px`;
|
|
|
|
|
});
|
2024-06-13 14:26:33 +02:00
|
|
|
});
|
|
|
|
|
|
2024-07-13 13:10:18 +02:00
|
|
|
/**
|
|
|
|
|
* @type {NodeListOf<HTMLElement>}
|
|
|
|
|
*/
|
|
|
|
|
const sections = document.querySelectorAll('.section');
|
|
|
|
|
|
2024-06-15 19:49:19 +02:00
|
|
|
sections.forEach(section =>
|
2024-06-13 14:26:33 +02:00
|
|
|
{
|
2024-06-15 19:49:19 +02:00
|
|
|
if (section.id)
|
2024-06-13 14:26:33 +02:00
|
|
|
{
|
|
|
|
|
const anchor = document.createElement('a');
|
|
|
|
|
anchor.className = 'anchor-link';
|
2024-06-15 19:49:19 +02:00
|
|
|
anchor.href = `#${section.id}`;
|
2024-06-13 14:26:33 +02:00
|
|
|
anchor.innerHTML = ' # ';
|
2024-06-15 19:49:19 +02:00
|
|
|
section.appendChild(anchor);
|
2024-06-13 14:26:33 +02:00
|
|
|
}
|
2024-06-15 19:49:19 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
document.querySelectorAll('#navbarNav li.nav-item>a').forEach(anchor =>
|
|
|
|
|
{
|
|
|
|
|
anchor.addEventListener('click', () =>
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @type {HTMLButtonElement}
|
|
|
|
|
*/
|
|
|
|
|
const navbarNav = document.querySelector('button.navbar-toggler[aria-expanded="true"]');
|
|
|
|
|
navbarNav?.click();
|
|
|
|
|
});
|
2024-06-13 14:26:33 +02:00
|
|
|
});
|