diff --git a/public/components/header.html b/public/components/header.html index 5ae002d..ca93beb 100644 --- a/public/components/header.html +++ b/public/components/header.html @@ -7,9 +7,9 @@ - Start - Expertise - Kontakt + Start + Expertise + Kontakt @@ -19,4 +19,11 @@ + diff --git a/public/js/components.js b/public/js/components.js index 28ac318..5ad5d9b 100644 --- a/public/js/components.js +++ b/public/js/components.js @@ -1,5 +1,5 @@ // Custom event for when components are fully loaded -const COMPONENTS_LOADED_EVENT = 'componentsLoaded'; +const COMPONENTS_LOADED_EVENT = new Event('componentsLoaded'); document.addEventListener('DOMContentLoaded', function() { // Helper function to handle component loading @@ -28,7 +28,7 @@ document.addEventListener('DOMContentLoaded', function() { ]).then(results => { if (results.every(Boolean)) { // Dispatch custom event when all components are loaded - document.dispatchEvent(new CustomEvent(COMPONENTS_LOADED_EVENT)); + document.dispatchEvent(COMPONENTS_LOADED_EVENT); } }).catch(error => { console.warn('Error loading components:', error); @@ -68,33 +68,35 @@ document.addEventListener('DOMContentLoaded', function() { }); } - // Scroll behavior - let lastScrollTop = 0; - let scrollTimeout; + // Scroll behavior - only enable on index page + if (window.location.pathname === '/' || window.location.pathname === '/index.html') { + let lastScrollTop = 0; + let scrollTimeout; - window.addEventListener('scroll', () => { - if (scrollTimeout) { - window.cancelAnimationFrame(scrollTimeout); - } + window.addEventListener('scroll', () => { + if (scrollTimeout) { + window.cancelAnimationFrame(scrollTimeout); + } - scrollTimeout = window.requestAnimationFrame(() => { - const scrollTop = window.pageYOffset || document.documentElement.scrollTop; - - // Don't hide header when near top of page - if (scrollTop < 100) { - header.style.transform = 'translateY(0)'; - return; - } - - // Hide header on scroll down, show on scroll up - if (scrollTop > lastScrollTop) { - header.style.transform = 'translateY(-100%)'; - } else { - header.style.transform = 'translateY(0)'; - } - - lastScrollTop = scrollTop; - }); - }, { passive: true }); + scrollTimeout = window.requestAnimationFrame(() => { + const scrollTop = window.pageYOffset || document.documentElement.scrollTop; + + // Don't hide header when near top of page + if (scrollTop < 100) { + header.style.transform = 'translateY(0)'; + return; + } + + // Hide header on scroll down, show on scroll up + if (scrollTop > lastScrollTop) { + header.style.transform = 'translateY(-100%)'; + } else { + header.style.transform = 'translateY(0)'; + } + + lastScrollTop = scrollTop; + }); + }, { passive: true }); + } } });