diff --git a/src/components/common/BasicScripts.astro b/src/components/common/BasicScripts.astro index 9451c9a..28aa1b1 100644 --- a/src/components/common/BasicScripts.astro +++ b/src/components/common/BasicScripts.astro @@ -97,7 +97,7 @@ import { UI } from '~/utils/config'; }); function appyHeaderStylesOnScroll() { - const header = document.getElementById('header'); + const header = document.querySelector("#header[data-aw-sticky-header]"); if (lastKnownScrollPosition > 60 && !header.classList.contains('scroll')) { document.getElementById('header').classList.add('scroll'); } else if (lastKnownScrollPosition <= 60 && header.classList.contains('scroll')) { diff --git a/src/components/widgets/Header.astro b/src/components/widgets/Header.astro index bee8011..79866ab 100644 --- a/src/components/widgets/Header.astro +++ b/src/components/widgets/Header.astro @@ -54,6 +54,7 @@ const currentPath = `/${trimSlash(new URL(Astro.url).pathname)}` { sticky: isSticky, relative: !isSticky, dark: isDark }, "top-0 z-40 flex-none mx-auto w-full border-b border-gray-50/0 transition-[opacity] ease-in-out", ]} + {...isSticky ? { "data-aw-sticky-header": true } : {}} {...id ? { id } : {}} >