@@ -12,12 +12,9 @@ export const TRANSITION_AFTER_SWAP = 'astro:after-swap';
1212/** @deprecated This will be removed in Astro 7 */
1313export const TRANSITION_PAGE_LOAD = 'astro:page-load' ;
1414
15- type Events =
16- | typeof TRANSITION_AFTER_PREPARATION
17- | typeof TRANSITION_AFTER_SWAP
18- | typeof TRANSITION_PAGE_LOAD ;
15+ type Events = 'astro:after-preparation' | 'astro:after-swap' | 'astro:page-load' ;
1916export const triggerEvent = ( name : Events ) => document . dispatchEvent ( new Event ( name ) ) ;
20- export const onPageLoad = ( ) => triggerEvent ( TRANSITION_PAGE_LOAD ) ;
17+ export const onPageLoad = ( ) => triggerEvent ( 'astro:page-load' ) ;
2118
2219/*
2320 * Common stuff
@@ -91,7 +88,7 @@ export class TransitionBeforePreparationEvent extends BeforeEvent {
9188 loader : ( event : TransitionBeforePreparationEvent ) => Promise < void > ,
9289 ) {
9390 super (
94- TRANSITION_BEFORE_PREPARATION ,
91+ 'astro:before-preparation' ,
9592 { cancelable : true } ,
9693 from ,
9794 to ,
@@ -116,15 +113,15 @@ export class TransitionBeforePreparationEvent extends BeforeEvent {
116113 */
117114/** @deprecated This will be removed in Astro 7 */
118115export const isTransitionBeforeSwapEvent = ( value : any ) : value is TransitionBeforeSwapEvent =>
119- value . type === TRANSITION_BEFORE_SWAP ;
116+ value . type === 'astro:before-swap' ;
120117export class TransitionBeforeSwapEvent extends BeforeEvent {
121118 readonly direction : Direction | string ;
122119 readonly viewTransition : ViewTransition ;
123120 swap : ( ) => void ;
124121
125122 constructor ( afterPreparation : BeforeEvent , viewTransition : ViewTransition ) {
126123 super (
127- TRANSITION_BEFORE_SWAP ,
124+ 'astro:before-swap' ,
128125 undefined ,
129126 afterPreparation . from ,
130127 afterPreparation . to ,
@@ -173,7 +170,7 @@ export async function doPreparation(
173170 if ( document . dispatchEvent ( event ) ) {
174171 await event . loader ( ) ;
175172 if ( ! event . defaultPrevented ) {
176- triggerEvent ( TRANSITION_AFTER_PREPARATION ) ;
173+ triggerEvent ( 'astro:after-preparation' ) ;
177174 if ( event . navigationType !== 'traverse' ) {
178175 // save the current scroll position before we change the DOM and transition to the new page
179176 updateScrollPosition ( { scrollX, scrollY } ) ;
0 commit comments