Re: [csswg-drafts] [css-view-transitions-2] Allow synchronous snapshots (#9400)

Yeah that's a good clear explanation, thanks.

Here are some snapshot lifecycles for popular view libraries:

- React: [`getSnapshotBeforeUpdate`](https://react.dev/reference/react/Component#getsnapshotbeforeupdate) - not deprecated!
- Vue: [`beforeUpdate`](https://vuejs.org/api/options-lifecycle.html#beforeupdate)
- Svelte: [`beforeUpdate`](https://learn.svelte.dev/tutorial/update)

> For example, you have these CSS animations running. If we do some sync snapshotting at the start, and then let animations keep running until we're ready to commit, wouldn't that create a jump?

The animation wouldn't keep running, it would be paused for a much shorter amount of time. 

```javascript
const transition = document.snapshotViewTransition() // pause
transition.notifyUpdated() // start transition
```

> I still think that the solution for this is something like React.startViewTransition that does this internally, if React doesn't want to expose those hooks.

From my perspective, rather than wait what is probably years for these view libraries to offer good APIs, by making this one API more fungible it could be solved in userland today. In the meantime we're going to have blocked UIs all over the web.

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


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

Received on Tuesday, 26 September 2023 13:54:18 UTC