Remove unused SSR module and remove first load fade (#835)

* disable SSR module in 11ty

* remove first load fade
This commit is contained in:
Cory LaViska
2025-03-26 10:45:29 -04:00
committed by GitHub
parent 041555fe99
commit 0db9ca12e3
2 changed files with 42 additions and 28 deletions

View File

@@ -1,8 +1,20 @@
let initialPageLoadComplete = false;
window.addEventListener('load', () => {
initialPageLoadComplete = true;
});
// Helper for view transitions
export function domChange(fn, { behavior = 'smooth' } = {}) {
export function domChange(fn, { behavior = 'smooth', ignoreInitialLoad = true } = {}) {
const canUseViewTransitions =
document.startViewTransition && !window.matchMedia('(prefers-reduced-motion: reduce)').matches;
// Skip transitions on initial page load
if (!initialPageLoadComplete && ignoreInitialLoad) {
fn(false);
return null;
}
if (canUseViewTransitions && behavior === 'smooth') {
const transition = document.startViewTransition(() => {
fn(true);
@@ -10,6 +22,9 @@ export function domChange(fn, { behavior = 'smooth' } = {}) {
return new Promise(resolve => setTimeout(resolve, 200));
});
return transition;
} else {
fn(false);
return null;
}
}