2024-04-07 09:57:55 +02:00
|
|
|
const verticalUnit = getUnit("--unit--vertical");
|
|
|
|
|
|
|
|
|
|
function getUnit(id) {
|
|
|
|
|
const remFactor = 16;
|
2024-04-09 08:38:29 +02:00
|
|
|
const rawUnit =
|
|
|
|
|
getComputedStyle(document.documentElement).getPropertyValue(id) || "1.7rem";
|
2024-04-07 09:57:55 +02:00
|
|
|
const remUnit = parseFloat(rawUnit);
|
|
|
|
|
const pxUnit = remUnit * remFactor;
|
|
|
|
|
return pxUnit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function throttle(callback, limit) {
|
|
|
|
|
let waiting = false;
|
|
|
|
|
return function () {
|
|
|
|
|
if (!waiting) {
|
|
|
|
|
callback.apply(this, arguments);
|
|
|
|
|
waiting = true;
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
waiting = false;
|
|
|
|
|
}, limit);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2024-01-26 13:42:00 +01:00
|
|
|
|
2024-03-09 11:27:10 +01:00
|
|
|
function toggleTab(data, tab) {
|
|
|
|
|
if (data.activeTab === tab) {
|
2024-04-06 10:08:45 +02:00
|
|
|
window.scrollTo({
|
|
|
|
|
top: 0,
|
|
|
|
|
behavior: "smooth",
|
|
|
|
|
});
|
2024-03-09 11:27:10 +01:00
|
|
|
setTimeout(() => {
|
2024-03-10 12:03:31 +01:00
|
|
|
data.isOpen = false;
|
2024-04-06 10:08:45 +02:00
|
|
|
data.activeTab = "";
|
2024-04-06 11:55:51 +02:00
|
|
|
}, 500);
|
2024-03-09 11:27:10 +01:00
|
|
|
} else {
|
|
|
|
|
data.activeTab = tab;
|
2024-03-10 12:03:31 +01:00
|
|
|
data.isOpen = true;
|
2024-03-09 11:27:10 +01:00
|
|
|
scrollToElem(".active-tab");
|
|
|
|
|
}
|
2024-01-25 17:05:19 +01:00
|
|
|
}
|
|
|
|
|
|
2024-01-25 18:34:32 +01:00
|
|
|
function scrollToElem(selector) {
|
2024-03-10 12:03:31 +01:00
|
|
|
document.querySelector(".active-tab").scrollTop = 0;
|
2024-01-25 18:34:32 +01:00
|
|
|
setTimeout(() => {
|
2024-03-09 11:27:10 +01:00
|
|
|
const yOffset = -7 * verticalUnit;
|
2024-01-25 18:34:32 +01:00
|
|
|
const elem = document.querySelector(selector);
|
|
|
|
|
const top = elem.getBoundingClientRect().top;
|
|
|
|
|
window.scrollTo({
|
|
|
|
|
top: top + window.scrollY + yOffset,
|
|
|
|
|
behavior: "smooth",
|
|
|
|
|
});
|
|
|
|
|
}, 100);
|
2024-01-25 17:05:19 +01:00
|
|
|
}
|
|
|
|
|
|
2024-04-06 10:08:45 +02:00
|
|
|
function setWindowHeightFactor() {
|
|
|
|
|
const windowHeight = window.innerHeight;
|
|
|
|
|
const min = 650;
|
|
|
|
|
const delta = windowHeight - min;
|
2024-04-06 11:55:51 +02:00
|
|
|
const factor = roundToNearestHalf(delta / 300) + 1;
|
2024-04-06 10:08:45 +02:00
|
|
|
|
2024-04-10 14:55:34 +02:00
|
|
|
document
|
|
|
|
|
.querySelector(":root")
|
|
|
|
|
.style.setProperty("--window-height-factor", factor);
|
2024-04-06 10:08:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function roundToNearestHalf(num) {
|
2024-04-06 11:55:51 +02:00
|
|
|
const round = Math.round(num * 2) / 2;
|
|
|
|
|
return Math.max(round, 0);
|
2024-04-06 10:08:45 +02:00
|
|
|
}
|
|
|
|
|
|
2024-04-07 11:09:43 +02:00
|
|
|
function enableToggleEntriesVisibility() {
|
2024-04-07 12:24:40 +02:00
|
|
|
const entries = document.querySelector("#entry-btns");
|
2024-04-07 11:09:43 +02:00
|
|
|
|
|
|
|
|
const leftBtn = entries.querySelector(".entry-btn--left");
|
|
|
|
|
const rightBtn = entries.querySelector(".entry-btn--right");
|
|
|
|
|
const leftBtnWidth = leftBtn.offsetWidth;
|
|
|
|
|
const rightBtnWidth = rightBtn.offsetWidth;
|
|
|
|
|
|
|
|
|
|
leftBtn.style = `--width: ${leftBtnWidth}px`;
|
|
|
|
|
rightBtn.style = `--width: ${rightBtnWidth}px`;
|
|
|
|
|
|
|
|
|
|
const toggleVisibility = (items) => {
|
|
|
|
|
items.forEach((item) => {
|
|
|
|
|
const isIntersecting = item.isIntersecting;
|
2024-04-07 09:57:55 +02:00
|
|
|
if (isIntersecting) {
|
2024-04-07 11:09:43 +02:00
|
|
|
entries.classList.remove("minimized");
|
2024-04-07 09:57:55 +02:00
|
|
|
} else {
|
2024-04-07 11:09:43 +02:00
|
|
|
entries.classList.add("minimized");
|
2024-04-07 09:57:55 +02:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2024-04-09 10:44:12 +02:00
|
|
|
const top = verticalUnit * 8;
|
2024-04-07 09:57:55 +02:00
|
|
|
|
|
|
|
|
const observer = new IntersectionObserver(toggleVisibility, {
|
|
|
|
|
root: null,
|
|
|
|
|
rootMargin: `-${top}px 0px 0px 0px`,
|
|
|
|
|
threshold: 0,
|
|
|
|
|
});
|
|
|
|
|
|
2024-04-07 11:09:43 +02:00
|
|
|
observer.observe(entries);
|
2024-04-07 09:57:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggleLogoState() {
|
|
|
|
|
const scrollY = window.scrollY || window.pageYOffset;
|
|
|
|
|
|
|
|
|
|
if (scrollY > 10) {
|
|
|
|
|
document.querySelector("#main-header").classList.add("minimized");
|
|
|
|
|
} else {
|
|
|
|
|
document.querySelector("#main-header").classList.remove("minimized");
|
2024-01-25 17:05:19 +01:00
|
|
|
}
|
2024-04-07 09:57:55 +02:00
|
|
|
}
|
2024-01-25 17:05:19 +01:00
|
|
|
|
2024-04-07 12:24:40 +02:00
|
|
|
function togglePanel(side) {
|
|
|
|
|
document.querySelector(`.panel--${side}`).classList.toggle("open");
|
2024-04-09 10:44:12 +02:00
|
|
|
const isOpen = document
|
|
|
|
|
.querySelector(`.panel--${side}`)
|
|
|
|
|
.classList.contains("open");
|
|
|
|
|
|
|
|
|
|
const scrollY = window.scrollY || window.pageYOffset;
|
|
|
|
|
|
|
|
|
|
if (isOpen) {
|
2024-04-09 18:37:45 +02:00
|
|
|
document.querySelector("html").style.overflowY = "hidden";
|
2024-04-09 10:44:12 +02:00
|
|
|
document.querySelector("#main-header").classList.remove("minimized");
|
2024-04-10 14:55:34 +02:00
|
|
|
} else {
|
2024-04-09 18:37:45 +02:00
|
|
|
document.querySelector("html").style.overflowY = "";
|
2024-04-10 14:55:34 +02:00
|
|
|
if (scrollY > 10) {
|
|
|
|
|
document.querySelector("#main-header").classList.add("minimized");
|
|
|
|
|
}
|
2024-04-09 10:44:12 +02:00
|
|
|
}
|
2024-04-07 12:24:40 +02:00
|
|
|
}
|
|
|
|
|
|
2024-04-07 09:57:55 +02:00
|
|
|
document.addEventListener("DOMContentLoaded", () => {
|
2024-03-12 17:41:59 +01:00
|
|
|
window.window.scrollTo({
|
|
|
|
|
top: 0,
|
|
|
|
|
});
|
|
|
|
|
|
2024-04-09 08:38:29 +02:00
|
|
|
window.addEventListener("scroll", () => {
|
|
|
|
|
toggleLogoState();
|
|
|
|
|
});
|
2024-04-09 07:24:22 +02:00
|
|
|
|
2024-04-07 09:57:55 +02:00
|
|
|
setWindowHeightFactor();
|
|
|
|
|
|
|
|
|
|
// Wait for fonts applied
|
|
|
|
|
setTimeout(() => {
|
2024-04-07 11:09:43 +02:00
|
|
|
enableToggleEntriesVisibility();
|
2024-04-07 09:57:55 +02:00
|
|
|
}, 100);
|
2024-01-25 18:34:32 +01:00
|
|
|
});
|