@wardic/dom 1.0.1 → 1.1.1
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/dist/Appear.d.ts +3 -2
- package/dist/Appear.d.ts.map +1 -1
- package/dist/Appear.js +4 -3
- package/dist/Appear.js.map +1 -1
- package/dist/DomProjectionSystem.js +3 -3
- package/dist/DomProjectionSystem.js.map +1 -1
- package/dist/FlushGate.d.ts +6 -6
- package/dist/FlushGate.d.ts.map +1 -1
- package/dist/FlushGate.js +11 -8
- package/dist/FlushGate.js.map +1 -1
- package/dist/ReorderController.js +3 -3
- package/dist/ReorderController.js.map +1 -1
- package/dist/Report.d.ts +1 -1
- package/dist/Report.d.ts.map +1 -1
- package/dist/Report.js +3 -2
- package/dist/Report.js.map +1 -1
- package/dist/Style.d.ts +2 -1
- package/dist/Style.d.ts.map +1 -1
- package/dist/Style.js +3 -1
- package/dist/Style.js.map +1 -1
- package/dist/TimelineValue.d.ts +18 -0
- package/dist/TimelineValue.d.ts.map +1 -0
- package/dist/TimelineValue.js +20 -0
- package/dist/TimelineValue.js.map +1 -0
- package/dist/index.d.ts +13 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/appear.d.ts +10 -4
- package/dist/internal/appear.d.ts.map +1 -1
- package/dist/internal/appear.js +18 -8
- package/dist/internal/appear.js.map +1 -1
- package/dist/internal/batch-handoff.d.ts +25 -0
- package/dist/internal/batch-handoff.d.ts.map +1 -0
- package/dist/internal/batch-handoff.js +64 -0
- package/dist/internal/batch-handoff.js.map +1 -0
- package/dist/internal/drag-defaults.js +4 -1
- package/dist/internal/drag-defaults.js.map +1 -1
- package/dist/internal/gate-environment.d.ts +4 -0
- package/dist/internal/gate-environment.d.ts.map +1 -0
- package/dist/internal/gate-environment.js +21 -0
- package/dist/internal/gate-environment.js.map +1 -0
- package/dist/internal/projection.d.ts.map +1 -1
- package/dist/internal/projection.js +22 -21
- package/dist/internal/projection.js.map +1 -1
- package/dist/internal/renderer.d.ts +13 -0
- package/dist/internal/renderer.d.ts.map +1 -1
- package/dist/internal/renderer.js +21 -0
- package/dist/internal/renderer.js.map +1 -1
- package/dist/internal/reorder.d.ts +2 -2
- package/dist/internal/reorder.d.ts.map +1 -1
- package/dist/internal/reorder.js +2 -2
- package/dist/internal/reorder.js.map +1 -1
- package/dist/internal/scroll.d.ts +17 -0
- package/dist/internal/scroll.d.ts.map +1 -1
- package/dist/internal/scroll.js +23 -15
- package/dist/internal/scroll.js.map +1 -1
- package/dist/internal/starting-style.d.ts +0 -83
- package/dist/internal/starting-style.d.ts.map +1 -1
- package/dist/internal/starting-style.js +16 -143
- package/dist/internal/starting-style.js.map +1 -1
- package/dist/internal/timeline.d.ts +56 -0
- package/dist/internal/timeline.d.ts.map +1 -0
- package/dist/internal/timeline.js +389 -0
- package/dist/internal/timeline.js.map +1 -0
- package/dist/unstable/AppearAnimations.d.ts +191 -0
- package/dist/unstable/AppearAnimations.d.ts.map +1 -0
- package/dist/unstable/AppearAnimations.js +561 -0
- package/dist/unstable/AppearAnimations.js.map +1 -0
- package/dist/unstable/BatchMembers.d.ts +513 -0
- package/dist/unstable/BatchMembers.d.ts.map +1 -0
- package/dist/unstable/BatchMembers.js +2490 -0
- package/dist/unstable/BatchMembers.js.map +1 -0
- package/dist/unstable/DomValues.d.ts +25 -0
- package/dist/unstable/DomValues.d.ts.map +1 -0
- package/dist/unstable/DomValues.js +45 -0
- package/dist/unstable/DomValues.js.map +1 -0
- package/dist/unstable/DragConstraints.d.ts +48 -0
- package/dist/unstable/DragConstraints.d.ts.map +1 -0
- package/dist/unstable/DragConstraints.js +49 -0
- package/dist/unstable/DragConstraints.js.map +1 -0
- package/dist/unstable/DragControls.d.ts +50 -0
- package/dist/unstable/DragControls.d.ts.map +1 -0
- package/dist/unstable/DragControls.js +55 -0
- package/dist/unstable/DragControls.js.map +1 -0
- package/dist/unstable/DragDefaults.d.ts +34 -0
- package/dist/unstable/DragDefaults.d.ts.map +1 -0
- package/dist/unstable/DragDefaults.js +47 -0
- package/dist/unstable/DragDefaults.js.map +1 -0
- package/dist/unstable/DragTrack.d.ts +236 -0
- package/dist/unstable/DragTrack.d.ts.map +1 -0
- package/dist/unstable/DragTrack.js +646 -0
- package/dist/unstable/DragTrack.js.map +1 -0
- package/dist/unstable/DragTransition.d.ts +22 -0
- package/dist/unstable/DragTransition.d.ts.map +1 -0
- package/dist/unstable/DragTransition.js +31 -0
- package/dist/unstable/DragTransition.js.map +1 -0
- package/dist/unstable/ElementSetup.d.ts +144 -0
- package/dist/unstable/ElementSetup.d.ts.map +1 -0
- package/dist/unstable/ElementSetup.js +297 -0
- package/dist/unstable/ElementSetup.js.map +1 -0
- package/dist/unstable/Feature.d.ts +221 -0
- package/dist/unstable/Feature.d.ts.map +1 -0
- package/dist/unstable/Feature.js +281 -0
- package/dist/unstable/Feature.js.map +1 -0
- package/dist/unstable/GestureFeatures.d.ts +30 -0
- package/dist/unstable/GestureFeatures.d.ts.map +1 -0
- package/dist/unstable/GestureFeatures.js +32 -0
- package/dist/unstable/GestureFeatures.js.map +1 -0
- package/dist/unstable/GestureInfo.d.ts +61 -0
- package/dist/unstable/GestureInfo.d.ts.map +1 -0
- package/dist/unstable/GestureInfo.js +23 -0
- package/dist/unstable/GestureInfo.js.map +1 -0
- package/dist/unstable/Imperative.d.ts +214 -0
- package/dist/unstable/Imperative.d.ts.map +1 -0
- package/dist/unstable/Imperative.js +768 -0
- package/dist/unstable/Imperative.js.map +1 -0
- package/dist/unstable/Instant.d.ts +46 -0
- package/dist/unstable/Instant.d.ts.map +1 -0
- package/dist/unstable/Instant.js +49 -0
- package/dist/unstable/Instant.js.map +1 -0
- package/dist/unstable/LayoutGroup.d.ts +14 -0
- package/dist/unstable/LayoutGroup.d.ts.map +1 -0
- package/dist/unstable/LayoutGroup.js +31 -0
- package/dist/unstable/LayoutGroup.js.map +1 -0
- package/dist/unstable/LayoutMember.d.ts +127 -0
- package/dist/unstable/LayoutMember.d.ts.map +1 -0
- package/dist/unstable/LayoutMember.js +176 -0
- package/dist/unstable/LayoutMember.js.map +1 -0
- package/dist/unstable/LiveStyle.d.ts +171 -0
- package/dist/unstable/LiveStyle.d.ts.map +1 -0
- package/dist/unstable/LiveStyle.js +329 -0
- package/dist/unstable/LiveStyle.js.map +1 -0
- package/dist/unstable/MemberHold.d.ts +3 -0
- package/dist/unstable/MemberHold.d.ts.map +1 -0
- package/dist/unstable/MemberHold.js +223 -0
- package/dist/unstable/MemberHold.js.map +1 -0
- package/dist/unstable/OwnerScope.d.ts +16 -0
- package/dist/unstable/OwnerScope.d.ts.map +1 -0
- package/dist/unstable/OwnerScope.js +35 -0
- package/dist/unstable/OwnerScope.js.map +1 -0
- package/dist/unstable/PresenceController.d.ts +128 -0
- package/dist/unstable/PresenceController.d.ts.map +1 -0
- package/dist/unstable/PresenceController.js +1427 -0
- package/dist/unstable/PresenceController.js.map +1 -0
- package/dist/unstable/Press.d.ts +26 -0
- package/dist/unstable/Press.d.ts.map +1 -0
- package/dist/unstable/Press.js +19 -0
- package/dist/unstable/Press.js.map +1 -0
- package/dist/unstable/ServerInterpolators.d.ts +17 -0
- package/dist/unstable/ServerInterpolators.d.ts.map +1 -0
- package/dist/unstable/ServerInterpolators.js +20 -0
- package/dist/unstable/ServerInterpolators.js.map +1 -0
- package/dist/unstable/WardConfig.d.ts +567 -0
- package/dist/unstable/WardConfig.d.ts.map +1 -0
- package/dist/unstable/WardConfig.js +2 -0
- package/dist/unstable/WardConfig.js.map +1 -0
- package/dist/unstable/features/All.d.ts +24 -0
- package/dist/unstable/features/All.d.ts.map +1 -0
- package/dist/unstable/features/All.js +20 -0
- package/dist/unstable/features/All.js.map +1 -0
- package/dist/unstable/features/Colors.d.ts +12 -0
- package/dist/unstable/features/Colors.d.ts.map +1 -0
- package/dist/unstable/features/Colors.js +38 -0
- package/dist/unstable/features/Colors.js.map +1 -0
- package/dist/unstable/features/DomAnimation.d.ts +16 -0
- package/dist/unstable/features/DomAnimation.d.ts.map +1 -0
- package/dist/unstable/features/DomAnimation.js +19 -0
- package/dist/unstable/features/DomAnimation.js.map +1 -0
- package/dist/unstable/features/DomMax.d.ts +12 -0
- package/dist/unstable/features/DomMax.d.ts.map +1 -0
- package/dist/unstable/features/DomMax.js +14 -0
- package/dist/unstable/features/DomMax.js.map +1 -0
- package/dist/unstable/features/Drag.d.ts +5 -0
- package/dist/unstable/features/Drag.d.ts.map +1 -0
- package/dist/unstable/features/Drag.js +32 -0
- package/dist/unstable/features/Drag.js.map +1 -0
- package/dist/unstable/features/Focus.d.ts +5 -0
- package/dist/unstable/features/Focus.d.ts.map +1 -0
- package/dist/unstable/features/Focus.js +20 -0
- package/dist/unstable/features/Focus.js.map +1 -0
- package/dist/unstable/features/Hover.d.ts +5 -0
- package/dist/unstable/features/Hover.d.ts.map +1 -0
- package/dist/unstable/features/Hover.js +20 -0
- package/dist/unstable/features/Hover.js.map +1 -0
- package/dist/unstable/features/InView.d.ts +5 -0
- package/dist/unstable/features/InView.d.ts.map +1 -0
- package/dist/unstable/features/InView.js +20 -0
- package/dist/unstable/features/InView.js.map +1 -0
- package/dist/unstable/features/Input.d.ts +28 -0
- package/dist/unstable/features/Input.d.ts.map +1 -0
- package/dist/unstable/features/Input.js +31 -0
- package/dist/unstable/features/Input.js.map +1 -0
- package/dist/unstable/features/Keys.d.ts +95 -0
- package/dist/unstable/features/Keys.d.ts.map +1 -0
- package/dist/unstable/features/Keys.js +44 -0
- package/dist/unstable/features/Keys.js.map +1 -0
- package/dist/unstable/features/Layout.d.ts +43 -0
- package/dist/unstable/features/Layout.d.ts.map +1 -0
- package/dist/unstable/features/Layout.js +44 -0
- package/dist/unstable/features/Layout.js.map +1 -0
- package/dist/unstable/features/Pan.d.ts +5 -0
- package/dist/unstable/features/Pan.d.ts.map +1 -0
- package/dist/unstable/features/Pan.js +20 -0
- package/dist/unstable/features/Pan.js.map +1 -0
- package/dist/unstable/features/Press.d.ts +13 -0
- package/dist/unstable/features/Press.d.ts.map +1 -0
- package/dist/unstable/features/Press.js +10 -0
- package/dist/unstable/features/Press.js.map +1 -0
- package/dist/unstable/features/Scroll.d.ts +20 -0
- package/dist/unstable/features/Scroll.d.ts.map +1 -0
- package/dist/unstable/features/Scroll.js +34 -0
- package/dist/unstable/features/Scroll.js.map +1 -0
- package/dist/unstable/features/TimelineKeys.d.ts +7 -0
- package/dist/unstable/features/TimelineKeys.d.ts.map +1 -0
- package/dist/unstable/features/TimelineKeys.js +103 -0
- package/dist/unstable/features/TimelineKeys.js.map +1 -0
- package/package.json +4 -3
- package/src/Appear.ts +4 -2
- package/src/DomProjectionSystem.ts +3 -3
- package/src/FlushGate.ts +15 -12
- package/src/ReorderController.ts +3 -3
- package/src/Report.ts +3 -7
- package/src/Style.ts +4 -1
- package/src/TimelineValue.ts +19 -0
- package/src/index.ts +15 -5
- package/src/internal/appear.ts +20 -8
- package/src/internal/batch-handoff.ts +75 -0
- package/src/internal/drag-defaults.ts +4 -4
- package/src/internal/gate-environment.ts +21 -0
- package/src/internal/projection.ts +22 -21
- package/src/internal/renderer.ts +22 -0
- package/src/internal/reorder.ts +4 -4
- package/src/internal/scroll.ts +32 -15
- package/src/internal/starting-style.ts +5 -204
- package/src/internal/timeline.ts +480 -0
- package/src/unstable/AppearAnimations.ts +837 -0
- package/src/unstable/BatchMembers.ts +3085 -0
- package/src/unstable/DomValues.ts +53 -0
- package/src/unstable/DragConstraints.ts +107 -0
- package/src/unstable/DragControls.ts +98 -0
- package/src/unstable/DragDefaults.ts +57 -0
- package/src/unstable/DragTrack.ts +959 -0
- package/src/unstable/DragTransition.ts +46 -0
- package/src/unstable/ElementSetup.ts +411 -0
- package/src/unstable/Feature.ts +494 -0
- package/src/unstable/GestureFeatures.ts +38 -0
- package/src/unstable/GestureInfo.ts +85 -0
- package/src/unstable/Imperative.ts +1037 -0
- package/src/unstable/Instant.ts +93 -0
- package/src/unstable/LayoutGroup.ts +36 -0
- package/src/unstable/LayoutMember.ts +319 -0
- package/src/unstable/LiveStyle.ts +497 -0
- package/src/unstable/MemberHold.ts +211 -0
- package/src/unstable/OwnerScope.ts +35 -0
- package/src/unstable/PresenceController.ts +1747 -0
- package/src/unstable/Press.ts +43 -0
- package/src/unstable/ServerInterpolators.ts +39 -0
- package/src/unstable/WardConfig.ts +704 -0
- package/src/unstable/features/All.ts +39 -0
- package/src/unstable/features/Colors.ts +40 -0
- package/src/unstable/features/DomAnimation.ts +19 -0
- package/src/unstable/features/DomMax.ts +14 -0
- package/src/unstable/features/Drag.ts +34 -0
- package/src/unstable/features/Focus.ts +21 -0
- package/src/unstable/features/Hover.ts +21 -0
- package/src/unstable/features/InView.ts +21 -0
- package/src/unstable/features/Input.ts +37 -0
- package/src/unstable/features/Keys.ts +124 -0
- package/src/unstable/features/Layout.ts +75 -0
- package/src/unstable/features/Pan.ts +21 -0
- package/src/unstable/features/Press.ts +21 -0
- package/src/unstable/features/Scroll.ts +35 -0
- package/src/unstable/features/TimelineKeys.ts +115 -0
- package/dist/internal/gate.d.ts +0 -188
- package/dist/internal/gate.d.ts.map +0 -1
- package/dist/internal/gate.js +0 -458
- package/dist/internal/gate.js.map +0 -1
- package/dist/internal/report.d.ts +0 -30
- package/dist/internal/report.d.ts.map +0 -1
- package/dist/internal/report.js +0 -60
- package/dist/internal/report.js.map +0 -1
- package/dist/internal/runner.d.ts +0 -21
- package/dist/internal/runner.d.ts.map +0 -1
- package/dist/internal/runner.js +0 -48
- package/dist/internal/runner.js.map +0 -1
- package/src/internal/gate.ts +0 -598
- package/src/internal/report.ts +0 -69
- package/src/internal/runner.ts +0 -64
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The **Instant change** and the **Projection reset** (#443, Motion's `useInstantLayoutTransition`,
|
|
3
|
+
* `useInstantTransition` and `useResetProjection`), scoped to a provider's runtime: its projection
|
|
4
|
+
* system's `instant` and `reset`, and a flag its elements' animations read as they start.
|
|
5
|
+
*
|
|
6
|
+
* Every DOM binding runs it over its own provider's context value (#209).
|
|
7
|
+
*
|
|
8
|
+
* Unstable, for Wardic's own packages: public, with no semver promise.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
// Unstable: ADR-0071, decision 5. #672: solid's `instant.ts`, moved to dom for every DOM binding's provider.
|
|
13
|
+
import type * as ProjectionSystem from "../ProjectionSystem.ts"
|
|
14
|
+
import { constFalse, constVoid } from "effect/Function"
|
|
15
|
+
import * as Predicate from "effect/Predicate"
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Whether a provider's animations are instant now (#443, Motion's `instantAnimations`): while on,
|
|
19
|
+
* every animation that starts is a **Skipped animation** (#468). `start` turns it on, and it goes off
|
|
20
|
+
* two Refresh frames after the last `start`, as Motion's does; `end` turns it off at once (Motion's
|
|
21
|
+
* `disableInstantTransitions`).
|
|
22
|
+
*/
|
|
23
|
+
export interface InstantAnimations {
|
|
24
|
+
readonly active: () => boolean
|
|
25
|
+
readonly start: () => void
|
|
26
|
+
readonly end: () => void
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** A provider's {@link InstantAnimations}, timed by its Environment's Refresh frames, found at the first `start`. */
|
|
30
|
+
export const makeInstantAnimations = (requestFrame: () => (callback: () => void) => unknown): InstantAnimations => {
|
|
31
|
+
let on = false
|
|
32
|
+
// The calls so far: a call's turn-off is skipped once a later call has come.
|
|
33
|
+
let calls = 0
|
|
34
|
+
return {
|
|
35
|
+
active: () => on,
|
|
36
|
+
start: () => {
|
|
37
|
+
on = true
|
|
38
|
+
calls++
|
|
39
|
+
const call = calls
|
|
40
|
+
const request = requestFrame()
|
|
41
|
+
request(() =>
|
|
42
|
+
request(() => {
|
|
43
|
+
if (call === calls) on = false
|
|
44
|
+
}))
|
|
45
|
+
},
|
|
46
|
+
end: () => {
|
|
47
|
+
on = false
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** A server's: never on. */
|
|
53
|
+
export const NO_INSTANT: InstantAnimations = { active: constFalse, start: constVoid, end: constVoid }
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* `createInstantTransition()`'s start: `start(fn)` runs `fn`, and its layout change and every
|
|
57
|
+
* animation that starts until two frames after the call land at once. A later call extends it, and
|
|
58
|
+
* `start.end()` ends it now.
|
|
59
|
+
*/
|
|
60
|
+
// #443, Motion's `useInstantTransition`; `end` is its `disableInstantTransitions`.
|
|
61
|
+
export interface InstantTransition {
|
|
62
|
+
(fn: () => void): void
|
|
63
|
+
readonly end: () => void
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* An Instant change of the layout (#443): `fn` run, and the next Measure pass blocked. On a server,
|
|
68
|
+
* with no projection system, `fn` alone.
|
|
69
|
+
*/
|
|
70
|
+
export const instantLayoutOf =
|
|
71
|
+
(projection: () => ProjectionSystem.Shape | undefined) =>
|
|
72
|
+
(fn?: () => void): void => {
|
|
73
|
+
const system = projection()
|
|
74
|
+
if (Predicate.isNotUndefined(system)) return system.instant(fn)
|
|
75
|
+
if (Predicate.isNotUndefined(fn)) fn()
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** An Instant change of the layout and of the animations started meanwhile (#443): see {@link InstantTransition}. */
|
|
79
|
+
export const instantTransitionOf = (projection: () => ProjectionSystem.Shape | undefined, instant: () => InstantAnimations): InstantTransition =>
|
|
80
|
+
Object.assign(
|
|
81
|
+
(fn: () => void): void =>
|
|
82
|
+
instantLayoutOf(projection)(() => {
|
|
83
|
+
instant().start()
|
|
84
|
+
fn()
|
|
85
|
+
}),
|
|
86
|
+
{ end: () => instant().end() },
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
/** A Projection reset (#443): the projection system's `reset`; nothing on a server. */
|
|
90
|
+
export const resetOf = (projection: () => ProjectionSystem.Shape | undefined) => (): void => {
|
|
91
|
+
const system = projection()
|
|
92
|
+
if (Predicate.isNotUndefined(system)) system.reset()
|
|
93
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A **Layout group**'s namespace for `layoutId` (#432, CONTEXT.md; Motion's `LayoutGroup`,
|
|
3
|
+
* `.reference/motion` at `16c6122`), for every binding: its `<LayoutGroup>` makes its id, and every
|
|
4
|
+
* layout node's `layoutId` is put in it before it reaches the Projection system.
|
|
5
|
+
*
|
|
6
|
+
* Unstable, for Wardic's own packages: public, with no semver promise.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
// Unstable: ADR-0071, decision 5. #672: solid's `layout-group.ts`, moved to dom for every DOM binding's
|
|
11
|
+
// `LayoutGroup`.
|
|
12
|
+
import * as Predicate from "effect/Predicate"
|
|
13
|
+
import * as UndefinedOr from "effect/UndefinedOr"
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Whether a group joins the id of the group it's in (Motion's `inherit`): `true` and `"id"` both do
|
|
17
|
+
* (Motion's `true` also joins its node group, whose members are measured together, which Wardic's
|
|
18
|
+
* whole-tree Measure pass already does, ADR-0009); `false` starts a namespace of its own.
|
|
19
|
+
*/
|
|
20
|
+
export type LayoutGroupInherit = boolean | "id"
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A group's id (Motion's): with `inherit` and an outer group's id, that id joined with its own
|
|
24
|
+
* (`outer-inner`), or the outer one's alone when it has none; else its own, or none.
|
|
25
|
+
*/
|
|
26
|
+
export const layoutGroupIdOf = (outer: string | undefined, id: string | undefined, inherit: LayoutGroupInherit = true): string | undefined => {
|
|
27
|
+
if (inherit === false) return id
|
|
28
|
+
if (Predicate.isUndefined(outer)) return id
|
|
29
|
+
return UndefinedOr.match(id, { onUndefined: () => outer, onDefined: (own) => `${outer}-${own}` })
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** `layoutId` in the group `group` (Motion's `useLayoutId`): `${group}-${layoutId}`, or as it is outside any. */
|
|
33
|
+
export const layoutIdIn = (group: string | undefined, layoutId: string | undefined): string | undefined => {
|
|
34
|
+
if (Predicate.isUndefined(group)) return layoutId
|
|
35
|
+
return UndefinedOr.map(layoutId, (own) => `${group}-${own}`)
|
|
36
|
+
}
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A layout node's registration (ADR-0009, ADR-0010), for every DOM binding: its layout transition, and
|
|
3
|
+
* what each binding's `createProjectionNode` hands the provider's projection system. The binding adds
|
|
4
|
+
* its own lifetime: the node's disposal, and a `layoutDependency` change's Measure pass.
|
|
5
|
+
*
|
|
6
|
+
* Unstable, for Wardic's own packages: public, with no semver promise.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
// Unstable: ADR-0071, decision 5. #672: solid's `layout-member.ts`, moved to dom for every DOM binding's
|
|
11
|
+
// layout nodes.
|
|
12
|
+
import type * as Box from "@wardic/core/Box"
|
|
13
|
+
import type * as Point from "@wardic/core/Point"
|
|
14
|
+
import type * as Projection from "@wardic/core/Projection"
|
|
15
|
+
import * as ProjectionSystem from "../ProjectionSystem.ts"
|
|
16
|
+
import * as Bool from "effect/Boolean"
|
|
17
|
+
import { constFalse, constTrue, identity } from "effect/Function"
|
|
18
|
+
import * as Option from "effect/Option"
|
|
19
|
+
import * as Predicate from "effect/Predicate"
|
|
20
|
+
import * as UndefinedOr from "effect/UndefinedOr"
|
|
21
|
+
import * as BatchMembers from "./BatchMembers.ts"
|
|
22
|
+
import type * as Values from "@wardic/core/Values"
|
|
23
|
+
import * as DomRenderer from "../DomRenderer.ts"
|
|
24
|
+
import type * as WardConfig from "./WardConfig.ts"
|
|
25
|
+
import * as LayoutGroup from "./LayoutGroup.ts"
|
|
26
|
+
import type * as PresenceRecord from "@wardic/core/unstable/PresenceRecord"
|
|
27
|
+
import * as RetargetLegs from "@wardic/core/unstable/RetargetLegs"
|
|
28
|
+
import * as VariantTree from "@wardic/core/unstable/VariantTree"
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* One transition as a layout animation's (ADR-0009 *Amendment (#171)*, ADR-0051): as it runs, a value's
|
|
32
|
+
* rule (a spring when it says so or gives a spring field, else a tween, Motion's fields filled in), so
|
|
33
|
+
* a ported `{ duration: 0.5 }` is a 0.5 s tween. One that defines none, a `delay` alone say, is
|
|
34
|
+
* Motion's default layout tween with its delay: it never turns a layout animation into a spring. An
|
|
35
|
+
* inertia (#435) is that tween too: a layout animation's progress has no velocity to glide on.
|
|
36
|
+
*/
|
|
37
|
+
const asLayoutTransition = (t: WardConfig.WardicTransition): ProjectionSystem.LayoutTransition =>
|
|
38
|
+
UndefinedOr.match(RetargetLegs.runOf(t), {
|
|
39
|
+
// A layout tween takes one `ease`: a list of them (#429) is a Keyframes tween's, which core's layout tween rejects.
|
|
40
|
+
onDefined: (run): ProjectionSystem.LayoutTransition =>
|
|
41
|
+
Bool.match(run.type === "inertia", { onTrue: () => defaultLayoutAfter(t.delay), onFalse: () => run as ProjectionSystem.LayoutTransition }),
|
|
42
|
+
onUndefined: () => defaultLayoutAfter(t.delay),
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
/** Motion's default layout tween, after `delay` when given. */
|
|
46
|
+
const defaultLayoutAfter = (delay: number | undefined): ProjectionSystem.LayoutTransition =>
|
|
47
|
+
UndefinedOr.match(delay, { onUndefined: () => ProjectionSystem.DEFAULT_LAYOUT_TRANSITION, onDefined: (after): ProjectionSystem.LayoutTransition => ({ ...ProjectionSystem.DEFAULT_LAYOUT_TRANSITION, delay: after }) })
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The element's layout transition (ADR-0009 *Amendment (#171)*, *Amendment (#301)*): Motion's
|
|
51
|
+
* `layout` entry, else its `default`, else its whole `transition`; `undefined`, with none, for the
|
|
52
|
+
* engine's default, Motion's 0.45 s tween.
|
|
53
|
+
*/
|
|
54
|
+
const toLayoutTransition = (t: WardConfig.WardicTransition | undefined): Option.Option<ProjectionSystem.LayoutTransition> =>
|
|
55
|
+
Option.map(Option.fromUndefinedOr(RetargetLegs.transitionForKey(t, "layout")), asLayoutTransition)
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* `createProjectionNode`'s options: the element, its id, and what its motion props would give a `w.*`
|
|
59
|
+
* element's layout node. Each function is read when the projection needs it, outside its binding's tracking.
|
|
60
|
+
*/
|
|
61
|
+
export interface CreateProjectionNodeOptions {
|
|
62
|
+
/** The element's id in the provider's gate, the entry its values are written under. */
|
|
63
|
+
// The spine's entry: the projection's `@projection` writes merge there.
|
|
64
|
+
readonly id: string
|
|
65
|
+
/** The element to measure and animate. */
|
|
66
|
+
readonly element: HTMLElement
|
|
67
|
+
/** Its `layoutDependency`: a change has it measured again. */
|
|
68
|
+
readonly layoutDependency: () => unknown
|
|
69
|
+
/** Its `transition`: the `layout` entry, else the whole transition, runs its layout animations. */
|
|
70
|
+
// ADR-0009 *Amendment (#171)*.
|
|
71
|
+
readonly transition: () => WardConfig.WardicTransition | undefined
|
|
72
|
+
/** Its `dragTransition`, resolved: what it carries on with after a drag is let go. */
|
|
73
|
+
// ADR-0016, *Amendment (#140)*: what its Release offset runs on.
|
|
74
|
+
readonly dragTransition?: () => ProjectionSystem.DragTransition
|
|
75
|
+
/** Whether reduced motion applies to it now: its nearest `WardicConfig`'s, else the provider's. Default: the system's. */
|
|
76
|
+
// ADR-0029, #434.
|
|
77
|
+
readonly reducedMotion?: () => boolean
|
|
78
|
+
/** Whether its animations land at once now: its nearest `WardicConfig`'s `skipAnimations`. Default: never. */
|
|
79
|
+
// #468.
|
|
80
|
+
readonly skipAnimations?: () => boolean
|
|
81
|
+
/** Its `layoutId`: an element with the same one, mounting as it leaves, flies from it. Left out, it's a plain `layout` element. */
|
|
82
|
+
// ADR-0010: the one node joins the engine's per-`layoutId` lead/follow stack (coexisting twins
|
|
83
|
+
// crossfade) and takes a Switch seed from a twin disposed in the same task, both engine-side
|
|
84
|
+
// (*Amendment (#13)*).
|
|
85
|
+
readonly layoutId?: string
|
|
86
|
+
/** Its `layoutScroll`: it scrolls, and its scroll isn't read as its children moving. */
|
|
87
|
+
// ADR-0012: its scroll offset is sampled at measure and folded out of its descendants' boxes, so a
|
|
88
|
+
// scroll between triggers doesn't leak into their FLIP delta.
|
|
89
|
+
readonly layoutScroll?: boolean
|
|
90
|
+
/**
|
|
91
|
+
* Its `layoutRoot`: a root for the layout animations inside it, which never animates its own. With a
|
|
92
|
+
* `layoutMode` other than `false` it stays at its new place while an ancestor's layout animation runs;
|
|
93
|
+
* with `false` it moves with it, as a `w.*` element's with no `layout` or `layoutId` does.
|
|
94
|
+
*/
|
|
95
|
+
// ADR-0013: a stable projection sub-root, self-snap, boundary and persistent relative anchor.
|
|
96
|
+
readonly layoutRoot?: boolean
|
|
97
|
+
/** Its `layoutAnchor`: where in its parent's box it anchors, 0 to 1 per axis, or `false` to measure it against the page. */
|
|
98
|
+
// ADR-0013: its relative-projection anchor; `false` forces absolute.
|
|
99
|
+
readonly layoutAnchor?: Point.Point | false
|
|
100
|
+
/** Its `layoutCrossfade`: whether a `layoutId` handover onto it crossfades, read as each begins. Default: always. */
|
|
101
|
+
// #442.
|
|
102
|
+
readonly crossfade?: () => boolean
|
|
103
|
+
/** Raises it above its siblings while it's dragged, as a `<Reorder>` item is. */
|
|
104
|
+
// ADR-0016 *Amendment (Reorder)*.
|
|
105
|
+
readonly raiseWhileDragged?: boolean
|
|
106
|
+
/**
|
|
107
|
+
* Its `layout` value: which part of a change it animates, read as each layout animation starts. `false`
|
|
108
|
+
* for one with no layout of its own, as a `w.*` element's with `layoutRoot` or `layoutScroll` and no
|
|
109
|
+
* `layout` or `layoutId`. Default `true`.
|
|
110
|
+
*/
|
|
111
|
+
// ADR-0009, *Amendments (#42, #691)*: its Layout mode.
|
|
112
|
+
readonly layoutMode?: () => Projection.LayoutMode
|
|
113
|
+
/** Its own `scale`, read at each handover and each frame it follows another element. */
|
|
114
|
+
// ADR-0010 *Amendment (#8)*.
|
|
115
|
+
readonly ownScale?: () => Point.Point
|
|
116
|
+
/** Its own `x` and `y`, in page pixels, read where its own scale is. */
|
|
117
|
+
// #363.
|
|
118
|
+
readonly ownTranslate?: () => Point.Point
|
|
119
|
+
/** Its own `rotate` and `opacity`, which a `layoutId` handover blends into. */
|
|
120
|
+
// ADR-0010 *Amendment (#166)*.
|
|
121
|
+
readonly ownRotate?: () => number
|
|
122
|
+
readonly ownOpacity?: () => number
|
|
123
|
+
/** The `transform` it's held at while it's measured: its `transformTemplate`'s. Left out without one. */
|
|
124
|
+
// #443.
|
|
125
|
+
readonly heldTransform?: () => string
|
|
126
|
+
/** Its `onBeforeLayoutMeasure` and `onLayoutMeasure`. Left out when it has none at mount. */
|
|
127
|
+
// #443.
|
|
128
|
+
readonly onBeforeMeasure?: () => void
|
|
129
|
+
readonly onMeasure?: (box: Box.Box, prev: Box.Box | undefined) => void
|
|
130
|
+
/** Its `onLayoutAnimationStart` and `onLayoutAnimationComplete`, read when they're called. */
|
|
131
|
+
// #191, ADR-0039.
|
|
132
|
+
readonly onLayoutAnimationStart?: () => (() => void) | undefined
|
|
133
|
+
readonly onLayoutAnimationComplete?: () => (() => void) | undefined
|
|
134
|
+
/** Its `onDragTransitionEnd`, read when it's called: once it comes to rest after a drag. */
|
|
135
|
+
// #273: a drag's Release offset at rest.
|
|
136
|
+
readonly onReleaseEnd?: () => (() => void) | undefined
|
|
137
|
+
/** Where its first layout animation starts, when it takes over from a leaving element with its `key`: that element's box. */
|
|
138
|
+
// #286: a presence take-over, its leaver's box in the Root frame.
|
|
139
|
+
readonly enteredFrom?: Box.Box
|
|
140
|
+
/** Where its handover's fade starts, when it takes over from a leaving twin with its `key`: how far that one had faded. */
|
|
141
|
+
// #286.
|
|
142
|
+
readonly fadeFrom?: number
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Whether a layout transition skips its animation (#468): its `layout` entry's, else its own `skipAnimations`. */
|
|
146
|
+
const layoutSkips = (transition: WardConfig.WardicTransition | undefined): boolean =>
|
|
147
|
+
UndefinedOr.match(RetargetLegs.transitionForKey(transition, "layout"), { onUndefined: constFalse, onDefined: (t) => t.skipAnimations === true })
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* A layout node's registration with the projection system (ADR-0009, ADR-0010): exactly one node per
|
|
151
|
+
* element, whether it has `layout`, `layoutId`, or both. Each getter is read where the projection
|
|
152
|
+
* system needs it, outside the binding's tracking.
|
|
153
|
+
*/
|
|
154
|
+
export const registrationOf = (opts: CreateProjectionNodeOptions): ProjectionSystem.RegisterNodeOptions => {
|
|
155
|
+
// A Batch member's element has no layout node (#665's PR 4, Q52): the projection measures its box under
|
|
156
|
+
// the Batch's transform, which it doesn't draw. Marked, so a Batch it joins later says so too.
|
|
157
|
+
BatchMembers.markLayoutElement(opts.element)
|
|
158
|
+
const { crossfade, dragTransition, element, enteredFrom, fadeFrom, id, layoutAnchor, layoutId, layoutMode, layoutRoot, layoutScroll, heldTransform, onBeforeMeasure, onMeasure, onLayoutAnimationComplete, onLayoutAnimationStart, onReleaseEnd, ownOpacity, ownRotate, ownScale, ownTranslate, raiseWhileDragged, reducedMotion, skipAnimations, transition } = opts
|
|
159
|
+
const configSkips = UndefinedOr.match(skipAnimations, { onUndefined: () => constFalse, onDefined: identity })
|
|
160
|
+
return {
|
|
161
|
+
id,
|
|
162
|
+
element,
|
|
163
|
+
transition: () => toLayoutTransition(transition()),
|
|
164
|
+
// Its layout transition's Path (#438, ADR-0065), Motion's: the `layout` entry's, else the element's.
|
|
165
|
+
// A layout animation of 20 px or more curves along it.
|
|
166
|
+
path: () => Option.fromUndefinedOr(UndefinedOr.map(RetargetLegs.transitionForKey(transition(), "layout"), (t) => t.path)),
|
|
167
|
+
// The layout transition's reduced-motion opt-out (ADR-0029, #301), read at each layout animation's start.
|
|
168
|
+
respectReducedMotion: () =>
|
|
169
|
+
UndefinedOr.match(RetargetLegs.transitionForKey(transition(), "layout"), { onUndefined: constTrue, onDefined: (t) => t.respectReducedMotion !== false }),
|
|
170
|
+
// Whether reduced motion applies to it (#434): its subtree's, else the system's.
|
|
171
|
+
...UndefinedOr.match(reducedMotion, { onUndefined: () => ({}), onDefined: (applies) => ({ reducedMotion: applies }) }),
|
|
172
|
+
// Whether its layout animations are skipped (#468): its subtree's, or its layout transition's own
|
|
173
|
+
// `skipAnimations`, as Motion's projection runs on its layout transition. Read at each start.
|
|
174
|
+
skipAnimations: () => Bool.or(configSkips(), layoutSkips(transition())),
|
|
175
|
+
...UndefinedOr.match(layoutId, { onUndefined: () => ({}), onDefined: (twinId) => ({ layoutId: twinId }) }),
|
|
176
|
+
...Bool.match(layoutScroll === true, { onTrue: () => ({ layoutScroll: true }), onFalse: () => ({}) }),
|
|
177
|
+
...Bool.match(layoutRoot === true, { onTrue: () => ({ layoutRoot: true }), onFalse: () => ({}) }),
|
|
178
|
+
...UndefinedOr.match(layoutAnchor, { onUndefined: () => ({}), onDefined: (anchor) => ({ layoutAnchor: anchor }) }),
|
|
179
|
+
...UndefinedOr.match(crossfade, { onUndefined: () => ({}), onDefined: (fades) => ({ crossfade: fades }) }),
|
|
180
|
+
...Bool.match(raiseWhileDragged === true, { onTrue: () => ({ raiseWhileDragged: true }), onFalse: () => ({}) }),
|
|
181
|
+
...UndefinedOr.match(dragTransition, { onUndefined: () => ({}), onDefined: (release) => ({ dragTransition: () => Option.some(release()) }) }),
|
|
182
|
+
...UndefinedOr.match(layoutMode, { onUndefined: () => ({}), onDefined: (mode) => ({ layoutMode: mode }) }),
|
|
183
|
+
...UndefinedOr.match(ownScale, { onUndefined: () => ({}), onDefined: (scale) => ({ ownScale: scale }) }),
|
|
184
|
+
...UndefinedOr.match(ownTranslate, { onUndefined: () => ({}), onDefined: (translate) => ({ ownTranslate: translate }) }),
|
|
185
|
+
...UndefinedOr.match(ownRotate, { onUndefined: () => ({}), onDefined: (rotate) => ({ ownRotate: rotate }) }),
|
|
186
|
+
...UndefinedOr.match(ownOpacity, { onUndefined: () => ({}), onDefined: (opacity) => ({ ownOpacity: opacity }) }),
|
|
187
|
+
...UndefinedOr.match(heldTransform, { onUndefined: () => ({}), onDefined: (held) => ({ heldTransform: held }) }),
|
|
188
|
+
...UndefinedOr.match(onBeforeMeasure, { onUndefined: () => ({}), onDefined: (before) => ({ onBeforeMeasure: before }) }),
|
|
189
|
+
// The engine's `prev` is an `Option` (#618, A1); this option keeps Motion's `undefined` at the first.
|
|
190
|
+
...UndefinedOr.match(onMeasure, { onUndefined: () => ({}), onDefined: (measured) => ({ onMeasure: (box: Box.Box, prev: Option.Option<Box.Box>) => measured(box, Option.getOrUndefined(prev)) }) }),
|
|
191
|
+
...UndefinedOr.match(onLayoutAnimationStart, {
|
|
192
|
+
onUndefined: () => ({}),
|
|
193
|
+
onDefined: (start) => ({ onLayoutAnimationStart: () => Option.fromUndefinedOr(start()) }),
|
|
194
|
+
}),
|
|
195
|
+
...UndefinedOr.match(onLayoutAnimationComplete, {
|
|
196
|
+
onUndefined: () => ({}),
|
|
197
|
+
onDefined: (complete) => ({ onLayoutAnimationComplete: () => Option.fromUndefinedOr(complete()) }),
|
|
198
|
+
}),
|
|
199
|
+
...UndefinedOr.match(onReleaseEnd, {
|
|
200
|
+
onUndefined: () => ({}),
|
|
201
|
+
onDefined: (ended) => ({ onReleaseEnd: () => Option.fromUndefinedOr(ended()) }),
|
|
202
|
+
}),
|
|
203
|
+
...takeOverOf(enteredFrom, fadeFrom),
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** No options: what most registrations add for a take-over (#286). */
|
|
208
|
+
const NONE = {}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* A take-over's layout start (#286): the leaver's box and fade, each when it has one. Guards, not a
|
|
212
|
+
* match per option: every layout node registers through here.
|
|
213
|
+
*/
|
|
214
|
+
const takeOverOf = (box: Box.Box | undefined, fade: number | undefined): Pick<ProjectionSystem.RegisterNodeOptions, "enteredFrom" | "fadeFrom"> => {
|
|
215
|
+
if (Bool.and(Predicate.isUndefined(box), Predicate.isUndefined(fade))) return NONE
|
|
216
|
+
return { ...UndefinedOr.match(box, { onUndefined: () => NONE, onDefined: (from) => ({ enteredFrom: from }) }), ...UndefinedOr.match(fade, { onUndefined: () => NONE, onDefined: (from) => ({ fadeFrom: from }) }) }
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* The Layout mode a config gives its node (ADR-0009, *Amendment (#42)*): the mode its `layout` names,
|
|
221
|
+
* `true` for `layout` or a `layoutId`, and `false` for a node only a `layoutScroll` or a `layoutRoot` gives,
|
|
222
|
+
* which animates no layout of its own and rides its ancestors', as Motion's (#691). Statement `if`s:
|
|
223
|
+
* read each frame for a Follower.
|
|
224
|
+
*/
|
|
225
|
+
export const layoutModeOf = (layout: WardConfig.WardConfig["layout"], layoutId: string | undefined): Projection.LayoutMode => {
|
|
226
|
+
if (isModeName(layout)) return layout
|
|
227
|
+
if (layout === true) return true
|
|
228
|
+
return Predicate.isNotUndefined(layoutId)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** Whether a `layout` prop names a Layout mode (a string), not `true` / `false`. */
|
|
232
|
+
const isModeName = (layout: WardConfig.WardConfig["layout"]): layout is Exclude<WardConfig.WardConfig["layout"], boolean | undefined> => Predicate.isString(layout)
|
|
233
|
+
|
|
234
|
+
/** What {@link layoutOptionsOf} reads of a ward. */
|
|
235
|
+
export interface WardLayout {
|
|
236
|
+
readonly id: string
|
|
237
|
+
readonly element: HTMLElement
|
|
238
|
+
/** The ward's config: its static layout props read once, here; the rest read where they're used. */
|
|
239
|
+
readonly config: () => WardConfig.WardConfig
|
|
240
|
+
/** The variant context the ward inherits its default transition from. */
|
|
241
|
+
readonly parent: VariantTree.WardicVariantContextValue | undefined
|
|
242
|
+
/** The ward's Snapshot: its own scale, rotate and opacity, as the renderer draws them. */
|
|
243
|
+
readonly snapshot: { readonly values: Values.Values }
|
|
244
|
+
/** What a release runs on: the node's Release offset (ADR-0016, *Amendment (#140)*). */
|
|
245
|
+
readonly dragTransition: ProjectionSystem.DragTransition
|
|
246
|
+
/** Raise the node while it's dragged: a `<Reorder>` item's. */
|
|
247
|
+
readonly raiseWhileDragged: boolean
|
|
248
|
+
/** Where its child's take-over of a leaver starts it (#286): its box and fade, when it has one. */
|
|
249
|
+
readonly taken?: PresenceRecord.PresenceSeed | undefined
|
|
250
|
+
/** The id of the **Layout group** the ward was made in (#432), whose namespace its `layoutId` goes in. */
|
|
251
|
+
readonly layoutGroup?: string | undefined
|
|
252
|
+
/** Whether reduced motion applies to it now (ADR-0029): its nearest `WardicConfig`'s, else the provider's (#434). */
|
|
253
|
+
readonly reducedMotion?: (() => boolean) | undefined
|
|
254
|
+
/** Whether its animations are skipped now (#468): its nearest `WardicConfig`'s. */
|
|
255
|
+
readonly skipAnimations?: (() => boolean) | undefined
|
|
256
|
+
/** What a Measure pass holds its transform at (#443): its Transform template's, when it had one at mount. */
|
|
257
|
+
readonly heldTransform?: (() => string) | undefined
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* A ward's layout node options, from its config: `layoutId` (in its **Layout group**'s namespace,
|
|
262
|
+
* #432), `layoutScroll`, `layoutRoot` and `layoutAnchor` read once, at mount; its transition, Layout
|
|
263
|
+
* mode and callbacks read when the projection system needs them.
|
|
264
|
+
*/
|
|
265
|
+
export const layoutOptionsOf = (ward: WardLayout): CreateProjectionNodeOptions => {
|
|
266
|
+
const { config, element, id, parent, snapshot, dragTransition, raiseWhileDragged, taken, layoutGroup, reducedMotion, skipAnimations, heldTransform } = ward
|
|
267
|
+
const c0 = config()
|
|
268
|
+
return {
|
|
269
|
+
id,
|
|
270
|
+
element,
|
|
271
|
+
layoutDependency: () => config().layoutDependency,
|
|
272
|
+
transition: () => VariantTree.ownOrInherited(config().transition, parent),
|
|
273
|
+
dragTransition: () => dragTransition,
|
|
274
|
+
// The Layout mode, read at each layout animation's start, at each Measure pass for a layoutRoot
|
|
275
|
+
// until it isolates, and each frame for a Follower (ADR-0009, *Amendments (#42, #691)*); its
|
|
276
|
+
// `layoutId` is the one read at mount.
|
|
277
|
+
layoutMode: () => layoutModeOf(config().layout, c0.layoutId),
|
|
278
|
+
// The own scale the renderer draws, from the values last written (ADR-0010 *Amendment (#8)*).
|
|
279
|
+
ownScale: () => DomRenderer.ownScaleOf(snapshot.values),
|
|
280
|
+
// And its own translate, which the renderer adds to its projection's (#363).
|
|
281
|
+
ownTranslate: () => DomRenderer.ownTranslateOf(snapshot.values),
|
|
282
|
+
// And its own rotate and opacity, which a handover blends into (ADR-0010 *Amendment (#166)*).
|
|
283
|
+
ownRotate: () => DomRenderer.ownRotateOf(snapshot.values),
|
|
284
|
+
ownOpacity: () => DomRenderer.ownOpacityOf(snapshot.values),
|
|
285
|
+
// The app's layout animation callbacks, read when they fire (#191, ADR-0039).
|
|
286
|
+
onLayoutAnimationStart: () => config().onLayoutAnimationStart,
|
|
287
|
+
onLayoutAnimationComplete: () => config().onLayoutAnimationComplete,
|
|
288
|
+
// The app's `onDragTransitionEnd` (#273): its Release offset at rest.
|
|
289
|
+
onReleaseEnd: () => config().onDragTransitionEnd,
|
|
290
|
+
// Whether a handover onto it crossfades (#442, Motion's `layoutCrossfade`), read as each begins.
|
|
291
|
+
crossfade: () => config().layoutCrossfade !== false,
|
|
292
|
+
...UndefinedOr.match(LayoutGroup.layoutIdIn(layoutGroup, c0.layoutId), { onUndefined: () => ({}), onDefined: (twinId) => ({ layoutId: twinId }) }),
|
|
293
|
+
...Bool.match(c0.layoutScroll === true, { onTrue: () => ({ layoutScroll: true }), onFalse: () => ({}) }),
|
|
294
|
+
...Bool.match(c0.layoutRoot === true, { onTrue: () => ({ layoutRoot: true }), onFalse: () => ({}) }),
|
|
295
|
+
...UndefinedOr.match(c0.layoutAnchor, { onUndefined: () => ({}), onDefined: (anchor) => ({ layoutAnchor: anchor }) }),
|
|
296
|
+
...Bool.match(raiseWhileDragged, { onTrue: () => ({ raiseWhileDragged: true }), onFalse: () => ({}) }),
|
|
297
|
+
...takenOptionsOf(taken),
|
|
298
|
+
...UndefinedOr.match(reducedMotion, { onUndefined: () => ({}), onDefined: (applies) => ({ reducedMotion: applies }) }),
|
|
299
|
+
...UndefinedOr.match(skipAnimations, { onUndefined: () => ({}), onDefined: (skips) => ({ skipAnimations: skips }) }),
|
|
300
|
+
// Its Transform template's hold for a Measure pass (#443): a node without one is cleared.
|
|
301
|
+
...UndefinedOr.match(heldTransform, { onUndefined: () => ({}), onDefined: (held) => ({ heldTransform: held }) }),
|
|
302
|
+
// The app's layout measure callbacks (#443), read when each is called: a node whose config had
|
|
303
|
+
// none at mount is given none, and pays nothing a pass.
|
|
304
|
+
...Bool.match(Predicate.isNotUndefined(c0.onBeforeLayoutMeasure), {
|
|
305
|
+
onTrue: () => ({ onBeforeMeasure: () => UndefinedOr.map(config().onBeforeLayoutMeasure, (before) => before()) }),
|
|
306
|
+
onFalse: () => ({}),
|
|
307
|
+
}),
|
|
308
|
+
...Bool.match(Predicate.isNotUndefined(c0.onLayoutMeasure), {
|
|
309
|
+
onTrue: () => ({ onMeasure: (box: Box.Box, prev: Box.Box | undefined) => UndefinedOr.map(config().onLayoutMeasure, (measured) => measured(box, prev)) }),
|
|
310
|
+
onFalse: () => ({}),
|
|
311
|
+
}),
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** A take-over's layout start (#286), when its child took over from a leaver: its box and fade. */
|
|
316
|
+
const takenOptionsOf = (taken: PresenceRecord.PresenceSeed | undefined): Pick<CreateProjectionNodeOptions, "enteredFrom" | "fadeFrom"> => {
|
|
317
|
+
if (Predicate.isUndefined(taken)) return NONE
|
|
318
|
+
return takeOverOf(taken.box, taken.fade)
|
|
319
|
+
}
|