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
  • Loading branch information
martrapp committed Apr 13, 2024
1 parent 174ce25 commit 9675710
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 9675710

Please sign in to comment.