diff --git a/public/js/haus-schleusingen.js b/public/js/haus-schleusingen.js index 8ab087a..7c5c95a 100755 --- a/public/js/haus-schleusingen.js +++ b/public/js/haus-schleusingen.js @@ -1,16 +1,23 @@ document.addEventListener("DOMContentLoaded", function () { // Navbar scroll var navbar = document.getElementById("navbar"); - window.addEventListener("scroll", function () { + function checkScroll() { if (window.scrollY > 60) navbar.classList.add("scrolled"); else navbar.classList.remove("scrolled"); - }); + } + // Check immediately on load (for non-hero pages already scrolled) + checkScroll(); + window.addEventListener("scroll", checkScroll); - // Hero animation on load - setTimeout(function () { - document.getElementById("heroContent").classList.add("visible"); - document.getElementById("heroBg").classList.add("loaded"); - }, 200); + // Hero animation on load (only if hero elements exist) + var heroContent = document.getElementById("heroContent"); + var heroBg = document.getElementById("heroBg"); + if (heroContent || heroBg) { + setTimeout(function () { + if (heroContent) heroContent.classList.add("visible"); + if (heroBg) heroBg.classList.add("loaded"); + }, 200); + } // Scroll animations via IntersectionObserver var animElements = document.querySelectorAll(".fact, [data-animate]"); @@ -177,7 +184,6 @@ document.addEventListener("DOMContentLoaded", function () { // Form submit is handled server-side by PHP – no JS intervention needed. // Success feedback is shown via #form-result after server redirect. - }); }); // Mobile hamburger menu (vanilla JS)