feat: slight optimization

This commit is contained in:
2026-03-05 19:12:39 -06:00
parent 2c2077053b
commit fe6604a5d9

View File

@@ -93,15 +93,26 @@ const normalizeTitle = !title ? global.name : `${title} | ${global.name}`;
<script>
document.addEventListener('astro:page-load', () => {
let ticking = false;
const onScroll = () => {
document.documentElement.style.setProperty('--scroll-offset', `${window.scrollY}px`);
document.documentElement.classList.add('has-js');
if (!ticking) {
window.requestAnimationFrame(() => {
document.documentElement.style.setProperty('--scroll-offset', `${window.scrollY}px`);
ticking = false;
});
ticking = true;
}
};
window.removeEventListener('scroll', onScroll);
window.addEventListener('scroll', onScroll, { passive: true });
onScroll();
document.documentElement.classList.add('has-js');
document.addEventListener('astro:before-swap', () => {
window.removeEventListener('scroll', onScroll);
}, { once: true });
});
</script>
@@ -129,6 +140,7 @@ const normalizeTitle = !title ? global.name : `${title} | ${global.name}`;
-webkit-mask-position-y: var(--scroll-offset);
mask-position-y: var(--scroll-offset);
will-change: mask-position;
}
/* Background that creates the "glimmer" effect */