update
This commit is contained in:
@@ -16,10 +16,15 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
|
||||
// Header shrink on scroll
|
||||
let ticking = false;
|
||||
const onScroll = () => {
|
||||
if (!header) return;
|
||||
const shouldShrink = window.scrollY > 40;
|
||||
header.classList.toggle('is-scrolled', shouldShrink);
|
||||
if (ticking || !header) return;
|
||||
ticking = true;
|
||||
window.requestAnimationFrame(() => {
|
||||
const shouldShrink = window.scrollY > 120;
|
||||
header.classList.toggle('is-scrolled', shouldShrink);
|
||||
ticking = false;
|
||||
});
|
||||
};
|
||||
onScroll();
|
||||
window.addEventListener('scroll', onScroll, { passive: true });
|
||||
|
||||
Reference in New Issue
Block a user