@ac-kit/ui-gesture 0.0.0-stage → 0.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.
Files changed (72) hide show
  1. package/CHANGELOG.md +151 -0
  2. package/LICENSE +28 -0
  3. package/README.md +310 -2
  4. package/dist/_validate.d.ts +4 -0
  5. package/dist/_validate.d.ts.map +1 -0
  6. package/dist/_validate.js +10 -0
  7. package/dist/_validate.js.map +1 -0
  8. package/dist/dom/_claim.d.ts +8 -0
  9. package/dist/dom/_claim.d.ts.map +1 -0
  10. package/dist/dom/_claim.js +14 -0
  11. package/dist/dom/_claim.js.map +1 -0
  12. package/dist/dom/_pointer-engine.d.ts +121 -0
  13. package/dist/dom/_pointer-engine.d.ts.map +1 -0
  14. package/dist/dom/_pointer-engine.js +559 -0
  15. package/dist/dom/_pointer-engine.js.map +1 -0
  16. package/dist/dom/_press-driver.d.ts +39 -0
  17. package/dist/dom/_press-driver.d.ts.map +1 -0
  18. package/dist/dom/_press-driver.js +121 -0
  19. package/dist/dom/_press-driver.js.map +1 -0
  20. package/dist/dom/index.d.ts +5 -0
  21. package/dist/dom/index.d.ts.map +1 -0
  22. package/dist/dom/index.js +5 -0
  23. package/dist/dom/index.js.map +1 -0
  24. package/dist/dom/pointer-binding.d.ts +111 -0
  25. package/dist/dom/pointer-binding.d.ts.map +1 -0
  26. package/dist/dom/pointer-binding.js +35 -0
  27. package/dist/dom/pointer-binding.js.map +1 -0
  28. package/dist/dom/press-binding.d.ts +29 -0
  29. package/dist/dom/press-binding.d.ts.map +1 -0
  30. package/dist/dom/press-binding.js +53 -0
  31. package/dist/dom/press-binding.js.map +1 -0
  32. package/dist/dom/transform-binding.d.ts +81 -0
  33. package/dist/dom/transform-binding.d.ts.map +1 -0
  34. package/dist/dom/transform-binding.js +349 -0
  35. package/dist/dom/transform-binding.js.map +1 -0
  36. package/dist/index.d.ts +8 -0
  37. package/dist/index.d.ts.map +1 -0
  38. package/dist/index.js +8 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/inertia/inertia.d.ts +32 -0
  41. package/dist/inertia/inertia.d.ts.map +1 -0
  42. package/dist/inertia/inertia.js +62 -0
  43. package/dist/inertia/inertia.js.map +1 -0
  44. package/dist/keys/key-step.d.ts +25 -0
  45. package/dist/keys/key-step.d.ts.map +1 -0
  46. package/dist/keys/key-step.js +30 -0
  47. package/dist/keys/key-step.js.map +1 -0
  48. package/dist/pointer/_slop.d.ts +26 -0
  49. package/dist/pointer/_slop.d.ts.map +1 -0
  50. package/dist/pointer/_slop.js +74 -0
  51. package/dist/pointer/_slop.js.map +1 -0
  52. package/dist/pointer/pointer-input.d.ts +61 -0
  53. package/dist/pointer/pointer-input.d.ts.map +1 -0
  54. package/dist/pointer/pointer-input.js +6 -0
  55. package/dist/pointer/pointer-input.js.map +1 -0
  56. package/dist/press/press-gesture.d.ts +282 -0
  57. package/dist/press/press-gesture.d.ts.map +1 -0
  58. package/dist/press/press-gesture.js +579 -0
  59. package/dist/press/press-gesture.js.map +1 -0
  60. package/dist/transform/transform-gesture.d.ts +174 -0
  61. package/dist/transform/transform-gesture.d.ts.map +1 -0
  62. package/dist/transform/transform-gesture.js +415 -0
  63. package/dist/transform/transform-gesture.js.map +1 -0
  64. package/dist/velocity/velocity-tracker.d.ts +69 -0
  65. package/dist/velocity/velocity-tracker.d.ts.map +1 -0
  66. package/dist/velocity/velocity-tracker.js +152 -0
  67. package/dist/velocity/velocity-tracker.js.map +1 -0
  68. package/dist/wheel/wheel.d.ts +115 -0
  69. package/dist/wheel/wheel.d.ts.map +1 -0
  70. package/dist/wheel/wheel.js +164 -0
  71. package/dist/wheel/wheel.js.map +1 -0
  72. package/package.json +79 -3
