Repository navigation
Replies: 2 comments 1 reply
|
Another use case for I've been playing with a Motion + Solid 2 integration to try the new vanilla layout animations, which were the one thing holding me on React 😅 Slop experiments here: https://github.com/carloitaben/solid-motion-experiments The hard part is hooking into Solid's commit. Motion needs to snapshot the layout before the DOM changes and animate after it does, and right now I get that by calling createMemo(() => items(), {
beforeCommit(next, committed) {
// snapshot old layout
committed.then(() => {
// DOM updated: animate
})
},
})The "newer value waits for the previous commit" ordering also helps, since rapid re-clicks otherwise start overlapping animations. |
|
I had this cool idea: I can probably already implement View Transitions in Solid 2.0 by taking advantage of
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hello,
I saw in view transitions proposal that the goal, post v2.0, is to implement a
ViewTransitionAPI similar to React's.However, I think it may be worthwhile to expose a minimal, lower-level API that gives library authors the flexibility to build their own abstractions around Solid's commit lifecycle and explore different high-level API designs.
This low-level API remains useful even if Solid adopts an official
ViewTransitionAPI, though it risks constraining Solid's internals.Proposal
I propose adding a new option to
createMemo, calledbeforeCommit, which is a callback that is executed just before Solid commits a new value.Proposed behavior
beforeCommit, even if it performs asynchronous work. The commit proceeds independently of the callback's completion.beforeCommitcallbacks running simultaneously.beforeCommitcallback has been invoked, the corresponding new value is guaranteed to be committed to the reactive graph beforebeforeCommitis invoked again for a subsequent, newer value.beforeCommit.Parameters
The
beforeCommitcallback receives the arguments:Example
Here is an example of how this API could be used to support view transitions with an asynchronously derived value:
All reactions