Skip to content

Commit

Permalink
Make viewTransition.finished wait for animations triggered by viewTra…
Browse files Browse the repository at this point in the history
…nsition.ready (#10787)
  • Loading branch information
martrapp authored Apr 15, 2024
1 parent 1607fac commit 699f455
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/stupid-countries-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro": patch
---

Fixes a timing issue in the view transition simulation.
4 changes: 3 additions & 1 deletion packages/astro/src/transitions/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 699f455

Please sign in to comment.