Re: [csswg-drafts] [css-view-transitions-1] Handling DOM updates when a transition's animation is reverse back to start/canceled (#7957)

@khushalsagar yes.
After I opened this issue I realized creating a new transition won't give us the result we need, because, as you say:

> First option would be easy but creating a new ViewTransition would cause us to first jump to the DOM state that the current transition will end at.

So what we really need is reverse the animations so that the effect is running backwards from current position, not have it jump to end result and play from there. That means we're animating back from the "new" images to the "old" ones. And as the effect finishes we need to update the DOM again back to the old state and remove the "old" image that should be identical to the current state (or perhaps fade it out?).
And for that I guess we need to change the API to support this.

We don't need to take another snapshot of the UI, since we already have one, we probably want to simply reverse all `running` animations that are playing on the pseudo-tree of the transition, not really `document.getAnimations()` since that will return _all_ CSS Animations, Web Animations, and CSS Transitions on the document and its descendants.
Maybe have something like `transition.getAnimations()`?
If we have `paused` animations, like mentioned in #7785, they will probably be scrubbed all the way back, and then signal to the transition that we want to update DOM back to old state and finish it, could be using same method as `transition.reverse()`.

So, I suppose it could use a method like:
```
transition.reverse();
```
As a handy way to reverse the animations, and then when it's actually done we want to update the DOM back to old state.

What I'm still not sure of is how to handle the `finished` promise. Should it reject?

-- 
GitHub Notification of comment by ydaniv
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7957#issuecomment-1295864658 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Saturday, 29 October 2022 15:06:47 UTC