elm / browser

Create Elm programs that run in browsers!
https://package.elm-lang.org/packages/elm/browser/latest/
BSD 3-Clause "New" or "Revised" License
313 stars 64 forks source link

Support View Transitions API #131

Open gampleman opened 1 year ago

gampleman commented 1 year ago

Chrome recently shipped the View Transition API, which allows to more seamlessly to animate transitions between different views using snapshots, which is particularly handy for immediate mode/VDOM based rendering, as this makes enter/exit animations particularly tricky.

The main thing to support this looks something like this:

 document.startViewTransition(() => patchTheDOM(patches));

Then there is a bunch of CSS syntax available to customise the transitions.

On the Elm side I don't know what the opt-in API would look like (perhaps an extra boolean field in Document?)

Eptis commented 9 months ago

@gampleman This might be of help. Diillon kearns made this example: https://github.com/dillonkearns/elm-view-transitions?tab=readme-ov-file