2025-07-10 01:15:13 +00:00
|
|
|
document$.subscribe(function () {
|
|
|
|
const hero = document.querySelector(".hero-banner");
|
|
|
|
const header = document.querySelector(".md-header");
|
|
|
|
const sidebarLeft = document.querySelector(".md-sidebar--primary");
|
|
|
|
const sidebarRight = document.querySelector(".md-sidebar--secondary");
|
|
|
|
|
2025-07-14 19:50:55 +00:00
|
|
|
// Add class to body if hero exists
|
|
|
|
if (hero) {
|
|
|
|
document.body.classList.add("has-hero");
|
|
|
|
} else {
|
|
|
|
// NO HERO - make header solid immediately
|
|
|
|
if (header) {
|
|
|
|
header.classList.add("scrolled");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-07-10 01:15:13 +00:00
|
|
|
if (!hero || !header) return;
|
|
|
|
|
|
|
|
// Reveal hero banner
|
|
|
|
requestAnimationFrame(() => {
|
|
|
|
hero.style.opacity = 1;
|
|
|
|
});
|
|
|
|
|
2025-07-14 19:50:55 +00:00
|
|
|
// Scroll logic - ONLY runs if hero exists
|
2025-07-10 01:15:13 +00:00
|
|
|
function updateUI() {
|
|
|
|
const heroBottom = hero.getBoundingClientRect().bottom;
|
|
|
|
const hasScrolledPastHero = heroBottom <= 0;
|
|
|
|
|
|
|
|
// Update header
|
|
|
|
if (hasScrolledPastHero) {
|
|
|
|
header.classList.add("scrolled");
|
|
|
|
} else {
|
|
|
|
header.classList.remove("scrolled");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle sidebar visibility (only on wide screens)
|
|
|
|
if (window.matchMedia("(min-width: 76.25em)").matches) {
|
|
|
|
const show = hasScrolledPastHero;
|
|
|
|
|
|
|
|
[sidebarLeft, sidebarRight].forEach((sidebar) => {
|
|
|
|
if (!sidebar) return;
|
|
|
|
|
|
|
|
if (show) {
|
|
|
|
sidebar.style.display = "block";
|
|
|
|
requestAnimationFrame(() => {
|
|
|
|
sidebar.style.opacity = "1";
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
sidebar.style.opacity = "0";
|
|
|
|
setTimeout(() => {
|
|
|
|
sidebar.style.display = "none";
|
|
|
|
}, 300);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initial and on scroll
|
|
|
|
window.addEventListener("scroll", updateUI);
|
|
|
|
updateUI(); // Initial run
|
|
|
|
});
|