From 9bf44e316736e5f024bbb96deda4d01b94a09d8f Mon Sep 17 00:00:00 2001 From: Martin Trapp <94928215+martrapp@users.noreply.github.com> Date: Wed, 30 Oct 2024 08:25:54 +0100 Subject: [PATCH 1/2] formatting --- src/dom-view-transisions-level2.d.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/dom-view-transisions-level2.d.ts b/src/dom-view-transisions-level2.d.ts index b919d38..94db293 100644 --- a/src/dom-view-transisions-level2.d.ts +++ b/src/dom-view-transisions-level2.d.ts @@ -5,11 +5,10 @@ declare global { } type UpdateCallback = undefined | (() => void | Promise); - type StartViewTransitionParameter - = UpdateCallback | { types?: string[]; update: UpdateCallback }; + type StartViewTransitionParameter = UpdateCallback | { types?: string[]; update: UpdateCallback }; interface Document { - startViewTransition(param: StartViewTransitionParameter): ViewTransition; + startViewTransition(param: StartViewTransitionParameter): ViewTransition; } interface PageRevealEvent extends Event { viewTransition: ViewTransition; From d8b18b254d9d84ee84e7c8172fa29050d80b1819 Mon Sep 17 00:00:00 2001 From: Martin Trapp <94928215+martrapp@users.noreply.github.com> Date: Wed, 30 Oct 2024 08:26:43 +0100 Subject: [PATCH 2/2] simplifications --- src/vanilla.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/vanilla.ts b/src/vanilla.ts index 345a8ad..ffc496e 100644 --- a/src/vanilla.ts +++ b/src/vanilla.ts @@ -15,17 +15,11 @@ function init() { self.crossingStorage = crossing.fun; } - document.addEventListener('astro:after-preparation', () => { - pageSwap(); - }); - document.addEventListener('astro:after-swap', () => { - pageReveal(); - }); + document.addEventListener('astro:after-preparation', pageSwap); + document.addEventListener('astro:after-swap', pageReveal); - self.addEventListener('onpageswap' in self ? 'pageswap' : 'pagehide', pageSwap, { once: true }); - self.addEventListener('onpagereveal' in self ? 'pagereveal' : 'DOMContentLoaded', pageReveal, { - once: true, - }); + self.addEventListener('onpageswap' in self ? 'pageswap' : 'pagehide', pageSwap); + self.addEventListener('onpagereveal' in self ? 'pagereveal' : 'DOMContentLoaded', pageReveal); } function pageSwap() {