2025-05-24 17:59:29 +02:00
|
|
|
window.addEventListener('pageshow', () =>
|
2024-06-13 14:26:33 +02:00
|
|
|
{
|
2024-07-13 18:09:28 +02:00
|
|
|
/**
|
|
|
|
|
* @type {NodeListOf<HTMLVideoElement>}
|
|
|
|
|
*/
|
|
|
|
|
const parallaxElems = document.querySelectorAll('.parallax');
|
2024-06-13 14:26:33 +02:00
|
|
|
|
2025-05-24 17:59:29 +02:00
|
|
|
const refreshScrollLinkedPositioningEffect = () =>
|
2024-06-15 19:49:19 +02:00
|
|
|
{
|
2024-07-13 18:09:28 +02:00
|
|
|
document.body.classList.toggle('is-scrolled', window.scrollY > 0);
|
|
|
|
|
|
|
|
|
|
parallaxElems.forEach(parallaxElem =>
|
|
|
|
|
{
|
|
|
|
|
const parentElem = parallaxElem.parentElement;
|
2024-06-15 19:49:19 +02:00
|
|
|
|
2024-07-13 18:09:28 +02:00
|
|
|
const parentRect = parentElem.getBoundingClientRect();
|
|
|
|
|
const parentScroll = parentRect.top + (parentRect.height / 2);
|
2024-06-15 19:49:19 +02:00
|
|
|
|
2024-07-13 18:09:28 +02:00
|
|
|
const windowScroll = window.scrollY + (window.innerHeight / 2);
|
2024-06-15 19:49:19 +02:00
|
|
|
|
2024-07-13 18:09:28 +02:00
|
|
|
parallaxElem.style.top = `${(windowScroll - parentScroll) / 4}px`;
|
|
|
|
|
});
|
2025-05-24 17:59:29 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
refreshScrollLinkedPositioningEffect();
|
|
|
|
|
window.addEventListener('scroll', refreshScrollLinkedPositioningEffect);
|
|
|
|
|
});
|
2024-06-13 14:26:33 +02:00
|
|
|
|
2025-05-24 17:59:29 +02:00
|
|
|
document.addEventListener('DOMContentLoaded', () =>
|
|
|
|
|
{
|
2024-07-13 18:09:28 +02:00
|
|
|
/**
|
|
|
|
|
* @type {NodeListOf<HTMLElement>}
|
|
|
|
|
*/
|
2024-07-29 17:17:52 +02:00
|
|
|
const sections = document.querySelectorAll('section');
|
2024-07-13 13:10:18 +02:00
|
|
|
|
2024-07-13 18:09:28 +02:00
|
|
|
sections.forEach(section =>
|
2024-06-13 14:26:33 +02:00
|
|
|
{
|
2025-07-03 15:16:20 +02:00
|
|
|
const anchorTarget = section.querySelector('[id]');
|
2024-07-29 17:17:52 +02:00
|
|
|
const anchorHeader = section.querySelector('h1,h2');
|
|
|
|
|
|
|
|
|
|
if (anchorTarget && anchorHeader)
|
2024-07-13 18:09:28 +02:00
|
|
|
{
|
2024-07-29 17:17:52 +02:00
|
|
|
const anchorLink = document.createElement('a');
|
|
|
|
|
anchorLink.className = 'anchor-link';
|
|
|
|
|
anchorLink.href = `#${anchorTarget.id}`;
|
|
|
|
|
anchorLink.innerHTML = ' # ';
|
|
|
|
|
anchorHeader.appendChild(anchorLink);
|
2024-07-13 18:09:28 +02:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2025-05-24 18:47:24 +02:00
|
|
|
// Collapse the navbar in mobile view after clicking a link.
|
|
|
|
|
document.querySelectorAll('#navbarNav li.nav-item>a').forEach(navLink =>
|
2024-06-15 19:49:19 +02:00
|
|
|
{
|
2025-05-24 18:47:24 +02:00
|
|
|
navLink.addEventListener('click', () =>
|
2024-07-13 18:09:28 +02:00
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @type {HTMLButtonElement}
|
|
|
|
|
*/
|
|
|
|
|
const navbarNav = document.querySelector('button.navbar-toggler[aria-expanded="true"]');
|
|
|
|
|
navbarNav?.click();
|
|
|
|
|
});
|
2024-06-15 19:49:19 +02:00
|
|
|
});
|
2024-06-13 14:26:33 +02:00
|
|
|
});
|