SolidJS and View Transitions API: A match made in heaven. #1933
kevintakeda
started this conversation in
Show and tell
Replies: 1 comment 5 replies
-
Hi @mishimalisa and others! const transition = function (fnStartingTheSynchronousTransition) {
// In case the API is not yet supported
if (!document.startViewTransition) { return fnStartingTheSynchronousTransition() }
// Transition the changes in the DOM
const transition = document.startViewTransition(fnStartingTheSynchronousTransition)
}
useBeforeLeave((e) => {
// Stop the inmediate navigation and DOM change
e.preventDefault()
// Perform the action that triggers a DOM change synchronously
transition(() => { e.retry(true) })
})) Tough it works, to me this does not really seem to be the way it should be done. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I came to appreciate the seamless experience of working with SolidJS and View Transitions API, thanks to its synchronous updates, eliminating the need for asynchronous operations.
Demo 0 (counter):
https://playground.solidjs.com/anonymous/b69093be-3fff-4e1b-b20d-879fccf0fb4b
Demo 1 (shopping cart):
https://playground.solidjs.com/anonymous/515472ff-c71f-4205-b680-d56404acf37c
Demo 2 (shopping cart multiple):
https://playground.solidjs.com/anonymous/e4742f65-deb1-45e4-b351-12be5fcab536
Demo 3 (starfield):
https://playground.solidjs.com/anonymous/085a66fa-3d83-42d1-b9ad-64b0fb04c784
Demo 4 (multiplying stars):
https://playground.solidjs.com/anonymous/d9a2e72d-d843-48f8-820c-d223d9466815
Obs: Works on latest Chrome. Unfortunately, doesn't work on Firefox or Safari.
Beta Was this translation helpful? Give feedback.
All reactions