@@ -0,0 +1,579 @@
1
+ import { assertFinite, assertInteger, assertNonNegative, describeValue, nextAfter, } from "@ac-kit/core";
2
+ import { Queue } from "@ac-kit/data";
3
+ import { assertSample_ } from "../_validate.js";
4
+ import { checkedSlop_, compareLength_, isWithinSlop_, slopOf_, } from "../pointer/_slop.js";
5
+ import { VelocityTracker, } from "../velocity/velocity-tracker.js";
6
+ const DEFAULT_BUTTONS_ = [0];
7
+ const DEFAULT_DOUBLE_TAP_INTERVAL_ = 300;
8
+ const DEFAULT_DOUBLE_TAP_MIN_INTERVAL_ = 40;
9
+ const DEFAULT_DOUBLE_TAP_SLOP_ = 100;
10
+ const DEFAULT_LONG_PRESS_DELAY_ = 500;
11
+ const DEFAULT_SWIPE_MIN_DISTANCE_ = 50;
12
+ const DEFAULT_SWIPE_MIN_VELOCITY_ = 0.5;
13
+ const ZERO_VELOCITY_ = Object.freeze({ x: 0, y: 0 });
14
+ const NO_RESOLUTION_ = Object.freeze({ kind: "none" });
15
+ function resolveDoubleTap_(option) {
16
+ if (option === undefined || option === false) {
17
+ return undefined;
18
+ }
19
+ const options = option === true ? {} : option;
20
+ const resolved = {
21
+ interval: options.interval ?? DEFAULT_DOUBLE_TAP_INTERVAL_,
22
+ minInterval: options.minInterval ?? DEFAULT_DOUBLE_TAP_MIN_INTERVAL_,
23
+ slop: options.slop ?? DEFAULT_DOUBLE_TAP_SLOP_,
24
+ };
25
+ assertNonNegative(resolved.interval, "doubleTap.interval");
26
+ assertNonNegative(resolved.minInterval, "doubleTap.minInterval");
27
+ assertNonNegative(resolved.slop, "doubleTap.slop");
28
+ return resolved;
29
+ }
30
+ function resolveLongPressDelay_(option) {
31
+ if (option === undefined || option === false) {
32
+ return undefined;
33
+ }
34
+ const delay = (option === true ? undefined : option.delay) ?? DEFAULT_LONG_PRESS_DELAY_;
35
+ assertNonNegative(delay, "longPress.delay");
36
+ return delay;
37
+ }
38
+ function resolveSwipe_(option) {
39
+ if (option === undefined) {
40
+ return undefined;
41
+ }
42
+ const resolved = {
43
+ minDistance: option.minDistance ?? DEFAULT_SWIPE_MIN_DISTANCE_,
44
+ minVelocity: option.minVelocity ?? DEFAULT_SWIPE_MIN_VELOCITY_,
45
+ };
46
+ assertNonNegative(resolved.minDistance, "swipe.minDistance");
47
+ assertNonNegative(resolved.minVelocity, "swipe.minVelocity");
48
+ return resolved;
49
+ }
50
+ function earlier_(current, candidate) {
51
+ return current === undefined || candidate < current ? candidate : current;
52
+ }
53
+ function swipeAlong_(movement, velocity, swipe) {
54
+ if (Math.abs(movement) > swipe.minDistance &&
55
+ Math.abs(velocity) > swipe.minVelocity &&
56
+ Math.sign(movement) === Math.sign(velocity)) {
57
+ return movement > 0 ? 1 : -1;
58
+ }
59
+ return 0;
60
+ }
61
+ /**
62
+ * Everything one press of one pointer can mean — a tap, a double tap, a long
63
+ * press, a drag — arbitrated in one place, as Android's `GestureDetector` does:
64
+ * a drag past the slop withdraws the tap and the long press; a fired long press
65
+ * withdraws the tap (a later move past the slop still drags); a second pointer
66
+ * withdraws both. Times are passed in; timers are the caller's: schedule a call
67
+ * to {@link PressGesture.resolve} at {@link PressGesture.deadline}, and read
68
+ * `deadline` again after every call, since any of them can change it.
69
+ *
70
+ * A tap is held back for a second tap only while a second tap is possible: a
71
+ * press that lands in time and place for one keeps the first tap from settling,
72
+ * and the first tap settles at once, as a single tap for `resolve` to report,
73
+ * when that press turns out to be anything but a tap (or any other press lands
74
+ * out of time or place), or can no longer be one (held past `tapMaxDuration`).
75
+ *
76
+ * What a press is follows from the times of the events, never from when the
77
+ * caller asked `resolve`. An event at time `T` first settles whatever fell due
78
+ * before `T`: a long press whose delay has passed fires, a tap whose interval
79
+ * has passed settles. Those resolutions wait for the next `resolve`, which
80
+ * reports each once (`long-press` carries the time it fell due), so an event
81
+ * can come back before the resolution that explains it: call `resolve` with the
82
+ * event's time before passing the event, as the DOM bindings do, to keep them
83
+ * in order. At exactly the time something falls due, the call order decides: an
84
+ * event passed before `resolve(T)` is processed first (a second press exactly
85
+ * `interval` ms after the first release is a double tap, a release exactly at
86
+ * the long-press delay is a tap, one exactly at `tapMaxDuration` is a tap), and
87
+ * `resolve(T)` first settles it. Taps settle at the time their cause happened
88
+ * and are reported by a `resolve` at or after it, never before, and never lost:
89
+ * a caller that never resolves accumulates one small record per settled tap.
90
+ *
91
+ * The press has a clock: the latest time one of its events or a resolution it
92
+ * settled carried. `move`, `release`, `resolve` and `signalLongPress` take a
93
+ * time on the press's own time line, so a time before the clock is a
94
+ * `RangeError` and changes nothing; another pointer's time, which ends no
95
+ * press, need not interleave. A caller that polls with a time earlier than an
96
+ * event it has not yet delivered passes `Math.max` of the two.
97
+ *
98
+ * Every method is O(1), except the end of a drag, O(capacity) for the velocity.
99
+ */
100
+ export class PressGesture {
101
+ slop_;
102
+ buttons_;
103
+ axisOption_;
104
+ dragFrom_;
105
+ doubleTap_;
106
+ longPressDelay_;
107
+ tapMaxDuration_;
108
+ swipe_;
109
+ tracker_ = new VelocityTracker();
110
+ press_ = undefined;
111
+ pending_ = undefined;
112
+ queue_ = new Queue();
113
+ // The `at` of the last queued resolution: a later one never precedes it.
114
+ lastQueuedAt_ = Number.NEGATIVE_INFINITY;
115
+ constructor(options) {
116
+ this.slop_ = checkedSlop_(options?.slop);
117
+ this.buttons_ = options?.buttons ?? DEFAULT_BUTTONS_;
118
+ for (const button of this.buttons_) {
119
+ assertInteger(button, "button");
120
+ }
121
+ const axis = options?.axis;
122
+ if (axis !== undefined && axis !== "x" && axis !== "y" && axis !== "lock") {
123
+ throw new RangeError(`axis must be "x", "y" or "lock", got ${describeValue(axis)}`);
124
+ }
125
+ this.axisOption_ = axis;
126
+ const dragFrom = options?.dragFrom ?? "slop";
127
+ if (dragFrom !== "press" && dragFrom !== "slop") {
128
+ throw new RangeError(`dragFrom must be "press" or "slop", got ${describeValue(dragFrom)}`);
129
+ }
130
+ this.dragFrom_ = dragFrom;
131
+ this.doubleTap_ = resolveDoubleTap_(options?.doubleTap);
132
+ this.longPressDelay_ = resolveLongPressDelay_(options?.longPress);
133
+ this.tapMaxDuration_ = options?.tapMaxDuration ?? Number.POSITIVE_INFINITY;
134
+ assertNonNegative(this.tapMaxDuration_, "tapMaxDuration", {
135
+ isInfinityAllowed: true,
136
+ });
137
+ this.swipe_ = resolveSwipe_(options?.swipe);
138
+ }
139
+ /** Whether a pointer is down. */
140
+ get isPressed() {
141
+ return this.press_ !== undefined;
142
+ }
143
+ /** Whether the pointer down has started a drag. */
144
+ get isDragging() {
145
+ return this.press_?.isDragging === true;
146
+ }
147
+ /**
148
+ * The earliest time {@link PressGesture.resolve} has something to report, or
149
+ * `undefined`: a settled resolution's time, a long press's delay, the end of
150
+ * a tap's interval, or the first instant a press held for a second tap can no
151
+ * longer be a tap.
152
+ */
153
+ get deadline() {
154
+ let earliest = this.queue_.front()?.at;
155
+ const press = this.press_;
156
+ if (press?.isTapCandidate === true &&
157
+ this.longPressDelay_ !== undefined &&
158
+ !press.longPressFired) {
159
+ earliest = earlier_(earliest, press.startTime + this.longPressDelay_);
160
+ }
161
+ if (press?.holdsPending === true && Number.isFinite(this.tapMaxDuration_)) {
162
+ earliest = earlier_(earliest, this.holdExpiry_(press));
163
+ }
164
+ if (this.pending_ !== undefined && press?.holdsPending !== true) {
165
+ earliest = earlier_(earliest, this.pending_.deadline);
166
+ }
167
+ return earliest;
168
+ }
169
+ /**
170
+ * Starts following `down`; `false` when ignored: another pointer is down
171
+ * (which withdraws the tap of the one followed, unless it is that very
172
+ * pointer, which changes nothing), or a button not accepted.
173
+ *
174
+ * @throws {RangeError} For a non-finite field.
175
+ */
176
+ press(down) {
177
+ assertSample_(down);
178
+ assertInteger(down.button, "button");
179
+ const current = this.press_;
180
+ if (current !== undefined) {
181
+ if (current.pointerId !== down.pointerId) {
182
+ // Another pointer's time is on its own line: never before the press's.
183
+ const at = Math.max(down.time, current.time);
184
+ this.drain_(at, false);
185
+ this.withdrawTap_(current, at);
186
+ }
187
+ return false;
188
+ }
189
+ if (!this.buttons_.includes(down.button)) {
190
+ return false;
191
+ }
192
+ this.drain_(down.time, false);
193
+ const pending = this.pending_;
194
+ const holdsPending = pending !== undefined && this.isSecondTap_(pending, down);
195
+ if (pending !== undefined && !holdsPending) {
196
+ this.settlePending_(down.time);
197
+ }
198
+ this.press_ = {
199
+ pointerId: down.pointerId,
200
+ kind: down.kind,
201
+ button: down.button,
202
+ startX: down.x,
203
+ startY: down.y,
204
+ startTime: down.time,
205
+ x: down.x,
206
+ y: down.y,
207
+ time: down.time,
208
+ isTapCandidate: true,
209
+ isDragging: false,
210
+ isAbandoned: false,
211
+ longPressFired: false,
212
+ holdsPending,
213
+ axis: undefined,
214
+ lastDragX: down.x,
215
+ lastDragY: down.y,
216
+ shiftKey: down.shiftKey === true,
217
+ altKey: down.altKey === true,
218
+ ctrlKey: down.ctrlKey === true,
219
+ metaKey: down.metaKey === true,
220
+ };
221
+ this.tracker_.reset();
222
+ this.tracker_.add(down.time, down.x, down.y);
223
+ return true;
224
+ }
225
+ /**
226
+ * A drag update once past the slop; `undefined` before, after an abandon, and
227
+ * for another pointer. The first update is the `start`, counted from where
228
+ * the slop was crossed unless `dragFrom` is `press`.
229
+ *
230
+ * @throws {RangeError} For a non-finite field, or a time before the pointer's
231
+ * last one.
232
+ */
233
+ move(sample) {
234
+ assertSample_(sample);
235
+ const press = this.press_;
236
+ if (press === undefined || press.pointerId !== sample.pointerId) {
237
+ return undefined;
238
+ }
239
+ this.checkTime_(press, sample.time);
240
+ this.drain_(sample.time, false);
241
+ this.follow_(press, sample);
242
+ if (press.isAbandoned) {
243
+ return undefined;
244
+ }
245
+ if (press.isDragging) {
246
+ const deltaX = sample.x - press.lastDragX;
247
+ const deltaY = sample.y - press.lastDragY;
248
+ press.lastDragX = sample.x;
249
+ press.lastDragY = sample.y;
250
+ return this.update_("move", press, deltaX, deltaY, ZERO_VELOCITY_, 0, 0);
251
+ }
252
+ return this.startDrag_(press, sample);
253
+ }
254
+ /**
255
+ * Ends the press of the pointer and says what it was. The release is a
256
+ * movement like any other: one past the slop that no `move` reported is a
257
+ * drag that starts and ends at once, its `end` update the only one (carrying
258
+ * what the `start` would have: no delta, or the whole movement for `dragFrom:
259
+ * "press"`), and along the other axis of a fixed one it abandons the press.
260
+ *
261
+ * @throws {RangeError} For a non-finite field, or a time before the pointer's
262
+ * last one.
263
+ */
264
+ release(sample) {
265
+ assertSample_(sample);
266
+ const press = this.press_;
267
+ if (press === undefined || press.pointerId !== sample.pointerId) {
268
+ return { kind: "ignored" };
269
+ }
270
+ this.checkTime_(press, sample.time);
271
+ this.drain_(sample.time, false);
272
+ this.follow_(press, sample);
273
+ const started = press.isDragging || press.isAbandoned
274
+ ? undefined
275
+ : this.startDrag_(press, sample);
276
+ this.press_ = undefined;
277
+ if (press.isDragging) {
278
+ const velocity = this.tracker_.velocity(sample.time);
279
+ const deltaX = started?.deltaX ?? sample.x - press.lastDragX;
280
+ const deltaY = started?.deltaY ?? sample.y - press.lastDragY;
281
+ let swipeX = 0;
282
+ let swipeY = 0;
283
+ if (this.swipe_ !== undefined) {
284
+ swipeX =
285
+ press.axis === "y"
286
+ ? 0
287
+ : swipeAlong_(sample.x - press.startX, velocity.x, this.swipe_);
288
+ swipeY =
289
+ press.axis === "x"
290
+ ? 0
291
+ : swipeAlong_(sample.y - press.startY, velocity.y, this.swipe_);
292
+ }
293
+ return {
294
+ kind: "drag",
295
+ update: this.update_("end", press, deltaX, deltaY, velocity, swipeX, swipeY),
296
+ };
297
+ }
298
+ const tap = {
299
+ pointerId: press.pointerId,
300
+ kind: press.kind,
301
+ button: press.button,
302
+ x: sample.x,
303
+ y: sample.y,
304
+ time: sample.time,
305
+ };
306
+ if (press.longPressFired) {
307
+ return { kind: "long-press-end", tap };
308
+ }
309
+ if (!press.isTapCandidate ||
310
+ sample.time - press.startTime > this.tapMaxDuration_) {
311
+ this.releaseHold_(press, sample.time);
312
+ return { kind: "none" };
313
+ }
314
+ if (this.doubleTap_ === undefined) {
315
+ return { kind: "single-tap", tap };
316
+ }
317
+ if (press.holdsPending) {
318
+ this.pending_ = undefined;
319
+ return { kind: "double-tap", tap };
320
+ }
321
+ const deadline = sample.time + this.doubleTap_.interval;
322
+ this.pending_ = { tap, deadline };
323
+ return { kind: "tap", tap, deadline };
324
+ }
325
+ /**
326
+ * Abandons the press, as on `pointercancel`; a `cancel` update when a drag
327
+ * was under way. Without `pointerId`, whichever is down.
328
+ */
329
+ cancel(pointerId) {
330
+ if (pointerId !== undefined) {
331
+ assertInteger(pointerId, "pointerId");
332
+ }
333
+ const press = this.press_;
334
+ if (press === undefined ||
335
+ (pointerId !== undefined && press.pointerId !== pointerId)) {
336
+ return undefined;
337
+ }
338
+ this.press_ = undefined;
339
+ this.releaseHold_(press, press.time);
340
+ return press.isDragging
341
+ ? this.update_("cancel", press, 0, 0, ZERO_VELOCITY_, 0, 0)
342
+ : undefined;
343
+ }
344
+ /**
345
+ * A single tap whose interval has passed, or a long press whose delay has;
346
+ * each reported once, once `time` has reached the moment it fell due (a
347
+ * `long-press` carries that moment as its time). Call it again until it
348
+ * reports `none`: several things can be due at once.
349
+ *
350
+ * @throws {RangeError} For a non-finite `time`, or one before the clock of
351
+ * the press that is down; nothing changes then.
352
+ */
353
+ resolve(time) {
354
+ assertFinite(time, "time");
355
+ const press = this.press_;
356
+ if (press !== undefined) {
357
+ this.checkTime_(press, time);
358
+ }
359
+ this.drain_(time, true);
360
+ const front = this.queue_.front();
361
+ if (front === undefined || front.at > time) {
362
+ return NO_RESOLUTION_;
363
+ }
364
+ this.queue_.dequeue();
365
+ if (this.queue_.count() === 0) {
366
+ this.lastQueuedAt_ = Number.NEGATIVE_INFINITY;
367
+ }
368
+ return front.resolution;
369
+ }
370
+ /**
371
+ * The platform signalled a long press (a `contextmenu` during a still touch
372
+ * or pen press): a `long-press` now if the press is still a candidate (long
373
+ * press on, within the slop, not yet fired); `none` otherwise.
374
+ *
375
+ * @throws {RangeError} For a non-finite `time`, or one before the clock of
376
+ * the press that is down; nothing changes then.
377
+ */
378
+ signalLongPress(time) {
379
+ assertFinite(time, "time");
380
+ const press = this.press_;
381
+ if (press === undefined) {
382
+ return NO_RESOLUTION_;
383
+ }
384
+ this.checkTime_(press, time);
385
+ this.drain_(time, false);
386
+ if (this.longPressDelay_ === undefined ||
387
+ !press.isTapCandidate ||
388
+ press.longPressFired) {
389
+ return NO_RESOLUTION_;
390
+ }
391
+ this.markLongPress_(press, time);
392
+ return { kind: "long-press", tap: this.tapOf_(press, time) };
393
+ }
394
+ checkTime_(press, time) {
395
+ if (time < press.time) {
396
+ throw new RangeError(`time must not go backwards for the press, got ${time} after ${press.time}`);
397
+ }
398
+ }
399
+ /**
400
+ * Settles, in the order they fell due, what fell due before `time` (at it,
401
+ * too, when `inclusive`): a tap whose interval ended, a long press whose
402
+ * delay passed, a press held for a second tap that can no longer be a tap.
403
+ * Each moves the press's clock to the moment it fell due.
404
+ */
405
+ drain_(time, inclusive) {
406
+ for (;;) {
407
+ const press = this.press_;
408
+ const pending = this.pending_;
409
+ let at = Number.POSITIVE_INFINITY;
410
+ let next = 0;
411
+ if (pending !== undefined && press?.holdsPending !== true) {
412
+ at = pending.deadline;
413
+ next = 1;
414
+ }
415
+ if (press?.isTapCandidate === true &&
416
+ this.longPressDelay_ !== undefined &&
417
+ !press.longPressFired &&
418
+ press.startTime + this.longPressDelay_ < at) {
419
+ at = press.startTime + this.longPressDelay_;
420
+ next = 2;
421
+ }
422
+ if (press?.holdsPending === true &&
423
+ Number.isFinite(this.tapMaxDuration_) &&
424
+ this.holdExpiry_(press) < at) {
425
+ at = this.holdExpiry_(press);
426
+ next = 3;
427
+ }
428
+ if (next === 0 || (inclusive ? at > time : at >= time)) {
429
+ return;
430
+ }
431
+ if (next === 1) {
432
+ this.settlePending_(at);
433
+ }
434
+ else if (next === 2) {
435
+ this.markLongPress_(press, at);
436
+ this.enqueue_({ kind: "long-press", tap: this.tapOf_(press, at) }, at);
437
+ }
438
+ else {
439
+ this.releaseHold_(press, at);
440
+ press.time = Math.max(press.time, at);
441
+ }
442
+ }
443
+ }
444
+ /**
445
+ * The first instant a press can no longer be a tap: a release exactly at
446
+ * `tapMaxDuration` still is one.
447
+ */
448
+ holdExpiry_(press) {
449
+ return nextAfter(press.startTime + this.tapMaxDuration_, Number.POSITIVE_INFINITY);
450
+ }
451
+ tapOf_(press, time) {
452
+ return {
453
+ pointerId: press.pointerId,
454
+ kind: press.kind,
455
+ button: press.button,
456
+ x: press.x,
457
+ y: press.y,
458
+ time,
459
+ };
460
+ }
461
+ follow_(press, sample) {
462
+ press.x = sample.x;
463
+ press.y = sample.y;
464
+ press.time = sample.time;
465
+ press.shiftKey = sample.shiftKey === true;
466
+ press.altKey = sample.altKey === true;
467
+ press.ctrlKey = sample.ctrlKey === true;
468
+ press.metaKey = sample.metaKey === true;
469
+ this.tracker_.add(sample.time, sample.x, sample.y);
470
+ }
471
+ /**
472
+ * The drag the followed pointer's position starts, if it is past the slop:
473
+ * its `start` update; `undefined` within the slop, and when the press is
474
+ * abandoned for running along the other axis of a fixed one.
475
+ */
476
+ startDrag_(press, sample) {
477
+ const movementX = sample.x - press.startX;
478
+ const movementY = sample.y - press.startY;
479
+ if (isWithinSlop_(movementX, movementY, slopOf_(this.slop_, press.kind))) {
480
+ return undefined;
481
+ }
482
+ const axis = this.axisOfFirstMovement_(movementX, movementY);
483
+ if (axis === null) {
484
+ press.isAbandoned = true;
485
+ this.withdrawTap_(press, sample.time);
486
+ return undefined;
487
+ }
488
+ press.isDragging = true;
489
+ press.axis = axis;
490
+ this.withdrawTap_(press, sample.time);
491
+ press.lastDragX = sample.x;
492
+ press.lastDragY = sample.y;
493
+ const fromPress = this.dragFrom_ === "press";
494
+ return this.update_("start", press, fromPress ? movementX : 0, fromPress ? movementY : 0, ZERO_VELOCITY_, 0, 0);
495
+ }
496
+ /** Whether `down` lands in time and place to be the second tap of `pending`. */
497
+ isSecondTap_(pending, down) {
498
+ const doubleTap = this.doubleTap_;
499
+ if (doubleTap === undefined) {
500
+ return false;
501
+ }
502
+ const elapsed = down.time - pending.tap.time;
503
+ return (elapsed >= doubleTap.minInterval &&
504
+ elapsed <= doubleTap.interval &&
505
+ compareLength_(down.x - pending.tap.x, down.y - pending.tap.y, doubleTap.slop) <= 0);
506
+ }
507
+ /** `undefined` for no axis, `null` for a press abandoned on the wrong axis. */
508
+ axisOfFirstMovement_(movementX, movementY) {
509
+ const horizontal = Math.abs(movementX);
510
+ const vertical = Math.abs(movementY);
511
+ switch (this.axisOption_) {
512
+ case "x":
513
+ return vertical > horizontal ? null : "x";
514
+ case "y":
515
+ return horizontal > vertical ? null : "y";
516
+ case "lock":
517
+ return vertical > horizontal ? "y" : "x";
518
+ default:
519
+ return undefined;
520
+ }
521
+ }
522
+ /** The press is no longer a tap: nor a long press, nor a second tap. */
523
+ withdrawTap_(press, time) {
524
+ press.isTapCandidate = false;
525
+ this.releaseHold_(press, time);
526
+ }
527
+ /** The first tap this press held back can no longer become a double tap. */
528
+ releaseHold_(press, time) {
529
+ if (press.holdsPending) {
530
+ press.holdsPending = false;
531
+ this.settlePending_(time);
532
+ }
533
+ }
534
+ settlePending_(time) {
535
+ const pending = this.pending_;
536
+ if (pending === undefined) {
537
+ return;
538
+ }
539
+ this.pending_ = undefined;
540
+ this.enqueue_({ kind: "single-tap", tap: pending.tap }, time);
541
+ }
542
+ enqueue_(resolution, at) {
543
+ this.lastQueuedAt_ = Math.max(at, this.lastQueuedAt_);
544
+ this.queue_.enqueue({ resolution, at: this.lastQueuedAt_ });
545
+ }
546
+ /** The press has become a long press: no longer a tap, at `at`. */
547
+ markLongPress_(press, at) {
548
+ press.longPressFired = true;
549
+ this.withdrawTap_(press, at);
550
+ press.time = Math.max(press.time, at);
551
+ }
552
+ update_(phase, press, deltaX, deltaY, velocity, swipeX, swipeY) {
553
+ const alongX = press.axis !== "y";
554
+ const alongY = press.axis !== "x";
555
+ return {
556
+ phase,
557
+ pointerId: press.pointerId,
558
+ kind: press.kind,
559
+ button: press.button,
560
+ axis: press.axis,
561
+ x: press.x,
562
+ y: press.y,
563
+ movementX: alongX ? press.x - press.startX : 0,
564
+ movementY: alongY ? press.y - press.startY : 0,
565
+ deltaX: alongX ? deltaX : 0,
566
+ deltaY: alongY ? deltaY : 0,
567
+ velocityX: alongX ? velocity.x : 0,
568
+ velocityY: alongY ? velocity.y : 0,
569
+ swipeX,
570
+ swipeY,
571
+ time: press.time,
572
+ shiftKey: press.shiftKey,
573
+ altKey: press.altKey,
574
+ ctrlKey: press.ctrlKey,
575
+ metaKey: press.metaKey,
576
+ };
577
+ }
578
+ }
579
+ //# sourceMappingURL=press-gesture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"press-gesture.js","sourceRoot":"","sources":["../../src/press/press-gesture.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,SAAS,GACT,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACN,YAAY,EACZ,cAAc,EACd,aAAa,EACb,OAAO,GACP,MAAM,qBAAqB,CAAC;AAS7B,OAAO,EACN,eAAe,GAEf,MAAM,iCAAiC,CAAC;AA6JzC,MAAM,gBAAgB,GAAsB,CAAC,CAAC,CAAC,CAAC;AAChD,MAAM,4BAA4B,GAAG,GAAG,CAAC;AACzC,MAAM,gCAAgC,GAAG,EAAE,CAAC;AAC5C,MAAM,wBAAwB,GAAG,GAAG,CAAC;AACrC,MAAM,yBAAyB,GAAG,GAAG,CAAC;AACtC,MAAM,2BAA2B,GAAG,EAAE,CAAC;AACvC,MAAM,2BAA2B,GAAG,GAAG,CAAC;AACxC,MAAM,cAAc,GAAa,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAC/D,MAAM,cAAc,GAAoB,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AAKxE,SAAS,iBAAiB,CACzB,MAA8C;IAE9C,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;QAC9C,OAAO,SAAS,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