@wardic/core 1.3.1 → 1.4.0
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/Arc.d.ts +2 -2
- package/dist/Arc.js +1 -1
- package/dist/BaseValue.d.ts +11 -10
- package/dist/BaseValue.d.ts.map +1 -1
- package/dist/BaseValue.js +12 -15
- package/dist/BaseValue.js.map +1 -1
- package/dist/Batch.d.ts +12 -6
- package/dist/Batch.d.ts.map +1 -1
- package/dist/Batch.js +374 -30
- package/dist/Batch.js.map +1 -1
- package/dist/Clock.d.ts +16 -0
- package/dist/Clock.d.ts.map +1 -1
- package/dist/Clock.js +22 -8
- package/dist/Clock.js.map +1 -1
- package/dist/DefaultTransition.d.ts +3 -2
- package/dist/DefaultTransition.d.ts.map +1 -1
- package/dist/DefaultTransition.js +5 -3
- package/dist/DefaultTransition.js.map +1 -1
- package/dist/Drag.d.ts +24 -9
- package/dist/Drag.d.ts.map +1 -1
- package/dist/Drag.js +10 -10
- package/dist/Drag.js.map +1 -1
- package/dist/DragActivity.js +3 -3
- package/dist/DragRecognizer.d.ts +14 -8
- package/dist/DragRecognizer.d.ts.map +1 -1
- package/dist/DragRecognizer.js +93 -34
- package/dist/DragRecognizer.js.map +1 -1
- package/dist/Easing.d.ts +1 -1
- package/dist/Easing.js +1 -1
- package/dist/Frame.d.ts.map +1 -1
- package/dist/Frame.js +5 -3
- package/dist/Frame.js.map +1 -1
- package/dist/InputFeed.d.ts +11 -8
- package/dist/InputFeed.d.ts.map +1 -1
- package/dist/InputFeed.js +18 -37
- package/dist/InputFeed.js.map +1 -1
- package/dist/InputSource.d.ts +3 -3
- package/dist/InputSource.js +2 -2
- package/dist/Interpolator.d.ts +2 -2
- package/dist/Interpolator.js +2 -2
- package/dist/InterpolatorRegistry.d.ts +29 -15
- package/dist/InterpolatorRegistry.d.ts.map +1 -1
- package/dist/InterpolatorRegistry.js +17 -8
- package/dist/InterpolatorRegistry.js.map +1 -1
- package/dist/LiveValue.d.ts +16 -9
- package/dist/LiveValue.d.ts.map +1 -1
- package/dist/LiveValue.js +204 -27
- package/dist/LiveValue.js.map +1 -1
- package/dist/Machine.d.ts +21 -8
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +184 -60
- package/dist/Machine.js.map +1 -1
- package/dist/Playback.d.ts.map +1 -1
- package/dist/Playback.js +16 -9
- package/dist/Playback.js.map +1 -1
- package/dist/Projection.d.ts +9 -9
- package/dist/Projection.js +2 -2
- package/dist/Recognizer.d.ts +2 -2
- package/dist/Recognizer.d.ts.map +1 -1
- package/dist/Recognizer.js +15 -10
- package/dist/Recognizer.js.map +1 -1
- package/dist/ReducedMotion.d.ts +4 -4
- package/dist/ReducedMotion.js +6 -6
- package/dist/Renderer.d.ts +5 -5
- package/dist/Renderer.js +6 -6
- package/dist/Renderer.js.map +1 -1
- package/dist/Reorder.d.ts +1 -1
- package/dist/Reorder.d.ts.map +1 -1
- package/dist/Reorder.js +2 -1
- package/dist/Reorder.js.map +1 -1
- package/dist/ScrollSource.d.ts +1 -1
- package/dist/ScrollSource.d.ts.map +1 -1
- package/dist/Sequence.d.ts +1 -1
- package/dist/SharedSource.d.ts +3 -3
- package/dist/SharedSource.js +5 -5
- package/dist/SharedSource.js.map +1 -1
- package/dist/Spring.d.ts.map +1 -1
- package/dist/Spring.js +2 -1
- package/dist/Spring.js.map +1 -1
- package/dist/Values.d.ts +2 -2
- package/dist/Values.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/carried.d.ts +13 -0
- package/dist/internal/carried.d.ts.map +1 -0
- package/dist/internal/carried.js +23 -0
- package/dist/internal/carried.js.map +1 -0
- package/dist/internal/firstSteps.d.ts +66 -0
- package/dist/internal/firstSteps.d.ts.map +1 -0
- package/dist/internal/firstSteps.js +107 -0
- package/dist/internal/firstSteps.js.map +1 -0
- package/dist/internal/frameLoop.d.ts +11 -3
- package/dist/internal/frameLoop.d.ts.map +1 -1
- package/dist/internal/frameLoop.js +190 -39
- package/dist/internal/frameLoop.js.map +1 -1
- package/dist/internal/guarded.d.ts +16 -0
- package/dist/internal/guarded.d.ts.map +1 -0
- package/dist/internal/guarded.js +68 -0
- package/dist/internal/guarded.js.map +1 -0
- package/dist/internal/lerpsNumbers.d.ts +11 -0
- package/dist/internal/lerpsNumbers.d.ts.map +1 -0
- package/dist/internal/lerpsNumbers.js +38 -0
- package/dist/internal/lerpsNumbers.js.map +1 -0
- package/dist/internal/options.d.ts +7 -7
- package/dist/internal/options.d.ts.map +1 -1
- package/dist/internal/options.js +10 -10
- package/dist/internal/options.js.map +1 -1
- package/dist/internal/stepper.d.ts +21 -4
- package/dist/internal/stepper.d.ts.map +1 -1
- package/dist/internal/stepper.js +21 -5
- package/dist/internal/stepper.js.map +1 -1
- package/dist/internal/tracing.d.ts +1 -1
- package/dist/internal/tracing.js +1 -1
- package/dist/unstable/AnimationControls.d.ts +45 -39
- package/dist/unstable/AnimationControls.d.ts.map +1 -1
- package/dist/unstable/AnimationControls.js +59 -35
- package/dist/unstable/AnimationControls.js.map +1 -1
- package/dist/unstable/AppearHandoff.d.ts +11 -5
- package/dist/unstable/AppearHandoff.d.ts.map +1 -1
- package/dist/unstable/AppearHandoff.js.map +1 -1
- package/dist/unstable/BatchCalls.d.ts +2 -2
- package/dist/unstable/BatchCalls.js +5 -5
- package/dist/unstable/Config.d.ts +21 -17
- package/dist/unstable/Config.d.ts.map +1 -1
- package/dist/unstable/Config.js.map +1 -1
- package/dist/unstable/FirstSteps.d.ts +25 -0
- package/dist/unstable/FirstSteps.d.ts.map +1 -0
- package/dist/unstable/FirstSteps.js +2 -0
- package/dist/unstable/FirstSteps.js.map +1 -0
- package/dist/unstable/FlushGate.d.ts +54 -50
- package/dist/unstable/FlushGate.d.ts.map +1 -1
- package/dist/unstable/FlushGate.js +201 -77
- package/dist/unstable/FlushGate.js.map +1 -1
- package/dist/unstable/FrameEffects.d.ts +6 -3
- package/dist/unstable/FrameEffects.d.ts.map +1 -1
- package/dist/unstable/FrameEffects.js +14 -3
- package/dist/unstable/FrameEffects.js.map +1 -1
- package/dist/unstable/FrameTime.d.ts +1 -1
- package/dist/unstable/FrameTime.js +1 -1
- package/dist/unstable/Imperative.d.ts +42 -13
- package/dist/unstable/Imperative.d.ts.map +1 -1
- package/dist/unstable/Imperative.js +279 -88
- package/dist/unstable/Imperative.js.map +1 -1
- package/dist/unstable/MeasuredPairs.d.ts +6 -2
- package/dist/unstable/MeasuredPairs.d.ts.map +1 -1
- package/dist/unstable/MeasuredPairs.js.map +1 -1
- package/dist/unstable/OwnValues.js +1 -1
- package/dist/unstable/PresenceRecord.d.ts +30 -26
- package/dist/unstable/PresenceRecord.d.ts.map +1 -1
- package/dist/unstable/PresenceRecord.js +8 -8
- package/dist/unstable/PresenceRecord.js.map +1 -1
- package/dist/unstable/Projector.d.ts +34 -0
- package/dist/unstable/Projector.d.ts.map +1 -0
- package/dist/unstable/Projector.js +9 -0
- package/dist/unstable/Projector.js.map +1 -0
- package/dist/unstable/Report.d.ts +8 -1
- package/dist/unstable/Report.d.ts.map +1 -1
- package/dist/unstable/Report.js +18 -2
- package/dist/unstable/Report.js.map +1 -1
- package/dist/unstable/RetargetLegs.d.ts +7 -1
- package/dist/unstable/RetargetLegs.d.ts.map +1 -1
- package/dist/unstable/RetargetLegs.js +24 -8
- package/dist/unstable/RetargetLegs.js.map +1 -1
- package/dist/unstable/Spine.d.ts +123 -68
- package/dist/unstable/Spine.d.ts.map +1 -1
- package/dist/unstable/Spine.js +319 -167
- package/dist/unstable/Spine.js.map +1 -1
- package/dist/unstable/Stops.d.ts +3 -3
- package/dist/unstable/Stops.js +4 -4
- package/dist/unstable/Subject.d.ts +2 -2
- package/dist/unstable/Subject.js +2 -2
- package/dist/unstable/Timelines.d.ts +11 -11
- package/dist/unstable/Timelines.d.ts.map +1 -1
- package/dist/unstable/Timelines.js +3 -3
- package/dist/unstable/VariantTarget.d.ts +32 -10
- package/dist/unstable/VariantTarget.d.ts.map +1 -1
- package/dist/unstable/VariantTarget.js +73 -20
- package/dist/unstable/VariantTarget.js.map +1 -1
- package/dist/unstable/VariantTree.d.ts +68 -34
- package/dist/unstable/VariantTree.d.ts.map +1 -1
- package/dist/unstable/VariantTree.js +83 -36
- package/dist/unstable/VariantTree.js.map +1 -1
- package/dist/unstable/WardicConfigValue.d.ts +13 -13
- package/dist/unstable/WardicConfigValue.d.ts.map +1 -1
- package/dist/unstable/WardicConfigValue.js +4 -4
- package/dist/unstable/WardicConfigValue.js.map +1 -1
- package/package.json +1 -1
- package/src/Arc.ts +3 -3
- package/src/BaseValue.ts +18 -21
- package/src/Batch.ts +391 -27
- package/src/Clock.ts +29 -8
- package/src/DefaultTransition.ts +5 -3
- package/src/Drag.ts +32 -14
- package/src/DragActivity.ts +3 -3
- package/src/DragRecognizer.ts +118 -41
- package/src/Easing.ts +1 -1
- package/src/Frame.ts +5 -3
- package/src/InputFeed.ts +39 -42
- package/src/InputSource.ts +5 -5
- package/src/Interpolator.ts +3 -3
- package/src/InterpolatorRegistry.ts +22 -13
- package/src/LiveValue.ts +186 -30
- package/src/Machine.ts +252 -81
- package/src/Playback.ts +15 -9
- package/src/Projection.ts +9 -9
- package/src/Recognizer.ts +16 -10
- package/src/ReducedMotion.ts +6 -6
- package/src/Renderer.ts +6 -6
- package/src/Reorder.ts +3 -2
- package/src/ScrollSource.ts +1 -1
- package/src/Sequence.ts +1 -1
- package/src/SharedSource.ts +5 -5
- package/src/Spring.ts +2 -1
- package/src/Values.ts +2 -2
- package/src/index.ts +1 -1
- package/src/internal/carried.ts +22 -0
- package/src/internal/firstSteps.ts +139 -0
- package/src/internal/frameLoop.ts +203 -41
- package/src/internal/guarded.ts +69 -0
- package/src/internal/lerpsNumbers.ts +53 -0
- package/src/internal/options.ts +10 -10
- package/src/internal/stepper.ts +33 -6
- package/src/internal/tracing.ts +1 -1
- package/src/unstable/AnimationControls.ts +88 -57
- package/src/unstable/AppearHandoff.ts +13 -6
- package/src/unstable/BatchCalls.ts +5 -5
- package/src/unstable/Config.ts +23 -17
- package/src/unstable/FirstSteps.ts +26 -0
- package/src/unstable/FlushGate.ts +250 -108
- package/src/unstable/FrameEffects.ts +17 -4
- package/src/unstable/FrameTime.ts +1 -1
- package/src/unstable/Imperative.ts +342 -101
- package/src/unstable/MeasuredPairs.ts +7 -1
- package/src/unstable/OwnValues.ts +1 -1
- package/src/unstable/PresenceRecord.ts +33 -29
- package/src/unstable/Projector.ts +45 -0
- package/src/unstable/Report.ts +20 -2
- package/src/unstable/RetargetLegs.ts +24 -9
- package/src/unstable/Spine.ts +399 -202
- package/src/unstable/Stops.ts +6 -6
- package/src/unstable/Subject.ts +2 -2
- package/src/unstable/Timelines.ts +12 -12
- package/src/unstable/VariantTarget.ts +102 -23
- package/src/unstable/VariantTree.ts +123 -42
- package/src/unstable/WardicConfigValue.ts +13 -13
package/src/Clock.ts
CHANGED
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
//
|
|
23
23
|
// Cold start (ADR-0017, ADR-0033): the subscription that starts an idle loop gets its first tick at the
|
|
24
24
|
// next Refresh frame, as a warm start does, with `dt = NOMINAL_DT`: `dt` stays nominal until two Refresh
|
|
25
|
-
// frame timestamps exist, then it is the measured interval. The flush gate
|
|
26
|
-
// the end of the Frame loop's tick, in that Refresh frame, so a Cold start's first step
|
|
27
|
-
// first Refresh frame. (Until #73 the gate
|
|
25
|
+
// frame timestamps exist, then it is the measured interval. The flush gate commits what a tick writes at
|
|
26
|
+
// the end of the Frame loop's tick, in that Refresh frame, so a Cold start's first step is drawn in the
|
|
27
|
+
// first Refresh frame. (Until #73 the gate's writes were drawn a frame later, and a Priming tick at the end of the
|
|
28
28
|
// subscribing task made up for it.) The loop never goes through the Effect scheduler: it starts
|
|
29
29
|
// synchronously, waits for the end of its task via `Microtask.next` (so a subscription made and dropped
|
|
30
30
|
// in one task requests no Refresh frame), and requests each next Refresh frame inside the current one's
|
|
@@ -95,6 +95,26 @@ export class Clock extends Context.Service<Clock, {
|
|
|
95
95
|
// @16c6122).
|
|
96
96
|
export const NOMINAL_DT = 1 / 60
|
|
97
97
|
|
|
98
|
+
/**
|
|
99
|
+
* How an Environment's Refresh frames run late ({@link LateFrames}): by their timestamps alone, or, once a
|
|
100
|
+
* frame's callback ran more than `ranAfter` ms after its timestamp, late, a long task delaying it.
|
|
101
|
+
*/
|
|
102
|
+
export type LateFrameTiming = "timestamp" | { readonly ranAfter: number }
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Whether the Frame loop tells a Refresh frame a long task delayed, a late frame: not by default. For an Environment whose frame
|
|
106
|
+
* timestamps are on its Clock's `now()`'s timebase, as `@wardic/dom`'s are, a frame that ran more than `ranAfter`
|
|
107
|
+
* ms after its timestamp, and one whose gap from the frame before is well past the frames' interval. A long task
|
|
108
|
+
* delays a frame, so a frame's dt holds the task's time. A run made in that task didn't exist before its first
|
|
109
|
+
* frame ran, and the loop leaves that time out of its first steps. The Clock's time stays the frames' timestamps,
|
|
110
|
+
* what every other run and reading counts.
|
|
111
|
+
*/
|
|
112
|
+
// #1026; the gap since #1050 (ADR-0027 *Amendment (#1050)*). `@wardic/dom` provides its own line to its Frame loop
|
|
113
|
+
// (`DomLive`'s `LateFramesDomLive`); `@wardic/object`'s pumped frames, whose times are its host's, keep the default.
|
|
114
|
+
export const LateFrames: Context.Reference<LateFrameTiming> = /*#__PURE__*/ Context.Reference<LateFrameTiming>("@wardic/core/Clock/LateFrames", {
|
|
115
|
+
defaultValue: () => "timestamp",
|
|
116
|
+
})
|
|
117
|
+
|
|
98
118
|
// @wardic/core compiles against ES2022 alone (no DOM lib, no Node types), which does
|
|
99
119
|
// not declare `performance` or `queueMicrotask`. They are host globals in every environment
|
|
100
120
|
// Wardic targets (browsers, Node, React Native), so they are declared here, in module scope only.
|
|
@@ -179,15 +199,16 @@ export const fromRefreshFrames: <Handle>(
|
|
|
179
199
|
* THE SINGLE UPDATE PATH. dt is NOMINAL_DT with no earlier Refresh frame, else (t - lastTime) / 1000.
|
|
180
200
|
*
|
|
181
201
|
* A Refresh frame whose timestamp REPEATS the previous one is timed by the
|
|
182
|
-
* elapsed `now()` since the previous frame instead:
|
|
183
|
-
* right after an input and
|
|
184
|
-
* otherwise advance nothing
|
|
185
|
-
*
|
|
186
|
-
*
|
|
202
|
+
* elapsed `now()` since the previous frame instead: an Environment may run a second
|
|
203
|
+
* frame right after an input and pass it the previous frame's timestamp, which would
|
|
204
|
+
* otherwise advance nothing. The next frame then gets the rest of the interval, and a
|
|
205
|
+
* dt never goes below 0. There is no upper clamp here: that is the consumer boundary's
|
|
206
|
+
* (`MAX_DT`).
|
|
187
207
|
*
|
|
188
208
|
* Hands dt to every subscriber. Hot path — intentionally unlogged; one `now()` read per
|
|
189
209
|
* Refresh frame.
|
|
190
210
|
*/
|
|
211
|
+
// Firefox runs that second frame (#18; ADR-0017, amended by #2).
|
|
191
212
|
const tick = (t: number): Effect.Effect<void> =>
|
|
192
213
|
Effect.sync(() => {
|
|
193
214
|
const at = now()
|
package/src/DefaultTransition.ts
CHANGED
|
@@ -88,7 +88,7 @@ const transformFor = (key: string, target: number | string): Transition =>
|
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
90
|
* The transition `key` runs on toward `target` by its name, as Motion picks it: a transform but a scale
|
|
91
|
-
* (`x`, `
|
|
91
|
+
* (`x`, `rotateY`, `rotateZ`…) on a spring of 500 / 25, at rest under 10 a second; a scale on a spring of
|
|
92
92
|
* 550, critically damped toward 0, else damped 30; any other key on a 0.3 s tween, eased by the cubic
|
|
93
93
|
* Bézier (0.25, 0.1, 0.35, 1). The same object for the same answer.
|
|
94
94
|
*
|
|
@@ -98,13 +98,15 @@ const transformFor = (key: string, target: number | string): Transition =>
|
|
|
98
98
|
*/
|
|
99
99
|
// Motion's `getDefaultTransition` (`motion-dom/src/animation/utils/default-transitions.ts` at 16c6122).
|
|
100
100
|
// #882 (ADR-0073, *Amendment (#882)*, Q2): dom's table (ADR-0051, #357), moved here, so a scene's keys run
|
|
101
|
-
// on what
|
|
101
|
+
// on what `@wardic/dom`'s do (ADR-0073, decision 22). dom's `DomDefaultTransition` and `@wardic/object`'s run
|
|
102
|
+
// their own transform keys as a twin's here (#887, #1002, ADR-0073 *Amendment (#1002)* Q3).
|
|
102
103
|
export const byKey = (key: string, target: number | string): Transition =>
|
|
103
104
|
Bool.match(Option.isSome(BaseValue.transformIdentity(key)), { onTrue: () => transformFor(key, target), onFalse: () => EASE })
|
|
104
105
|
|
|
105
106
|
/**
|
|
106
107
|
* The Default transition by key: {@link byKey} for each key, and {@link KEYFRAMES_TWEEN} through more
|
|
107
|
-
* than two stops.
|
|
108
|
+
* than two stops. An Environment's whose transform keys are core's; one with keys of its own gives them
|
|
109
|
+
* a transition too, as `@wardic/dom` and `@wardic/object` do.
|
|
108
110
|
*
|
|
109
111
|
* @example
|
|
110
112
|
* program.pipe(Effect.provide(DefaultTransition.layerByKey))
|
package/src/Drag.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A drag's samples and what shapes them: `Sample`, what `DragRecognizer`'s drags give at each step;
|
|
3
3
|
* `Axis`, the axes one moves on; and the constraints a binding applies to a sample's `offset`, with a
|
|
4
|
-
* rubber band past them (`constrain`, `within`, `withinBounds`), or to keep
|
|
5
|
-
* container (`boundsWithin`, `keepPlace` after a resize). A binding moves the
|
|
4
|
+
* rubber band past them (`constrain`, `within`, `withinBounds`), or to keep a Subject inside a
|
|
5
|
+
* container (`boundsWithin`, `keepPlace` after a resize). A binding moves the Subject from the
|
|
6
6
|
* shaped samples, and flings it at the end.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
@@ -38,9 +38,9 @@ export interface Sample {
|
|
|
38
38
|
readonly velocity: Point.Point
|
|
39
39
|
/**
|
|
40
40
|
* `"start"` once it's past its threshold, `"move"` as it moves, `"end"` at its release or a cancel. A
|
|
41
|
-
* cancel ends at the last move's point, with
|
|
42
|
-
*
|
|
43
|
-
*
|
|
41
|
+
* cancel ends at the last move's point, with no velocity. A drag whose release was lost ends at the
|
|
42
|
+
* pointer's first move with no button pressed, or at its next down: an `"end"` at the last pressed
|
|
43
|
+
* point, with no delta and no velocity. How it ended is its `endedBy`.
|
|
44
44
|
*/
|
|
45
45
|
// A `pointercancel`'s own coordinates aren't the pointer's (Chromium's carries (0, 0)). The lost
|
|
46
46
|
// release is a **Stale gesture** (ADR-0019).
|
|
@@ -59,11 +59,29 @@ export interface Sample {
|
|
|
59
59
|
/**
|
|
60
60
|
* `true` on an `"end"` its watch's `cancel` gave: the drag ended where it is, which a binding
|
|
61
61
|
* releases with no fling and tells no app. Absent on every other sample.
|
|
62
|
+
*
|
|
63
|
+
* @deprecated `endedBy === "controls"` says the same. It goes at the next major.
|
|
62
64
|
*/
|
|
63
|
-
// #431, Motion's drag controls' `cancel
|
|
65
|
+
// #431, Motion's drag controls' `cancel`; deprecated by #1042.
|
|
64
66
|
readonly cancelled?: boolean
|
|
67
|
+
/** How the drag ended, on its `"end"` ({@link EndedBy}). Absent on a `"start"` and a `"move"`. */
|
|
68
|
+
// #1042.
|
|
69
|
+
readonly endedBy?: EndedBy
|
|
65
70
|
}
|
|
66
71
|
|
|
72
|
+
/**
|
|
73
|
+
* How a drag ended:
|
|
74
|
+
*
|
|
75
|
+
* - `"release"`: its pointer let go, or its drag controls' `stop()` ended it as a release would.
|
|
76
|
+
* - `"cancel"`: the platform took its pointer away, its Environment's cancel (a touch taken to scroll, a
|
|
77
|
+
* system gesture). It ends at its last point with no velocity, so it doesn't fling.
|
|
78
|
+
* - `"lost"`: its release never came (a **Stale gesture**), found at its pointer's next move with no
|
|
79
|
+
* button pressed, or its next down. No velocity either.
|
|
80
|
+
* - `"controls"`: its drag controls' `cancel()` ended it where it is.
|
|
81
|
+
*/
|
|
82
|
+
// #1042 (ADR-0019, *Amendment (#1042)*).
|
|
83
|
+
export type EndedBy = "release" | "cancel" | "lost" | "controls"
|
|
84
|
+
|
|
67
85
|
/** A range on one axis. Either end can be left out: `{ min: 0 }` holds it above 0, and lets it go as far as it likes the other way. */
|
|
68
86
|
export interface AxisRange {
|
|
69
87
|
/** The least it goes to. */
|
|
@@ -111,8 +129,8 @@ const aboveMax = (v: number, range: AxisRange, elastic: number): Option.Option<n
|
|
|
111
129
|
* Drag.constrain(130, { min: 0, max: 100 }, 0.35) // 110.5
|
|
112
130
|
*/
|
|
113
131
|
// Below `min`: `min - (min - v) * elastic`; above `max`: `max + (v - max) * elastic`. Positional: a
|
|
114
|
-
// drag whose constraints bound the
|
|
115
|
-
//
|
|
132
|
+
// drag whose constraints bound the Subject's x/y applies it where the gesture's offset meets where the
|
|
133
|
+
// Subject started (ADR-0016, *Amendment (#140)*).
|
|
116
134
|
export const constrain = (v: number, range: AxisRange | undefined, elastic: number): number =>
|
|
117
135
|
Option.fromUndefinedOr(range).pipe(
|
|
118
136
|
Option.flatMap((r) => Option.orElse(belowMin(v, r, elastic), () => aboveMax(v, r, elastic))),
|
|
@@ -140,9 +158,9 @@ const rangeWithin = (near: number, far: number, containerNear: number, container
|
|
|
140
158
|
}
|
|
141
159
|
|
|
142
160
|
/**
|
|
143
|
-
* The bounds on
|
|
144
|
-
* constraints given
|
|
145
|
-
* dragged to show what overflows and no further. `own` is the
|
|
161
|
+
* The bounds on a Subject's x and y that keep its box inside `container`, as Motion's drag
|
|
162
|
+
* constraints given a container. On an axis where the box is the bigger they turn around, so it can be
|
|
163
|
+
* dragged to show what overflows and no further. `own` is the Subject's box with no x or y of its own:
|
|
146
164
|
* its layout box.
|
|
147
165
|
*
|
|
148
166
|
* @example
|
|
@@ -162,7 +180,7 @@ const sameRange = (a: AxisRange | undefined, b: AxisRange | undefined): boolean
|
|
|
162
180
|
onDefined: (ra) => UndefinedOr.match(b, { onUndefined: () => false, onDefined: (rb) => Bool.and(ra.min === rb.min, ra.max === rb.max) }),
|
|
163
181
|
})
|
|
164
182
|
|
|
165
|
-
/** Whether two bounds are the same on both axes: a resize that changed neither leaves
|
|
183
|
+
/** Whether two bounds are the same on both axes: a resize that changed neither leaves a Subject where it is. */
|
|
166
184
|
// #273.
|
|
167
185
|
export const sameBounds = (a: Bounds, b: Bounds): boolean => Bool.and(sameRange(a.x, b.x), sameRange(a.y, b.y))
|
|
168
186
|
|
|
@@ -185,7 +203,7 @@ const keptOn = (value: number, from: AxisRange | undefined, to: AxisRange | unde
|
|
|
185
203
|
})
|
|
186
204
|
|
|
187
205
|
/**
|
|
188
|
-
* `position` moved to keep its place, from `from` within `to`:
|
|
206
|
+
* `position` moved to keep its place, from `from` within `to`: a Subject's x and y after a resize
|
|
189
207
|
* changes the bounds that keep it inside its container, as Motion's. Only on the axes `axis` moves,
|
|
190
208
|
* and where both bounds have both ends; elsewhere it stays.
|
|
191
209
|
*/
|
|
@@ -223,7 +241,7 @@ export const within: {
|
|
|
223
241
|
|
|
224
242
|
/**
|
|
225
243
|
* A drag's samples with each one's `offset` kept within `bounds`, as `within` keeps one: for a Stream of
|
|
226
|
-
* them. `delta` and `velocity` stay the pointer's: a binding places the
|
|
244
|
+
* them. `delta` and `velocity` stay the pointer's: a binding places the Subject from `offset`, and the
|
|
227
245
|
* others stay a true record of how the pointer moved.
|
|
228
246
|
*
|
|
229
247
|
* @example
|
package/src/DragActivity.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Drag activity: how many drags are active, and which
|
|
2
|
+
* Drag activity: how many drags are active, and which Subject holds each axis. While a
|
|
3
3
|
* drag is active no hover and no press starts, as Motion's; and a drag that claims an axis another
|
|
4
|
-
*
|
|
4
|
+
* Subject holds is refused, so a nested drag on the same axis doesn't move both. A drag counts in once
|
|
5
5
|
* it's past its threshold, and counts off at its end or when it's interrupted. `DragRecognizer`'s drags
|
|
6
6
|
* keep it; a recognizer of your own reads it, or counts in and claims as a drag does.
|
|
7
7
|
*
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* import * as DragActivity from "@wardic/core/DragActivity"
|
|
13
13
|
*
|
|
14
14
|
* const activity = yield* DragActivity.DragActivity
|
|
15
|
-
* const release = activity.claim(card, "x") // None when another
|
|
15
|
+
* const release = activity.claim(card, "x") // None when another Subject holds x
|
|
16
16
|
* activity.isDragActive() // true until it's released
|
|
17
17
|
*/
|
|
18
18
|
// ADR-0019, decision 3b (Drag activity), and *Amendment (#29)* (Drag claims): Motion's `isDragging`
|
package/src/DragRecognizer.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The pointer's drags and pans. `drag` is a Stream of `Drag.Sample`s as a pointer drags `target`, kept
|
|
3
|
-
* to its axis, and refused when another
|
|
3
|
+
* to its axis, and refused when another Subject holds that axis; `pan` gives the same samples with a
|
|
4
4
|
* session's start at each down, moves nothing, and stops no drag. `watchDrag` and `watchPan` call you
|
|
5
5
|
* with each sample inside its pointer event's dispatch while a Scope is open, with no fiber of their own:
|
|
6
6
|
* a binding's drags run on these. They're apart from `Recognizer`'s gestures, so an app that never drags
|
|
@@ -114,6 +114,13 @@ type StaleRule = "unpressed move" | "second down"
|
|
|
114
114
|
// Module state (#460, Q7): a cache held weakly by the object it's for, so it goes with it.
|
|
115
115
|
const staleEnds = /*#__PURE__*/ new WeakMap<Drag.Sample, StaleRule>()
|
|
116
116
|
|
|
117
|
+
/**
|
|
118
|
+
* The cancels folded in place of a release whose point its mapping couldn't give ({@link standInFor}):
|
|
119
|
+
* a release all the same, which {@link onRelease} ends as one, with its moves' velocity.
|
|
120
|
+
*/
|
|
121
|
+
// Module state (#1042): a mark held weakly by the event it's on, so it goes with it.
|
|
122
|
+
const unmappedReleases = /*#__PURE__*/ new WeakSet<InputSource.PointerLikeEvent>()
|
|
123
|
+
|
|
117
124
|
/** No samples: the event changes nothing a consumer sees. */
|
|
118
125
|
const NO_SAMPLES: ReadonlyArray<Drag.Sample> = []
|
|
119
126
|
|
|
@@ -136,6 +143,7 @@ const staleEnd = (state: DragState, rule: StaleRule, timeStamp: number, raw: unk
|
|
|
136
143
|
scroll: state.lastScroll,
|
|
137
144
|
raw,
|
|
138
145
|
axis: "xy",
|
|
146
|
+
endedBy: "lost",
|
|
139
147
|
}
|
|
140
148
|
staleEnds.set(sample, rule)
|
|
141
149
|
return [sample]
|
|
@@ -207,19 +215,26 @@ const onRelease = (state: DragState, event: InputSource.PointerLikeEvent): Step
|
|
|
207
215
|
onFalse: () => [initState, NO_SAMPLES],
|
|
208
216
|
onTrue: () => {
|
|
209
217
|
// A cancel's coordinates aren't the pointer's (Chromium's pointercancel carries
|
|
210
|
-
// (0, 0)), so it ends at the last move's point,
|
|
211
|
-
//
|
|
218
|
+
// (0, 0)), so it ends at the last move's point, as Motion's pan session does
|
|
219
|
+
// (PanSession.ts:329-333 at 16c6122). With no velocity, where Motion's keeps the
|
|
220
|
+
// moves': a gesture the platform took away doesn't fling, as a lost release doesn't
|
|
221
|
+
// (#1042, ADR-0019's *Amendment (#1042)*).
|
|
222
|
+
// A release its mapping couldn't place comes as a cancel too, and ends at the last point all the
|
|
223
|
+
// same, but it was let go: a release, with its moves' velocity (#1000, #1042).
|
|
212
224
|
const sample: Drag.Sample = Bool.match(event.type === "cancel", {
|
|
213
225
|
onTrue: () => ({
|
|
214
226
|
point: state.last,
|
|
215
227
|
offset: { x: state.last.x - state.origin.x, y: state.last.y - state.origin.y },
|
|
216
228
|
delta: { x: 0, y: 0 },
|
|
217
|
-
velocity: windowVelocity(state.history),
|
|
218
229
|
phase: "end",
|
|
219
230
|
timeStamp: event.timeStamp,
|
|
220
231
|
scroll: state.lastScroll,
|
|
221
232
|
raw: event.raw,
|
|
222
233
|
axis: "xy",
|
|
234
|
+
...Bool.match(unmappedReleases.has(event), {
|
|
235
|
+
onTrue: (): Pick<Drag.Sample, "velocity" | "endedBy"> => ({ velocity: windowVelocity(state.history), endedBy: "release" }),
|
|
236
|
+
onFalse: (): Pick<Drag.Sample, "velocity" | "endedBy"> => ({ velocity: { x: 0, y: 0 }, endedBy: "cancel" }),
|
|
237
|
+
}),
|
|
223
238
|
}),
|
|
224
239
|
onFalse: () => {
|
|
225
240
|
const point = pointOf(event)
|
|
@@ -235,6 +250,7 @@ const onRelease = (state: DragState, event: InputSource.PointerLikeEvent): Step
|
|
|
235
250
|
scroll: event.scroll,
|
|
236
251
|
raw: event.raw,
|
|
237
252
|
axis: "xy",
|
|
253
|
+
endedBy: "release",
|
|
238
254
|
}
|
|
239
255
|
},
|
|
240
256
|
})
|
|
@@ -302,8 +318,9 @@ const onMove = (state: DragState, event: InputSource.PointerLikeEvent, starts: S
|
|
|
302
318
|
/**
|
|
303
319
|
* The gesture ended from outside its pointer (#431, Motion's drag controls): an `"end"` at its last
|
|
304
320
|
* point, with that event's time and platform event, as a cancel's. `stop`'s has the moves' velocity,
|
|
305
|
-
* a release; `cancel`'s none, marked `cancelled`. A gesture that hasn't
|
|
306
|
-
* as a tap does. Either way its pointer's later events are left out,
|
|
321
|
+
* a release; `cancel`'s none, ended by `"controls"` and marked `cancelled`. A gesture that hasn't
|
|
322
|
+
* started resets with no sample, as a tap does. Either way its pointer's later events are left out,
|
|
323
|
+
* until a down claims again.
|
|
307
324
|
*/
|
|
308
325
|
const endedFromOutside = (state: DragState, cancelled: boolean): Step =>
|
|
309
326
|
Bool.match(state.phase === "active", {
|
|
@@ -313,14 +330,17 @@ const endedFromOutside = (state: DragState, cancelled: boolean): Step =>
|
|
|
313
330
|
point: state.last,
|
|
314
331
|
offset: { x: state.last.x - state.origin.x, y: state.last.y - state.origin.y },
|
|
315
332
|
delta: { x: 0, y: 0 },
|
|
316
|
-
velocity: Bool.match(cancelled, { onTrue: () => ({ x: 0, y: 0 }), onFalse: () => windowVelocity(state.history) }),
|
|
317
333
|
phase: "end",
|
|
318
334
|
timeStamp: Option.match(Arr.last(state.history), { onNone: () => 0, onSome: (p) => p.timeStamp }),
|
|
319
335
|
scroll: state.lastScroll,
|
|
320
336
|
raw: state.lastRaw,
|
|
321
337
|
axis: "xy",
|
|
338
|
+
...Bool.match(cancelled, {
|
|
339
|
+
onTrue: (): Pick<Drag.Sample, "velocity" | "endedBy" | "cancelled"> => ({ velocity: { x: 0, y: 0 }, endedBy: "controls", cancelled: true }),
|
|
340
|
+
onFalse: (): Pick<Drag.Sample, "velocity" | "endedBy"> => ({ velocity: windowVelocity(state.history), endedBy: "release" }),
|
|
341
|
+
}),
|
|
322
342
|
}
|
|
323
|
-
return [initState, [
|
|
343
|
+
return [initState, [end]]
|
|
324
344
|
},
|
|
325
345
|
})
|
|
326
346
|
|
|
@@ -409,12 +429,18 @@ export interface DragOptions {
|
|
|
409
429
|
readonly threshold?: ((down: InputSource.PointerLikeEvent) => Option.Option<number>) | undefined
|
|
410
430
|
/**
|
|
411
431
|
* Where each pointer point is for the gesture, as Motion's `transformPagePoint`: read at each down, and
|
|
412
|
-
* applied to
|
|
413
|
-
*
|
|
414
|
-
*
|
|
415
|
-
*
|
|
432
|
+
* applied to the points the gesture is made of, its down's, each pressed move's and its release's. A
|
|
433
|
+
* cancel, a move with no button pressed, an enter and a leave aren't mapped. None, or no function given,
|
|
434
|
+
* leaves the points as they are. It's handed the point on the screen and gives one; the scroll a hold
|
|
435
|
+
* counts in is added back after. A caller gives back the same `Some` while its mapping is the same, so
|
|
436
|
+
* a down allocates nothing.
|
|
437
|
+
*
|
|
438
|
+
* A mapping that throws is reported through `onDefect`, once a run of throws, and the gesture goes on
|
|
439
|
+
* without that point: a move is left out; a release ends the gesture at its last point, with its moves'
|
|
440
|
+
* velocity, a release all the same (`endedBy: "release"`); a down starts nothing, and ends a gesture its
|
|
441
|
+
* pointer had left open.
|
|
416
442
|
*/
|
|
417
|
-
// #443; an `Option` (#618, A1).
|
|
443
|
+
// #443; an `Option` (#618, A1). #1000 (ADR-0074): the points mapped, and a throw's.
|
|
418
444
|
readonly mapPoint?: LazyArg<Option.Option<PointMap>> | undefined
|
|
419
445
|
}
|
|
420
446
|
|
|
@@ -425,20 +451,30 @@ export type PointMap = (point: Point.Point) => Point.Point
|
|
|
425
451
|
/** `watchPan`'s options. */
|
|
426
452
|
// #443.
|
|
427
453
|
export interface PanOptions {
|
|
428
|
-
/** Where each pointer point is for the gesture, as `DragOptions`' `mapPoint
|
|
454
|
+
/** Where each pointer point is for the gesture, as `DragOptions`' `mapPoint`: the same points, and a throw the same way. */
|
|
429
455
|
readonly mapPoint?: LazyArg<Option.Option<PointMap>> | undefined
|
|
430
456
|
}
|
|
431
457
|
|
|
432
458
|
/**
|
|
433
|
-
*
|
|
434
|
-
*
|
|
435
|
-
*
|
|
459
|
+
* Whether a drag's fold reads `event`'s point: a down's, a pressed move's and a release's. A cancel ends at
|
|
460
|
+
* the last move's point and an unpressed move (a lost release) at the last pressed one, and an enter or
|
|
461
|
+
* a leave moves nothing.
|
|
462
|
+
*/
|
|
463
|
+
// #1000 (ADR-0074): mapped, a cancel at (0, 0), where Chromium's lands, or any hover move could throw.
|
|
464
|
+
const readsPoint = (event: InputSource.PointerLikeEvent): boolean =>
|
|
465
|
+
Bool.or(Bool.or(event.type === "down", event.type === "up"), Bool.and(event.type === "move", event.pressed))
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* A gesture's point mapping (#443): read at each down, `event` mapped while it's set, when its fold reads
|
|
469
|
+
* its point ({@link readsPoint}). The point mapped is the one on the screen (`x - scroll.x`), the scroll
|
|
470
|
+
* the hold counts in added back after. Allocates only for a mapped gesture.
|
|
436
471
|
*/
|
|
437
472
|
const mappedEvents = (mapPoint: DragOptions["mapPoint"]): ((event: InputSource.PointerLikeEvent) => InputSource.PointerLikeEvent) => {
|
|
438
473
|
if (Predicate.isUndefined(mapPoint)) return identity
|
|
439
474
|
const current = MutableRef.make<Option.Option<PointMap>>(Option.none())
|
|
440
475
|
return (event) => {
|
|
441
476
|
if (event.type === "down") MutableRef.set(current, mapPoint())
|
|
477
|
+
if (Bool.not(readsPoint(event))) return event
|
|
442
478
|
const mapping = MutableRef.get(current)
|
|
443
479
|
if (Option.isNone(mapping)) return event
|
|
444
480
|
const { scroll } = event
|
|
@@ -447,6 +483,58 @@ const mappedEvents = (mapPoint: DragOptions["mapPoint"]): ((event: InputSource.P
|
|
|
447
483
|
}
|
|
448
484
|
}
|
|
449
485
|
|
|
486
|
+
/**
|
|
487
|
+
* The event folded in place of one whose point its mapping can't give, an event whose point isn't read:
|
|
488
|
+
* a release's a cancel marked as a release ({@link unmappedReleases}), which ends the gesture at its last
|
|
489
|
+
* point with its moves' velocity; a down's an unpressed move, a lost release, which ends a gesture of its
|
|
490
|
+
* pointer's still open, at its last point with no velocity, and starts none. None for a move, left out.
|
|
491
|
+
*/
|
|
492
|
+
// #1000 (ADR-0074): a release left out kept its gesture going, active and claimed, until the next press;
|
|
493
|
+
// a down left out kept one a lost release had left open, for good while the mapping threw at each down.
|
|
494
|
+
const standInFor: (event: InputSource.PointerLikeEvent) => Option.Option<InputSource.PointerLikeEvent> = /*#__PURE__*/ Match.type<InputSource.PointerLikeEvent>().pipe(
|
|
495
|
+
Match.when({ type: "up" }, (up) => {
|
|
496
|
+
const standIn: InputSource.PointerLikeEvent = { ...up, type: "cancel" }
|
|
497
|
+
unmappedReleases.add(standIn)
|
|
498
|
+
return Option.some(standIn)
|
|
499
|
+
}),
|
|
500
|
+
Match.when({ type: "down" }, (down) => Option.some<InputSource.PointerLikeEvent>({ ...down, type: "move", pressed: false })),
|
|
501
|
+
Match.orElse(() => Option.none()),
|
|
502
|
+
)
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* A watch's handler over `step`: each event's point mapped first, its state kept in `state` and its
|
|
506
|
+
* samples told to `tell`. An event whose mapping throws is folded as its stand-in ({@link standInFor}),
|
|
507
|
+
* and the throw goes on to the watch's guard, which reports it, once its samples are told.
|
|
508
|
+
*/
|
|
509
|
+
// #443; #1000: the throw is rethrown so the guard stays the one place a run of throws is reported, once.
|
|
510
|
+
// A throw from `tell` as the stand-in's samples are told reaches the guard in the mapping's place: still
|
|
511
|
+
// one report for the run.
|
|
512
|
+
const mappedHandler = <S>(
|
|
513
|
+
mapPoint: DragOptions["mapPoint"],
|
|
514
|
+
step: (state: DragState, event: InputSource.PointerLikeEvent) => readonly [DragState, ReadonlyArray<S>],
|
|
515
|
+
state: MutableRef.MutableRef<DragState>,
|
|
516
|
+
tell: (sample: S) => void,
|
|
517
|
+
): ((event: InputSource.PointerLikeEvent) => boolean) => {
|
|
518
|
+
const mapped = mappedEvents(mapPoint)
|
|
519
|
+
const fold = (event: InputSource.PointerLikeEvent): void => {
|
|
520
|
+
const [next, samples] = step(MutableRef.get(state), event)
|
|
521
|
+
MutableRef.set(state, next)
|
|
522
|
+
Arr.forEach(samples, tell)
|
|
523
|
+
}
|
|
524
|
+
return (event) => {
|
|
525
|
+
let mappedEvent: InputSource.PointerLikeEvent
|
|
526
|
+
try {
|
|
527
|
+
mappedEvent = mapped(event)
|
|
528
|
+
} catch (error) {
|
|
529
|
+
const standIn = standInFor(event)
|
|
530
|
+
if (Option.isSome(standIn)) fold(standIn.value)
|
|
531
|
+
throw error
|
|
532
|
+
}
|
|
533
|
+
fold(mappedEvent)
|
|
534
|
+
return true
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
450
538
|
/** A drag's watch, as one with no drag controls gives it back: its Scope ends it, and nothing else does. */
|
|
451
539
|
// #618 (F3): a plain watch's type has no `stop` or `cancel`, which did nothing on it.
|
|
452
540
|
export interface WatchedDrag {}
|
|
@@ -460,7 +548,7 @@ export interface WatchedDrag {}
|
|
|
460
548
|
export interface AdoptableDrag extends WatchedDrag {
|
|
461
549
|
/** Ends the gesture as its pointer's release would: an `"end"` at its last point, with its moves' velocity. */
|
|
462
550
|
readonly stop: () => void
|
|
463
|
-
/** Ends the gesture where it is: an `"end"` with no velocity,
|
|
551
|
+
/** Ends the gesture where it is: an `"end"` with no velocity, `endedBy: "controls"` (and the deprecated `cancelled`). */
|
|
464
552
|
readonly cancel: () => void
|
|
465
553
|
}
|
|
466
554
|
|
|
@@ -591,10 +679,13 @@ export const watchDragAmong: (
|
|
|
591
679
|
}
|
|
592
680
|
const own: PressedMember = { scope: Scope.forkUnsafe(scope, "sequential"), pointerId: told.pointerId, started: false }
|
|
593
681
|
pressed.set(member, own)
|
|
682
|
+
// #979 group I, row 28 (ADR-0074, group A's *Order first*): the watch ended before the app hears the
|
|
683
|
+
// end, so a handler that throws at it can't leave the member pressed, its next press starting nothing.
|
|
684
|
+
// The end closes the watch after this dispatch, so the handler still hears this sample.
|
|
594
685
|
const on = (sample: Drag.Sample): void => {
|
|
595
686
|
if (sample.phase === "start") own.started = true
|
|
596
|
-
handlers.on(member, sample)
|
|
597
687
|
if (sample.phase === "end") end(member, own)
|
|
688
|
+
handlers.on(member, sample)
|
|
598
689
|
}
|
|
599
690
|
run(watchDrag(member, { ...options, listen: false, adoptable: true }, { on, onDefect: handlers.onDefect }).pipe(Scope.provide(own.scope)))
|
|
600
691
|
hand(member, own, told)
|
|
@@ -635,7 +726,7 @@ export const drag = (target: unknown, options: DragOptions = {}): Stream.Stream<
|
|
|
635
726
|
* - **It starts** once the pointer has moved `threshold` px, 3 by default, from its down.
|
|
636
727
|
* - **Its axis is claimed** at its `"start"`, before `on` hears it, and counts as an active drag, so no
|
|
637
728
|
* hover or press starts elsewhere while it's on. Every watch on one target shares the claim. When
|
|
638
|
-
* another
|
|
729
|
+
* another Subject holds an axis it needs, the gesture is refused: it tells nothing until its end, as a
|
|
639
730
|
* tap tells nothing, and doesn't retry. Of nested drags, the innermost claims first. With `claim: false`
|
|
640
731
|
* it only counts.
|
|
641
732
|
* - **Its claim is given back** at its `"end"`, before `on` hears it, or when the Scope closes mid-drag,
|
|
@@ -670,7 +761,6 @@ export const watchDrag: {
|
|
|
670
761
|
handlers: InputFeed.Handlers<Drag.Sample>,
|
|
671
762
|
): Effect.Effect<AdoptableDrag, never, Scope.Scope | InputSource.InputSource> => {
|
|
672
763
|
const attributes = { threshold: THRESHOLD, velocityWindowMs: VELOCITY_WINDOW_MS }
|
|
673
|
-
const mapped = mappedEvents(mapPoint)
|
|
674
764
|
const axisAt = axisAtOf(axis)
|
|
675
765
|
const fold = dragFoldOf(lock, listen, threshold)
|
|
676
766
|
const on = handlers.on
|
|
@@ -738,12 +828,7 @@ export const watchDrag: {
|
|
|
738
828
|
"wardic.drag",
|
|
739
829
|
attributes,
|
|
740
830
|
feed,
|
|
741
|
-
() => (
|
|
742
|
-
const [next, samples] = fold(MutableRef.get(state), mapped(event))
|
|
743
|
-
MutableRef.set(state, next)
|
|
744
|
-
Arr.forEach(samples, admit)
|
|
745
|
-
return true
|
|
746
|
-
},
|
|
831
|
+
() => mappedHandler(mapPoint, fold, state, admit),
|
|
747
832
|
handlers,
|
|
748
833
|
)
|
|
749
834
|
// Its ends from outside its pointer (#431) only for a target given Drag controls (#539): no other
|
|
@@ -808,7 +893,7 @@ const panStep = (state: DragState, event: InputSource.PointerLikeEvent): PanStep
|
|
|
808
893
|
* A pan claims no axis, so it never stops a drag, nested or not, and no drag stops it. Once started it
|
|
809
894
|
* counts as an active drag until its end, so a press it took over ends as neither a tap nor a cancel,
|
|
810
895
|
* and no hover starts meanwhile: that's Wardic's, not Motion's, whose swipe let go over a tappable
|
|
811
|
-
*
|
|
896
|
+
* Subject taps it too.
|
|
812
897
|
*/
|
|
813
898
|
// #273, ADR-0047: no **Drag claim**; counted in the **Drag activity**. Motion's pan is invisible to its
|
|
814
899
|
// drag lock.
|
|
@@ -847,19 +932,11 @@ export const watchPan: (target: unknown, handlers: InputFeed.Handlers<PanSample>
|
|
|
847
932
|
"wardic.pan",
|
|
848
933
|
PAN_ATTRIBUTES,
|
|
849
934
|
input.pointer(target),
|
|
850
|
-
() =>
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
MutableRef.set(state, next)
|
|
856
|
-
Arr.forEach(samples, (sample) => {
|
|
857
|
-
counted(sample)
|
|
858
|
-
handlers.on(sample)
|
|
859
|
-
})
|
|
860
|
-
return true
|
|
861
|
-
}
|
|
862
|
-
},
|
|
935
|
+
() =>
|
|
936
|
+
mappedHandler(options.mapPoint, panStep, MutableRef.make(initState), (sample) => {
|
|
937
|
+
counted(sample)
|
|
938
|
+
handlers.on(sample)
|
|
939
|
+
}),
|
|
863
940
|
handlers,
|
|
864
941
|
)
|
|
865
942
|
})
|
package/src/Easing.ts
CHANGED
|
@@ -161,7 +161,7 @@ export const easeInOutBounce: Easing = (t) => {
|
|
|
161
161
|
|
|
162
162
|
/**
|
|
163
163
|
* A cubic Bézier easing through the control points `(x1, y1)` and `(x2, y2)`. An `ease` of
|
|
164
|
-
* `[x1, y1, x2, y2]` is the same. `x1` and `x2` are from 0 to 1,
|
|
164
|
+
* `[x1, y1, x2, y2]` is the same. `x1` and `x2` are from 0 to 1, so the curve is a function of time;
|
|
165
165
|
* `y1` and `y2` may be any finite number, so the curve may overshoot. Anything else throws an
|
|
166
166
|
* `OptionError` naming the point, as an `ease` given in a transition does.
|
|
167
167
|
*
|
package/src/Frame.ts
CHANGED
|
@@ -12,9 +12,11 @@
|
|
|
12
12
|
* if (Frame.isPhysics(frame)) speed = frame.velocity
|
|
13
13
|
* }
|
|
14
14
|
*/
|
|
15
|
-
// CONTEXT.md's Frame; docs/adr/0001-core-stream-contract.md. A plain shape,
|
|
16
|
-
//
|
|
17
|
-
// `
|
|
15
|
+
// CONTEXT.md's Frame; docs/adr/0001-core-stream-contract.md. A plain shape, with no methods (ADR-0028,
|
|
16
|
+
// decision 1): a step allocates one every tick, or rewrites one per run in place, as `springValues`', a
|
|
17
|
+
// tween's, the blends' and `keyframesValues`' do (ADR-0030, decision 11 and *Amendments (#895, #1031)*). A
|
|
18
|
+
// tween's is a class's instance, still with no methods, so V8 gives it a hidden class of its own (#1031).
|
|
19
|
+
// Only the physics Primitives (`spring`, `decay`, `chase`)
|
|
18
20
|
// emit `velocity`, the field `isPhysics` narrows on.
|
|
19
21
|
import * as Predicate from "effect/Predicate"
|
|
20
22
|
|