revert handling of JavaScript animations during view transitions #10841
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
This is edge-case-land of Astro's view transition simulation when you do not use CSS only but also want to combine it with JavaScript animations.
While #10787 worked fine for Firefox on desktops, it introduced a regression on mobile WebKit browsers.
Video.mp4
The blinking screen in the middle of the animation is a result of un-animated rendering before the animation kicks in. Reverting #10787 fixes this.
As an afterthought, it would have been better to switch micro tasks instead of yielding to the tasks queue. But after consulting the spec again (https://drafts.csswg.org/css-view-transitions-1/), I'm not sure whether this goes into the right direction. In browsers with native view transition support
viewTransition.finished
would not wait for arbitrary animations triggered byviewTransition.ready
.It would only include animations that depend on the view transition pseudo elements. Translated to Astro that would mean only animations that depend on
data-astro-transition*
attributes. This thinking leads to a straight forward solution for JavaScript animations:If you want to delay
finished
in Astro's view transition simulation for a JavaScript animation triggered by ready, add a noop animation that is triggered bydata-astro-transition-fallback="new"
. This will automatically be covered byfallback="animate"
.Testing
No automated tests as this only shows on browsers which we do not include in our e2e tests.
After removing the round trip through the task queue, the transition looks smooth again. The noop CSS animation shown above was used to fix the original issue faced in #10787
Video2.mp4
Docs
n.a. / Bug fix