feat: move script handling to use swup instead of astro transitions, move animations to baselayout
This commit is contained in:
@@ -58,6 +58,12 @@ const normalizeTitle = !title ? global.name : `${title} | ${global.name}`;
|
||||
window.localStorage.setItem('theme', theme);
|
||||
</script>
|
||||
|
||||
<!-- Preline -->
|
||||
<script
|
||||
src="/vendor/preline/collapse2.1.0.min.js"
|
||||
is:inline
|
||||
/>
|
||||
|
||||
<!-- Rybbit Tracking Snippet -->
|
||||
<script
|
||||
src="https://rybbit.alexlebens.dev/api/script.js"
|
||||
@@ -102,7 +108,52 @@ const normalizeTitle = !title ? global.name : `${title} | ${global.name}`;
|
||||
}
|
||||
};
|
||||
resetScroll();
|
||||
document.addEventListener('astro:after-swap', resetScroll);
|
||||
|
||||
document.addEventListener('swup:page:view', () => {
|
||||
resetScroll();
|
||||
if (typeof (window as any).HSStaticMethods !== 'undefined') {
|
||||
(window as any).HSStaticMethods.autoInit();
|
||||
}
|
||||
if (typeof (window as any).rybbit === 'function') {
|
||||
(window as any).rybbit('trackPageview');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
const animateContent = () => {
|
||||
const smoothReveal = document.querySelectorAll('.smooth-reveal');
|
||||
smoothReveal.forEach((el, index) => {
|
||||
setTimeout(() => {
|
||||
el.classList.add('animate-reveal');
|
||||
}, 50 + index * 100);
|
||||
});
|
||||
|
||||
const smoothReveal2 = document.querySelectorAll('.smooth-reveal-2');
|
||||
smoothReveal2.forEach((el, index) => {
|
||||
setTimeout(() => {
|
||||
el.classList.add('animate-reveal');
|
||||
}, 200 + index * 250);
|
||||
});
|
||||
|
||||
const smoothRevealCards = document.querySelectorAll('.smooth-reveal-cards');
|
||||
smoothRevealCards.forEach((el, index) => {
|
||||
setTimeout(() => {
|
||||
el.classList.add('animate-reveal');
|
||||
}, 400 + index * 250);
|
||||
});
|
||||
|
||||
const smoothRevealFade = document.querySelectorAll('.smooth-reveal-fade');
|
||||
smoothRevealFade.forEach((el, index) => {
|
||||
setTimeout(() => {
|
||||
el.classList.add('animate-reveal-fade');
|
||||
}, 100 + index * 250);
|
||||
});
|
||||
};
|
||||
|
||||
animateContent();
|
||||
|
||||
document.addEventListener('swup:page:view', animateContent);
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
Reference in New Issue
Block a user