From fa4367792b1d53b8e89475eb046d5a46cc5fdb34 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Thu, 3 Aug 2023 19:57:36 -0400 Subject: [PATCH] Revert "Fix race condition when performing swap for fallback" This reverts commit e5f7d11ef5564e4ecf450a8235cbe5b2b89e4e5c. --- packages/astro/components/ViewTransitions.astro | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/astro/components/ViewTransitions.astro b/packages/astro/components/ViewTransitions.astro index 7f4a60988..78c723efc 100644 --- a/packages/astro/components/ViewTransitions.astro +++ b/packages/astro/components/ViewTransitions.astro @@ -168,18 +168,13 @@ const { fallback = 'animate' } = Astro.props as Props; // Trigger the animations document.documentElement.dataset.astroTransitionFallback = 'old'; - const fallbackSwap = () => { - removeEventListener('animationend', fallbackSwap); - clearTimeout(timeout); - swap(); - document.documentElement.dataset.astroTransitionFallback = 'new'; - }; + doc.documentElement.dataset.astroTransitionFallback = 'new'; // If there are any animations, want for the animationend event. - addEventListener('animationend', fallbackSwap, { once: true }); + addEventListener('animationend', swap, { once: true }); // If there are no animations, go ahead and swap on next tick // This is necessary because we do not know if there are animations. // The setTimeout is a fallback in case there are none. - var timeout = setTimeout(() => !isAnimating && fallbackSwap()); + setTimeout(() => !isAnimating && swap()); } else { swap(); }