Skip to content

Commit 699f455

Browse files
authored
Make viewTransition.finished wait for animations triggered by viewTransition.ready (#10787)
1 parent 1607fac commit 699f455

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"astro": patch
3+
---
4+
5+
Fixes a timing issue in the view transition simulation.

packages/astro/src/transitions/router.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,10 @@ async function updateDOM(
396396
const style = window.getComputedStyle(effect.target, effect.pseudoElement);
397397
return style.animationIterationCount === 'infinite';
398398
}
399-
// Trigger the animations
400399
const currentAnimations = document.getAnimations();
400+
// allow animations triggered by viewTransition.ready to start
401+
await new Promise<void>((r)=>setTimeout(r));
402+
// Trigger view transition animations waiting for data-astro-transition-fallback
401403
document.documentElement.setAttribute(OLD_NEW_ATTR, phase);
402404
const nextAnimations = document.getAnimations();
403405
const newAnimations = nextAnimations.filter(

0 commit comments

Comments
 (0)