});
-window.addEventListener('scroll', function () {
+
+function getBodyScrollTop() {
+ const el = document.scrollingElement || document.documentElement;
+ return el.scrollTop
+}
+
+document.addEventListener('scroll', function () {
checkScroll();
}, {passive: true});
function checkScroll() {
window.headerHeight = 134;
- var scroll = document.documentElement.scrollTop;
+ var scroll = getBodyScrollTop();
if (scroll > 200) {
document.getElementById('site-header').classList.add('minimized');
window.headerHeight = 60;
- } else if (scroll < 100) {
+ } else {
document.getElementById('site-header').classList.remove('minimized');
}
}
.site-header
--transition-duration 500ms
- @apply bg-navy text-white text-lg font-display font-medium antialiased sticky top-0
+ @apply bg-navy text-white text-lg font-display font-medium antialiased fixed top-0
transition height var(--transition-duration)
width 100%
z-index 100
@include('partials.nav-mobile')
+<div id="header-placeholder"></div>
<header id="site-header" class="site-header">
<div class="container flex items-center py-8 relative z-30">