@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/dist/Drag.d.ts
CHANGED
|
@@ -15,9 +15,9 @@ export interface Sample {
|
|
|
15
15
|
readonly velocity: Point.Point;
|
|
16
16
|
/**
|
|
17
17
|
* `"start"` once it's past its threshold, `"move"` as it moves, `"end"` at its release or a cancel. A
|
|
18
|
-
* cancel ends at the last move's point, with
|
|
19
|
-
*
|
|
20
|
-
*
|
|
18
|
+
* cancel ends at the last move's point, with no velocity. A drag whose release was lost ends at the
|
|
19
|
+
* pointer's first move with no button pressed, or at its next down: an `"end"` at the last pressed
|
|
20
|
+
* point, with no delta and no velocity. How it ended is its `endedBy`.
|
|
21
21
|
*/
|
|
22
22
|
readonly phase: "start" | "move" | "end";
|
|
23
23
|
/** The time, in ms, of the event behind it: for a move a scroll made, the scroll's. */
|
|
@@ -31,9 +31,24 @@ export interface Sample {
|
|
|
31
31
|
/**
|
|
32
32
|
* `true` on an `"end"` its watch's `cancel` gave: the drag ended where it is, which a binding
|
|
33
33
|
* releases with no fling and tells no app. Absent on every other sample.
|
|
34
|
+
*
|
|
35
|
+
* @deprecated `endedBy === "controls"` says the same. It goes at the next major.
|
|
34
36
|
*/
|
|
35
37
|
readonly cancelled?: boolean;
|
|
38
|
+
/** How the drag ended, on its `"end"` ({@link EndedBy}). Absent on a `"start"` and a `"move"`. */
|
|
39
|
+
readonly endedBy?: EndedBy;
|
|
36
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* How a drag ended:
|
|
43
|
+
*
|
|
44
|
+
* - `"release"`: its pointer let go, or its drag controls' `stop()` ended it as a release would.
|
|
45
|
+
* - `"cancel"`: the platform took its pointer away, its Environment's cancel (a touch taken to scroll, a
|
|
46
|
+
* system gesture). It ends at its last point with no velocity, so it doesn't fling.
|
|
47
|
+
* - `"lost"`: its release never came (a **Stale gesture**), found at its pointer's next move with no
|
|
48
|
+
* button pressed, or its next down. No velocity either.
|
|
49
|
+
* - `"controls"`: its drag controls' `cancel()` ended it where it is.
|
|
50
|
+
*/
|
|
51
|
+
export type EndedBy = "release" | "cancel" | "lost" | "controls";
|
|
37
52
|
/** 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. */
|
|
38
53
|
export interface AxisRange {
|
|
39
54
|
/** The least it goes to. */
|
|
@@ -75,21 +90,21 @@ export interface Edges {
|
|
|
75
90
|
readonly left: number;
|
|
76
91
|
}
|
|
77
92
|
/**
|
|
78
|
-
* The bounds on
|
|
79
|
-
* constraints given
|
|
80
|
-
* dragged to show what overflows and no further. `own` is the
|
|
93
|
+
* The bounds on a Subject's x and y that keep its box inside `container`, as Motion's drag
|
|
94
|
+
* constraints given a container. On an axis where the box is the bigger they turn around, so it can be
|
|
95
|
+
* dragged to show what overflows and no further. `own` is the Subject's box with no x or y of its own:
|
|
81
96
|
* its layout box.
|
|
82
97
|
*
|
|
83
98
|
* @example
|
|
84
99
|
* const bounds = Drag.boundsWithin(cardBox, frameBox)
|
|
85
100
|
*/
|
|
86
101
|
export declare const boundsWithin: (own: Edges, container: Edges) => Bounds;
|
|
87
|
-
/** Whether two bounds are the same on both axes: a resize that changed neither leaves
|
|
102
|
+
/** Whether two bounds are the same on both axes: a resize that changed neither leaves a Subject where it is. */
|
|
88
103
|
export declare const sameBounds: (a: Bounds, b: Bounds) => boolean;
|
|
89
104
|
/** Where `value` sits between `min` and `max`: 0 at `min`, 1 at `max`, held between; ½ for a range of no length. */
|
|
90
105
|
export declare const progressWithin: (value: number, min: number, max: number) => number;
|
|
91
106
|
/**
|
|
92
|
-
* `position` moved to keep its place, from `from` within `to`:
|
|
107
|
+
* `position` moved to keep its place, from `from` within `to`: a Subject's x and y after a resize
|
|
93
108
|
* changes the bounds that keep it inside its container, as Motion's. Only on the axes `axis` moves,
|
|
94
109
|
* and where both bounds have both ends; elsewhere it stays.
|
|
95
110
|
*/
|
|
@@ -112,7 +127,7 @@ export declare const within: {
|
|
|
112
127
|
};
|
|
113
128
|
/**
|
|
114
129
|
* A drag's samples with each one's `offset` kept within `bounds`, as `within` keeps one: for a Stream of
|
|
115
|
-
* them. `delta` and `velocity` stay the pointer's: a binding places the
|
|
130
|
+
* them. `delta` and `velocity` stay the pointer's: a binding places the Subject from `offset`, and the
|
|
116
131
|
* others stay a true record of how the pointer moved.
|
|
117
132
|
*
|
|
118
133
|
* @example
|
package/dist/Drag.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drag.d.ts","sourceRoot":"","sources":["../src/Drag.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAA;AAGxC,sHAAsH;AAEtH,MAAM,WAAW,MAAM;IACrB,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAA;IAC3B,wFAAwF;IACxF,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAA;IAC5B,kDAAkD;IAClD,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAA;IAC3B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,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 +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
|
|
@@ -34,8 +34,8 @@ const aboveMax = (v, range, elastic) => Option.fromNullishOr(range.max).pipe(Opt
|
|
|
34
34
|
* Drag.constrain(130, { min: 0, max: 100 }, 0.35) // 110.5
|
|
35
35
|
*/
|
|
36
36
|
// Below `min`: `min - (min - v) * elastic`; above `max`: `max + (v - max) * elastic`. Positional: a
|
|
37
|
-
// drag whose constraints bound the
|
|
38
|
-
//
|
|
37
|
+
// drag whose constraints bound the Subject's x/y applies it where the gesture's offset meets where the
|
|
38
|
+
// Subject started (ADR-0016, *Amendment (#140)*).
|
|
39
39
|
export const constrain = (v, range, elastic) => Option.fromUndefinedOr(range).pipe(Option.flatMap((r) => Option.orElse(belowMin(v, r, elastic), () => aboveMax(v, r, elastic))), Option.getOrElse(() => v));
|
|
40
40
|
/** One axis of {@link boundsWithin}: from the container's near edge less the box's, to its far edge less the box's; swapped when the box is bigger. */
|
|
41
41
|
const rangeWithin = (near, far, containerNear, containerFar) => {
|
|
@@ -46,9 +46,9 @@ const rangeWithin = (near, far, containerNear, containerFar) => {
|
|
|
46
46
|
return { min, max };
|
|
47
47
|
};
|
|
48
48
|
/**
|
|
49
|
-
* The bounds on
|
|
50
|
-
* constraints given
|
|
51
|
-
* dragged to show what overflows and no further. `own` is the
|
|
49
|
+
* The bounds on a Subject's x and y that keep its box inside `container`, as Motion's drag
|
|
50
|
+
* constraints given a container. On an axis where the box is the bigger they turn around, so it can be
|
|
51
|
+
* dragged to show what overflows and no further. `own` is the Subject's box with no x or y of its own:
|
|
52
52
|
* its layout box.
|
|
53
53
|
*
|
|
54
54
|
* @example
|
|
@@ -65,7 +65,7 @@ const sameRange = (a, b) => UndefinedOr.match(a, {
|
|
|
65
65
|
onUndefined: () => Predicate.isUndefined(b),
|
|
66
66
|
onDefined: (ra) => UndefinedOr.match(b, { onUndefined: () => false, onDefined: (rb) => Bool.and(ra.min === rb.min, ra.max === rb.max) }),
|
|
67
67
|
});
|
|
68
|
-
/** Whether two bounds are the same on both axes: a resize that changed neither leaves
|
|
68
|
+
/** Whether two bounds are the same on both axes: a resize that changed neither leaves a Subject where it is. */
|
|
69
69
|
// #273.
|
|
70
70
|
export const sameBounds = (a, b) => Bool.and(sameRange(a.x, b.x), sameRange(a.y, b.y));
|
|
71
71
|
/** Where `value` sits between `min` and `max`: 0 at `min`, 1 at `max`, held between; ½ for a range of no length. */
|
|
@@ -83,7 +83,7 @@ const keptOn = (value, from, to) => Option.match(Option.all([edgesOfRange(from),
|
|
|
83
83
|
onSome: ([[fromMin, fromMax], [toMin, toMax]]) => toMin + progressWithin(value, fromMin, fromMax) * (toMax - toMin),
|
|
84
84
|
});
|
|
85
85
|
/**
|
|
86
|
-
* `position` moved to keep its place, from `from` within `to`:
|
|
86
|
+
* `position` moved to keep its place, from `from` within `to`: a Subject's x and y after a resize
|
|
87
87
|
* changes the bounds that keep it inside its container, as Motion's. Only on the axes `axis` moves,
|
|
88
88
|
* and where both bounds have both ends; elsewhere it stays.
|
|
89
89
|
*/
|
|
@@ -113,7 +113,7 @@ export const within = dual((first) => Predicate.hasProperty(first, "phase"), (sa
|
|
|
113
113
|
});
|
|
114
114
|
/**
|
|
115
115
|
* A drag's samples with each one's `offset` kept within `bounds`, as `within` keeps one: for a Stream of
|
|
116
|
-
* them. `delta` and `velocity` stay the pointer's: a binding places the
|
|
116
|
+
* them. `delta` and `velocity` stay the pointer's: a binding places the Subject from `offset`, and the
|
|
117
117
|
* others stay a true record of how the pointer moved.
|
|
118
118
|
*
|
|
119
119
|
* @example
|
package/dist/Drag.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drag.js","sourceRoot":"","sources":["../src/Drag.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,+FAA+F;AAC/F,2EAA2E;AAC3E,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAA;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"Drag.js","sourceRoot":"","sources":["../src/Drag.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,+FAA+F;AAC/F,2EAA2E;AAC3E,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAA;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAqFzC,wFAAwF;AACxF,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAE,KAAgB,EAAE,OAAe,EAAyB,EAAE,CACvF,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAClC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,EAC/B,MAAM,CAAC,GAA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,CAAC,EAAE,OAAO,CAAC;YAChD,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC;SACjD;KACF,CAAA;AACH,CAAC,CACF,CAAA;AAED;;;;;;;GAOG;AACH,mGAAmG;AACnG,wGAAwG;AACxG,kDAAkD;AAClD,MAAM,CAAC,MAAM,YAAY,GAUrB,IAAI,CACN,MAAM,CAAC,QAAQ,EACf,CACE,MAAmC,EACnC,MAAc,EACd,OAAO,GAAkC,EAAE,EACd,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAClG,CAAA"}
|
package/dist/DragActivity.js
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/dist/DragRecognizer.d.ts
CHANGED
|
@@ -47,10 +47,16 @@ export interface DragOptions {
|
|
|
47
47
|
readonly threshold?: ((down: InputSource.PointerLikeEvent) => Option.Option<number>) | undefined;
|
|
48
48
|
/**
|
|
49
49
|
* Where each pointer point is for the gesture, as Motion's `transformPagePoint`: read at each down, and
|
|
50
|
-
* applied to
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
50
|
+
* applied to the points the gesture is made of, its down's, each pressed move's and its release's. A
|
|
51
|
+
* cancel, a move with no button pressed, an enter and a leave aren't mapped. None, or no function given,
|
|
52
|
+
* leaves the points as they are. It's handed the point on the screen and gives one; the scroll a hold
|
|
53
|
+
* counts in is added back after. A caller gives back the same `Some` while its mapping is the same, so
|
|
54
|
+
* a down allocates nothing.
|
|
55
|
+
*
|
|
56
|
+
* A mapping that throws is reported through `onDefect`, once a run of throws, and the gesture goes on
|
|
57
|
+
* without that point: a move is left out; a release ends the gesture at its last point, with its moves'
|
|
58
|
+
* velocity, a release all the same (`endedBy: "release"`); a down starts nothing, and ends a gesture its
|
|
59
|
+
* pointer had left open.
|
|
54
60
|
*/
|
|
55
61
|
readonly mapPoint?: LazyArg<Option.Option<PointMap>> | undefined;
|
|
56
62
|
}
|
|
@@ -58,7 +64,7 @@ export interface DragOptions {
|
|
|
58
64
|
export type PointMap = (point: Point.Point) => Point.Point;
|
|
59
65
|
/** `watchPan`'s options. */
|
|
60
66
|
export interface PanOptions {
|
|
61
|
-
/** Where each pointer point is for the gesture, as `DragOptions`' `mapPoint
|
|
67
|
+
/** Where each pointer point is for the gesture, as `DragOptions`' `mapPoint`: the same points, and a throw the same way. */
|
|
62
68
|
readonly mapPoint?: LazyArg<Option.Option<PointMap>> | undefined;
|
|
63
69
|
}
|
|
64
70
|
/** A drag's watch, as one with no drag controls gives it back: its Scope ends it, and nothing else does. */
|
|
@@ -72,7 +78,7 @@ export interface WatchedDrag {
|
|
|
72
78
|
export interface AdoptableDrag extends WatchedDrag {
|
|
73
79
|
/** Ends the gesture as its pointer's release would: an `"end"` at its last point, with its moves' velocity. */
|
|
74
80
|
readonly stop: () => void;
|
|
75
|
-
/** Ends the gesture where it is: an `"end"` with no velocity,
|
|
81
|
+
/** Ends the gesture where it is: an `"end"` with no velocity, `endedBy: "controls"` (and the deprecated `cancelled`). */
|
|
76
82
|
readonly cancel: () => void;
|
|
77
83
|
}
|
|
78
84
|
/**
|
|
@@ -104,7 +110,7 @@ export declare const drag: (target: unknown, options?: DragOptions) => Stream.St
|
|
|
104
110
|
* - **It starts** once the pointer has moved `threshold` px, 3 by default, from its down.
|
|
105
111
|
* - **Its axis is claimed** at its `"start"`, before `on` hears it, and counts as an active drag, so no
|
|
106
112
|
* hover or press starts elsewhere while it's on. Every watch on one target shares the claim. When
|
|
107
|
-
* another
|
|
113
|
+
* another Subject holds an axis it needs, the gesture is refused: it tells nothing until its end, as a
|
|
108
114
|
* tap tells nothing, and doesn't retry. Of nested drags, the innermost claims first. With `claim: false`
|
|
109
115
|
* it only counts.
|
|
110
116
|
* - **Its claim is given back** at its `"end"`, before `on` hears it, or when the Scope closes mid-drag,
|
|
@@ -145,7 +151,7 @@ export interface PanSample extends Omit<Drag.Sample, "phase"> {
|
|
|
145
151
|
* A pan claims no axis, so it never stops a drag, nested or not, and no drag stops it. Once started it
|
|
146
152
|
* counts as an active drag until its end, so a press it took over ends as neither a tap nor a cancel,
|
|
147
153
|
* and no hover starts meanwhile: that's Wardic's, not Motion's, whose swipe let go over a tappable
|
|
148
|
-
*
|
|
154
|
+
* Subject taps it too.
|
|
149
155
|
*/
|
|
150
156
|
export declare const pan: (target: unknown) => Stream.Stream<PanSample, never, InputSource.InputSource>;
|
|
151
157
|
export declare const watchPan: (target: unknown, handlers: InputFeed.Handlers<PanSample>, options?: PanOptions) => Effect.Effect<void, never, Scope.Scope | InputSource.InputSource>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DragRecognizer.d.ts","sourceRoot":"","sources":["../src/DragRecognizer.ts"],"names":[],"mappings":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,CAAC,MAAM,CAAC,aAAa,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,WAAW,CAAC,WAAW,CAAC,CAAA;CA2F/J,CAAA;AAED;;;GAGG;AAEH,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3D,+FAA+F;IAC/F,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;CACjD;AA8BD;;;;;;;;;GASG;AAGH,eAAO,MAAM,GAAG,WAAY,OAAO,KAAG,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,WAAW,CAAC,WAAW,CACL,CAAA;AAYxF,eAAO,MAAM,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,EAAE,UAAU,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,WAAW,CAAC,WAAW,CA6BvK,CAAA"}
|
package/dist/DragRecognizer.js
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
|
|
@@ -82,6 +82,12 @@ const windowVelocity = (history) => Velocity.trailing(history, VELOCITY_WINDOW_M
|
|
|
82
82
|
*/
|
|
83
83
|
// Module state (#460, Q7): a cache held weakly by the object it's for, so it goes with it.
|
|
84
84
|
const staleEnds = /*#__PURE__*/ new WeakMap();
|
|
85
|
+
/**
|
|
86
|
+
* The cancels folded in place of a release whose point its mapping couldn't give ({@link standInFor}):
|
|
87
|
+
* a release all the same, which {@link onRelease} ends as one, with its moves' velocity.
|
|
88
|
+
*/
|
|
89
|
+
// Module state (#1042): a mark held weakly by the event it's on, so it goes with it.
|
|
90
|
+
const unmappedReleases = /*#__PURE__*/ new WeakSet();
|
|
85
91
|
/** No samples: the event changes nothing a consumer sees. */
|
|
86
92
|
const NO_SAMPLES = [];
|
|
87
93
|
/**
|
|
@@ -102,6 +108,7 @@ const staleEnd = (state, rule, timeStamp, raw) => Bool.match(state.phase === "ac
|
|
|
102
108
|
scroll: state.lastScroll,
|
|
103
109
|
raw,
|
|
104
110
|
axis: "xy",
|
|
111
|
+
endedBy: "lost",
|
|
105
112
|
};
|
|
106
113
|
staleEnds.set(sample, rule);
|
|
107
114
|
return [sample];
|
|
@@ -152,19 +159,26 @@ const onRelease = (state, event) => Bool.match(state.phase === "active", {
|
|
|
152
159
|
onFalse: () => [initState, NO_SAMPLES],
|
|
153
160
|
onTrue: () => {
|
|
154
161
|
// A cancel's coordinates aren't the pointer's (Chromium's pointercancel carries
|
|
155
|
-
// (0, 0)), so it ends at the last move's point,
|
|
156
|
-
//
|
|
162
|
+
// (0, 0)), so it ends at the last move's point, as Motion's pan session does
|
|
163
|
+
// (PanSession.ts:329-333 at 16c6122). With no velocity, where Motion's keeps the
|
|
164
|
+
// moves': a gesture the platform took away doesn't fling, as a lost release doesn't
|
|
165
|
+
// (#1042, ADR-0019's *Amendment (#1042)*).
|
|
166
|
+
// A release its mapping couldn't place comes as a cancel too, and ends at the last point all the
|
|
167
|
+
// same, but it was let go: a release, with its moves' velocity (#1000, #1042).
|
|
157
168
|
const sample = Bool.match(event.type === "cancel", {
|
|
158
169
|
onTrue: () => ({
|
|
159
170
|
point: state.last,
|
|
160
171
|
offset: { x: state.last.x - state.origin.x, y: state.last.y - state.origin.y },
|
|
161
172
|
delta: { x: 0, y: 0 },
|
|
162
|
-
velocity: windowVelocity(state.history),
|
|
163
173
|
phase: "end",
|
|
164
174
|
timeStamp: event.timeStamp,
|
|
165
175
|
scroll: state.lastScroll,
|
|
166
176
|
raw: event.raw,
|
|
167
177
|
axis: "xy",
|
|
178
|
+
...Bool.match(unmappedReleases.has(event), {
|
|
179
|
+
onTrue: () => ({ velocity: windowVelocity(state.history), endedBy: "release" }),
|
|
180
|
+
onFalse: () => ({ velocity: { x: 0, y: 0 }, endedBy: "cancel" }),
|
|
181
|
+
}),
|
|
168
182
|
}),
|
|
169
183
|
onFalse: () => {
|
|
170
184
|
const point = pointOf(event);
|
|
@@ -180,6 +194,7 @@ const onRelease = (state, event) => Bool.match(state.phase === "active", {
|
|
|
180
194
|
scroll: event.scroll,
|
|
181
195
|
raw: event.raw,
|
|
182
196
|
axis: "xy",
|
|
197
|
+
endedBy: "release",
|
|
183
198
|
};
|
|
184
199
|
},
|
|
185
200
|
});
|
|
@@ -234,8 +249,9 @@ const onMove = (state, event, starts) => {
|
|
|
234
249
|
/**
|
|
235
250
|
* The gesture ended from outside its pointer (#431, Motion's drag controls): an `"end"` at its last
|
|
236
251
|
* point, with that event's time and platform event, as a cancel's. `stop`'s has the moves' velocity,
|
|
237
|
-
* a release; `cancel`'s none, marked `cancelled`. A gesture that hasn't
|
|
238
|
-
* as a tap does. Either way its pointer's later events are left out,
|
|
252
|
+
* a release; `cancel`'s none, ended by `"controls"` and marked `cancelled`. A gesture that hasn't
|
|
253
|
+
* started resets with no sample, as a tap does. Either way its pointer's later events are left out,
|
|
254
|
+
* until a down claims again.
|
|
239
255
|
*/
|
|
240
256
|
const endedFromOutside = (state, cancelled) => Bool.match(state.phase === "active", {
|
|
241
257
|
onFalse: () => [initState, NO_SAMPLES],
|
|
@@ -244,14 +260,17 @@ const endedFromOutside = (state, cancelled) => Bool.match(state.phase === "activ
|
|
|
244
260
|
point: state.last,
|
|
245
261
|
offset: { x: state.last.x - state.origin.x, y: state.last.y - state.origin.y },
|
|
246
262
|
delta: { x: 0, y: 0 },
|
|
247
|
-
velocity: Bool.match(cancelled, { onTrue: () => ({ x: 0, y: 0 }), onFalse: () => windowVelocity(state.history) }),
|
|
248
263
|
phase: "end",
|
|
249
264
|
timeStamp: Option.match(Arr.last(state.history), { onNone: () => 0, onSome: (p) => p.timeStamp }),
|
|
250
265
|
scroll: state.lastScroll,
|
|
251
266
|
raw: state.lastRaw,
|
|
252
267
|
axis: "xy",
|
|
268
|
+
...Bool.match(cancelled, {
|
|
269
|
+
onTrue: () => ({ velocity: { x: 0, y: 0 }, endedBy: "controls", cancelled: true }),
|
|
270
|
+
onFalse: () => ({ velocity: windowVelocity(state.history), endedBy: "release" }),
|
|
271
|
+
}),
|
|
253
272
|
};
|
|
254
|
-
return [initState, [
|
|
273
|
+
return [initState, [end]];
|
|
255
274
|
},
|
|
256
275
|
});
|
|
257
276
|
/** An event from the gesture's owner, other than a down. */
|
|
@@ -284,9 +303,16 @@ Match.orElse((e) => Bool.match(e.pointerId === state.ownerId, { onTrue: () => on
|
|
|
284
303
|
/** A pan's fold: its own presses, each starting past the threshold. */
|
|
285
304
|
const panFold = /*#__PURE__*/ stepOf(pastThreshold, OWN_DOWNS);
|
|
286
305
|
/**
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
306
|
+
* Whether a drag's fold reads `event`'s point: a down's, a pressed move's and a release's. A cancel ends at
|
|
307
|
+
* the last move's point and an unpressed move (a lost release) at the last pressed one, and an enter or
|
|
308
|
+
* a leave moves nothing.
|
|
309
|
+
*/
|
|
310
|
+
// #1000 (ADR-0074): mapped, a cancel at (0, 0), where Chromium's lands, or any hover move could throw.
|
|
311
|
+
const readsPoint = (event) => Bool.or(Bool.or(event.type === "down", event.type === "up"), Bool.and(event.type === "move", event.pressed));
|
|
312
|
+
/**
|
|
313
|
+
* A gesture's point mapping (#443): read at each down, `event` mapped while it's set, when its fold reads
|
|
314
|
+
* its point ({@link readsPoint}). The point mapped is the one on the screen (`x - scroll.x`), the scroll
|
|
315
|
+
* the hold counts in added back after. Allocates only for a mapped gesture.
|
|
290
316
|
*/
|
|
291
317
|
const mappedEvents = (mapPoint) => {
|
|
292
318
|
if (Predicate.isUndefined(mapPoint))
|
|
@@ -295,6 +321,8 @@ const mappedEvents = (mapPoint) => {
|
|
|
295
321
|
return (event) => {
|
|
296
322
|
if (event.type === "down")
|
|
297
323
|
MutableRef.set(current, mapPoint());
|
|
324
|
+
if (Bool.not(readsPoint(event)))
|
|
325
|
+
return event;
|
|
298
326
|
const mapping = MutableRef.get(current);
|
|
299
327
|
if (Option.isNone(mapping))
|
|
300
328
|
return event;
|
|
@@ -303,6 +331,49 @@ const mappedEvents = (mapPoint) => {
|
|
|
303
331
|
return { ...event, x: at.x + scroll.x, y: at.y + scroll.y };
|
|
304
332
|
};
|
|
305
333
|
};
|
|
334
|
+
/**
|
|
335
|
+
* The event folded in place of one whose point its mapping can't give, an event whose point isn't read:
|
|
336
|
+
* a release's a cancel marked as a release ({@link unmappedReleases}), which ends the gesture at its last
|
|
337
|
+
* point with its moves' velocity; a down's an unpressed move, a lost release, which ends a gesture of its
|
|
338
|
+
* pointer's still open, at its last point with no velocity, and starts none. None for a move, left out.
|
|
339
|
+
*/
|
|
340
|
+
// #1000 (ADR-0074): a release left out kept its gesture going, active and claimed, until the next press;
|
|
341
|
+
// a down left out kept one a lost release had left open, for good while the mapping threw at each down.
|
|
342
|
+
const standInFor = /*#__PURE__*/ Match.type().pipe(Match.when({ type: "up" }, (up) => {
|
|
343
|
+
const standIn = { ...up, type: "cancel" };
|
|
344
|
+
unmappedReleases.add(standIn);
|
|
345
|
+
return Option.some(standIn);
|
|
346
|
+
}), Match.when({ type: "down" }, (down) => Option.some({ ...down, type: "move", pressed: false })), Match.orElse(() => Option.none()));
|
|
347
|
+
/**
|
|
348
|
+
* A watch's handler over `step`: each event's point mapped first, its state kept in `state` and its
|
|
349
|
+
* samples told to `tell`. An event whose mapping throws is folded as its stand-in ({@link standInFor}),
|
|
350
|
+
* and the throw goes on to the watch's guard, which reports it, once its samples are told.
|
|
351
|
+
*/
|
|
352
|
+
// #443; #1000: the throw is rethrown so the guard stays the one place a run of throws is reported, once.
|
|
353
|
+
// A throw from `tell` as the stand-in's samples are told reaches the guard in the mapping's place: still
|
|
354
|
+
// one report for the run.
|
|
355
|
+
const mappedHandler = (mapPoint, step, state, tell) => {
|
|
356
|
+
const mapped = mappedEvents(mapPoint);
|
|
357
|
+
const fold = (event) => {
|
|
358
|
+
const [next, samples] = step(MutableRef.get(state), event);
|
|
359
|
+
MutableRef.set(state, next);
|
|
360
|
+
Arr.forEach(samples, tell);
|
|
361
|
+
};
|
|
362
|
+
return (event) => {
|
|
363
|
+
let mappedEvent;
|
|
364
|
+
try {
|
|
365
|
+
mappedEvent = mapped(event);
|
|
366
|
+
}
|
|
367
|
+
catch (error) {
|
|
368
|
+
const standIn = standInFor(event);
|
|
369
|
+
if (Option.isSome(standIn))
|
|
370
|
+
fold(standIn.value);
|
|
371
|
+
throw error;
|
|
372
|
+
}
|
|
373
|
+
fold(mappedEvent);
|
|
374
|
+
return true;
|
|
375
|
+
};
|
|
376
|
+
};
|
|
306
377
|
/** A plain watch's ends from outside (#539): shared, and doing nothing. */
|
|
307
378
|
const NO_ENDS = { stop: constVoid, cancel: constVoid };
|
|
308
379
|
/** A drag's downs (#431): its own presses unless it doesn't `listen`, and those it adopted; each gesture's threshold its `threshold`'s, else 3. */
|
|
@@ -397,12 +468,15 @@ export const watchDragAmong = /*#__PURE__*/ Effect.fnUntraced(function* (memberO
|
|
|
397
468
|
}
|
|
398
469
|
const own = { scope: Scope.forkUnsafe(scope, "sequential"), pointerId: told.pointerId, started: false };
|
|
399
470
|
pressed.set(member, own);
|
|
471
|
+
// #979 group I, row 28 (ADR-0074, group A's *Order first*): the watch ended before the app hears the
|
|
472
|
+
// end, so a handler that throws at it can't leave the member pressed, its next press starting nothing.
|
|
473
|
+
// The end closes the watch after this dispatch, so the handler still hears this sample.
|
|
400
474
|
const on = (sample) => {
|
|
401
475
|
if (sample.phase === "start")
|
|
402
476
|
own.started = true;
|
|
403
|
-
handlers.on(member, sample);
|
|
404
477
|
if (sample.phase === "end")
|
|
405
478
|
end(member, own);
|
|
479
|
+
handlers.on(member, sample);
|
|
406
480
|
};
|
|
407
481
|
run(watchDrag(member, { ...options, listen: false, adoptable: true }, { on, onDefect: handlers.onDefect }).pipe(Scope.provide(own.scope)));
|
|
408
482
|
hand(member, own, told);
|
|
@@ -443,7 +517,7 @@ export const drag = (target, options = {}) => streamOf((handlers) => watchDrag(t
|
|
|
443
517
|
* - **It starts** once the pointer has moved `threshold` px, 3 by default, from its down.
|
|
444
518
|
* - **Its axis is claimed** at its `"start"`, before `on` hears it, and counts as an active drag, so no
|
|
445
519
|
* hover or press starts elsewhere while it's on. Every watch on one target shares the claim. When
|
|
446
|
-
* another
|
|
520
|
+
* another Subject holds an axis it needs, the gesture is refused: it tells nothing until its end, as a
|
|
447
521
|
* tap tells nothing, and doesn't retry. Of nested drags, the innermost claims first. With `claim: false`
|
|
448
522
|
* it only counts.
|
|
449
523
|
* - **Its claim is given back** at its `"end"`, before `on` hears it, or when the Scope closes mid-drag,
|
|
@@ -470,7 +544,6 @@ export const drag = (target, options = {}) => streamOf((handlers) => watchDrag(t
|
|
|
470
544
|
// closed, and any other watch's nothing at all (#539). Its overloads are types alone (#618, F3).
|
|
471
545
|
export const watchDrag = (target, { axis = "xy", claim = true, lock = false, listen = true, adoptable = false, threshold, mapPoint }, handlers) => {
|
|
472
546
|
const attributes = { threshold: THRESHOLD, velocityWindowMs: VELOCITY_WINDOW_MS };
|
|
473
|
-
const mapped = mappedEvents(mapPoint);
|
|
474
547
|
const axisAt = axisAtOf(axis);
|
|
475
548
|
const fold = dragFoldOf(lock, listen, threshold);
|
|
476
549
|
const on = handlers.on;
|
|
@@ -525,12 +598,7 @@ export const watchDrag = (target, { axis = "xy", claim = true, lock = false, lis
|
|
|
525
598
|
yield* Effect.addFinalizer(() => Effect.sync(release));
|
|
526
599
|
// The adoptable feed only for a target given Drag controls (#507): a plain one subscribes no adoption.
|
|
527
600
|
const feed = Bool.match(adoptable, { onTrue: () => InputSource.adoptablePointerOf(input, target), onFalse: () => input.pointer(target) });
|
|
528
|
-
yield* watchFeed("wardic.drag", attributes, feed, () => (
|
|
529
|
-
const [next, samples] = fold(MutableRef.get(state), mapped(event));
|
|
530
|
-
MutableRef.set(state, next);
|
|
531
|
-
Arr.forEach(samples, admit);
|
|
532
|
-
return true;
|
|
533
|
-
}, handlers);
|
|
601
|
+
yield* watchFeed("wardic.drag", attributes, feed, () => mappedHandler(mapPoint, fold, state, admit), handlers);
|
|
534
602
|
// Its ends from outside its pointer (#431) only for a target given Drag controls (#539): no other
|
|
535
603
|
// is ended so. Closing the Scope stops them first.
|
|
536
604
|
if (Bool.not(adoptable))
|
|
@@ -581,7 +649,7 @@ const panStep = (state, event) => {
|
|
|
581
649
|
* A pan claims no axis, so it never stops a drag, nested or not, and no drag stops it. Once started it
|
|
582
650
|
* counts as an active drag until its end, so a press it took over ends as neither a tap nor a cancel,
|
|
583
651
|
* and no hover starts meanwhile: that's Wardic's, not Motion's, whose swipe let go over a tappable
|
|
584
|
-
*
|
|
652
|
+
* Subject taps it too.
|
|
585
653
|
*/
|
|
586
654
|
// #273, ADR-0047: no **Drag claim**; counted in the **Drag activity**. Motion's pan is invisible to its
|
|
587
655
|
// drag lock.
|
|
@@ -612,18 +680,9 @@ export const watchPan = Effect.fnUntraced(function* (target, handlers, options =
|
|
|
612
680
|
};
|
|
613
681
|
// Added first, so it runs last: after the feed has stopped.
|
|
614
682
|
yield* Effect.addFinalizer(() => Effect.sync(release));
|
|
615
|
-
yield* watchFeed("wardic.pan", PAN_ATTRIBUTES, input.pointer(target), () => {
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
const [next, samples] = panStep(MutableRef.get(state), mapped(event));
|
|
620
|
-
MutableRef.set(state, next);
|
|
621
|
-
Arr.forEach(samples, (sample) => {
|
|
622
|
-
counted(sample);
|
|
623
|
-
handlers.on(sample);
|
|
624
|
-
});
|
|
625
|
-
return true;
|
|
626
|
-
};
|
|
627
|
-
}, handlers);
|
|
683
|
+
yield* watchFeed("wardic.pan", PAN_ATTRIBUTES, input.pointer(target), () => mappedHandler(options.mapPoint, panStep, MutableRef.make(initState), (sample) => {
|
|
684
|
+
counted(sample);
|
|
685
|
+
handlers.on(sample);
|
|
686
|
+
}), handlers);
|
|
628
687
|
});
|
|
629
688
|
//# sourceMappingURL=DragRecognizer.js.map
|