Revert "Fix race condition when performing swap for fallback"
This reverts commit e5f7d11ef5
.
This commit is contained in:
parent
e5f7d11ef5
commit
fa4367792b
1 changed files with 3 additions and 8 deletions
|
@ -168,18 +168,13 @@ const { fallback = 'animate' } = Astro.props as Props;
|
||||||
|
|
||||||
// Trigger the animations
|
// Trigger the animations
|
||||||
document.documentElement.dataset.astroTransitionFallback = 'old';
|
document.documentElement.dataset.astroTransitionFallback = 'old';
|
||||||
const fallbackSwap = () => {
|
doc.documentElement.dataset.astroTransitionFallback = 'new';
|
||||||
removeEventListener('animationend', fallbackSwap);
|
|
||||||
clearTimeout(timeout);
|
|
||||||
swap();
|
|
||||||
document.documentElement.dataset.astroTransitionFallback = 'new';
|
|
||||||
};
|
|
||||||
// If there are any animations, want for the animationend event.
|
// 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
|
// If there are no animations, go ahead and swap on next tick
|
||||||
// This is necessary because we do not know if there are animations.
|
// This is necessary because we do not know if there are animations.
|
||||||
// The setTimeout is a fallback in case there are none.
|
// The setTimeout is a fallback in case there are none.
|
||||||
var timeout = setTimeout(() => !isAnimating && fallbackSwap());
|
setTimeout(() => !isAnimating && swap());
|
||||||
} else {
|
} else {
|
||||||
swap();
|
swap();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue