@@ -17,14 +17,14 @@ const { fallback = 'animate' } = Astro.props as Props;
1717 index: number;
1818 scrollY: number;
1919 };
20- type Events = 'astro:load' | 'astro:beforeload ';
20+ type Events = 'astro:page- load' | 'astro:after-swap ';
2121
2222 const persistState = (state: State) => history.replaceState(state, '');
2323 const supportsViewTransitions = !!document.startViewTransition;
2424 const transitionEnabledOnThisPage = () =>
2525 !!document.querySelector('[name="astro-view-transitions-enabled"]');
2626 const triggerEvent = (name: Events) => document.dispatchEvent(new Event(name));
27- const onload = () => triggerEvent('astro:load');
27+ const onPageLoad = () => triggerEvent('astro:page- load');
2828 const PERSIST_ATTR = 'data-astro-transition-persist';
2929
3030 // The History API does not tell you if navigation is forward or back, so
@@ -193,7 +193,7 @@ const { fallback = 'animate' } = Astro.props as Props;
193193 scrollTo(0, state.scrollY); // usings default scrollBehavior
194194 }
195195
196- triggerEvent('astro:beforeload ');
196+ triggerEvent('astro:after-swap ');
197197 };
198198
199199 // Wait on links to finish, to prevent FOUC
@@ -263,7 +263,7 @@ const { fallback = 'animate' } = Astro.props as Props;
263263 // document.documentElement.removeAttribute('data-astro-transition');
264264 await runScripts();
265265 markScriptsExec();
266- onload ();
266+ onPageLoad ();
267267 }
268268 }
269269
@@ -383,7 +383,7 @@ const { fallback = 'animate' } = Astro.props as Props;
383383 { passive: true, capture: true }
384384 );
385385 });
386- addEventListener('load', onload );
386+ addEventListener('load', onPageLoad );
387387 // There's not a good way to record scroll position before a back button.
388388 // So the way we do it is by listening to scroll and just continuously recording it.
389389 addEventListener(
0 commit comments