0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-30 22:03:56 -05:00

Make viewTransition.finished wait for animations triggered by viewTransition.ready (#10787)

This commit is contained in:
Martin Trapp 2024-04-15 10:58:40 +02:00 committed by GitHub
parent 1607face67
commit 699f4559a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
"astro": patch
---
Fixes a timing issue in the view transition simulation.

View file

@ -396,8 +396,10 @@ async function updateDOM(
const style = window.getComputedStyle(effect.target, effect.pseudoElement);
return style.animationIterationCount === 'infinite';
}
// Trigger the animations
const currentAnimations = document.getAnimations();
// allow animations triggered by viewTransition.ready to start
await new Promise<void>((r)=>setTimeout(r));
// Trigger view transition animations waiting for data-astro-transition-fallback
document.documentElement.setAttribute(OLD_NEW_ATTR, phase);
const nextAnimations = document.getAnimations();
const newAnimations = nextAnimations.filter(