solidjs-motion 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/presence.tsx +13 -0
- package/src/primitives/createMotion.ts +40 -13
package/package.json
CHANGED
package/src/presence.tsx
CHANGED
|
@@ -204,6 +204,19 @@ export const Presence: Component<PresenceProps> = (props) => {
|
|
|
204
204
|
runEnters.set(el, runEnter)
|
|
205
205
|
},
|
|
206
206
|
beforeMount: (el) => {
|
|
207
|
+
// Fires the runEnter for THE tracked element that transition-group
|
|
208
|
+
// is signalling via onEnter / onChange.added. Nested motion
|
|
209
|
+
// descendants of this element do NOT have their runEnter fired
|
|
210
|
+
// here — they handle their own readiness via createMotion's
|
|
211
|
+
// isConnected-based fallback (see the comment at that fallback
|
|
212
|
+
// site for why). Doing the subtree walk here was tried and
|
|
213
|
+
// misfired during wait-mode nested-Presence swaps: NESTED
|
|
214
|
+
// Presence's onEnter runs synchronously while NESTED's Panel is
|
|
215
|
+
// still off-DOM inside the outer page-transition holding pen, so
|
|
216
|
+
// flipping enterReady=true would dispatch animate to a
|
|
217
|
+
// disconnected element and the WAAPI commitStyles would silently
|
|
218
|
+
// drop, leaving the element painted at its animate target with
|
|
219
|
+
// no visible transition.
|
|
207
220
|
const fn = runEnters.get(el)
|
|
208
221
|
runEnters.delete(el)
|
|
209
222
|
fn?.()
|
|
@@ -482,20 +482,47 @@ export function createMotion(
|
|
|
482
482
|
const inPresence = presence.registerEnter !== undefined
|
|
483
483
|
const [enterReady, setEnterReady] = createSignal(!inPresence)
|
|
484
484
|
if (inPresence && presence.registerEnter) {
|
|
485
|
-
|
|
486
|
-
//
|
|
487
|
-
//
|
|
488
|
-
//
|
|
489
|
-
//
|
|
490
|
-
//
|
|
491
|
-
//
|
|
492
|
-
//
|
|
493
|
-
//
|
|
494
|
-
//
|
|
495
|
-
//
|
|
496
|
-
|
|
497
|
-
|
|
485
|
+
// Single source of truth for readiness: `el.isConnected`. The diff
|
|
486
|
+
// effect's first iteration must NOT fire animate against a
|
|
487
|
+
// disconnected element — motion's WAAPI animation runs to completion
|
|
488
|
+
// off-DOM, then silently drops `commitStyles`, leaving the element
|
|
489
|
+
// painted at its `initial` target with no visible transition.
|
|
490
|
+
//
|
|
491
|
+
// Both signals that could trip readiness are routed through this
|
|
492
|
+
// function:
|
|
493
|
+
//
|
|
494
|
+
// 1. Presence's `beforeMount(el)` callback — fires when
|
|
495
|
+
// transition-group inserts the tracked element. For a tracked
|
|
496
|
+
// direct child of Presence, by the time this fires the element
|
|
497
|
+
// is in the DOM, so `isConnected` is true and we flip
|
|
498
|
+
// immediately. For a NESTED motion element inside a deeper
|
|
499
|
+
// Presence whose `onEnter` fires synchronously during render
|
|
500
|
+
// (while the surrounding outer-Presence-tracked subtree is
|
|
501
|
+
// STILL off-DOM in a holding pen), `isConnected` is false and
|
|
502
|
+
// we schedule a retry.
|
|
503
|
+
//
|
|
504
|
+
// 2. The initial-microtask fallback — for cases where Presence's
|
|
505
|
+
// `beforeMount` doesn't fire at all (e.g., a `<Presence
|
|
506
|
+
// initial={false}>` appear=false case, where transition-group
|
|
507
|
+
// doesn't raise enter for the initial source items).
|
|
508
|
+
//
|
|
509
|
+
// The rAF retry self-terminates the moment `setEnterReady(true)`
|
|
510
|
+
// fires; the `live` flag (cleared via `onCleanup`) prevents leaks
|
|
511
|
+
// if the owner is disposed before insertion ever happens.
|
|
512
|
+
let live = true
|
|
513
|
+
onCleanup(() => {
|
|
514
|
+
live = false
|
|
498
515
|
})
|
|
516
|
+
const checkConnection = (): void => {
|
|
517
|
+
if (!live) return
|
|
518
|
+
if (el.isConnected) {
|
|
519
|
+
setEnterReady(true)
|
|
520
|
+
return
|
|
521
|
+
}
|
|
522
|
+
requestAnimationFrame(checkConnection)
|
|
523
|
+
}
|
|
524
|
+
presence.registerEnter(el, checkConnection)
|
|
525
|
+
queueMicrotask(checkConnection)
|
|
499
526
|
}
|
|
500
527
|
|
|
501
528
|
// ---------- Gesture state machine (Q3b, ADR 0002) ----------
|