@ac-kit/ui-gesture 0.0.0-stage → 0.1.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/CHANGELOG.md +107 -0
- package/LICENSE +28 -0
- package/README.md +310 -2
- package/dist/_validate.d.ts +4 -0
- package/dist/_validate.d.ts.map +1 -0
- package/dist/_validate.js +10 -0
- package/dist/_validate.js.map +1 -0
- package/dist/dom/_claim.d.ts +8 -0
- package/dist/dom/_claim.d.ts.map +1 -0
- package/dist/dom/_claim.js +14 -0
- package/dist/dom/_claim.js.map +1 -0
- package/dist/dom/_pointer-engine.d.ts +121 -0
- package/dist/dom/_pointer-engine.d.ts.map +1 -0
- package/dist/dom/_pointer-engine.js +559 -0
- package/dist/dom/_pointer-engine.js.map +1 -0
- package/dist/dom/_press-driver.d.ts +39 -0
- package/dist/dom/_press-driver.d.ts.map +1 -0
- package/dist/dom/_press-driver.js +121 -0
- package/dist/dom/_press-driver.js.map +1 -0
- package/dist/dom/index.d.ts +5 -0
- package/dist/dom/index.d.ts.map +1 -0
- package/dist/dom/index.js +5 -0
- package/dist/dom/index.js.map +1 -0
- package/dist/dom/pointer-binding.d.ts +111 -0
- package/dist/dom/pointer-binding.d.ts.map +1 -0
- package/dist/dom/pointer-binding.js +35 -0
- package/dist/dom/pointer-binding.js.map +1 -0
- package/dist/dom/press-binding.d.ts +29 -0
- package/dist/dom/press-binding.d.ts.map +1 -0
- package/dist/dom/press-binding.js +53 -0
- package/dist/dom/press-binding.js.map +1 -0
- package/dist/dom/transform-binding.d.ts +81 -0
- package/dist/dom/transform-binding.d.ts.map +1 -0
- package/dist/dom/transform-binding.js +349 -0
- package/dist/dom/transform-binding.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/inertia/inertia.d.ts +32 -0
- package/dist/inertia/inertia.d.ts.map +1 -0
- package/dist/inertia/inertia.js +62 -0
- package/dist/inertia/inertia.js.map +1 -0
- package/dist/keys/key-step.d.ts +25 -0
- package/dist/keys/key-step.d.ts.map +1 -0
- package/dist/keys/key-step.js +30 -0
- package/dist/keys/key-step.js.map +1 -0
- package/dist/pointer/_slop.d.ts +26 -0
- package/dist/pointer/_slop.d.ts.map +1 -0
- package/dist/pointer/_slop.js +74 -0
- package/dist/pointer/_slop.js.map +1 -0
- package/dist/pointer/pointer-input.d.ts +61 -0
- package/dist/pointer/pointer-input.d.ts.map +1 -0
- package/dist/pointer/pointer-input.js +6 -0
- package/dist/pointer/pointer-input.js.map +1 -0
- package/dist/press/press-gesture.d.ts +282 -0
- package/dist/press/press-gesture.d.ts.map +1 -0
- package/dist/press/press-gesture.js +579 -0
- package/dist/press/press-gesture.js.map +1 -0
- package/dist/transform/transform-gesture.d.ts +174 -0
- package/dist/transform/transform-gesture.d.ts.map +1 -0
- package/dist/transform/transform-gesture.js +415 -0
- package/dist/transform/transform-gesture.js.map +1 -0
- package/dist/velocity/velocity-tracker.d.ts +69 -0
- package/dist/velocity/velocity-tracker.d.ts.map +1 -0
- package/dist/velocity/velocity-tracker.js +152 -0
- package/dist/velocity/velocity-tracker.js.map +1 -0
- package/dist/wheel/wheel.d.ts +115 -0
- package/dist/wheel/wheel.d.ts.map +1 -0
- package/dist/wheel/wheel.js +162 -0
- package/dist/wheel/wheel.js.map +1 -0
- package/package.json +79 -3
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A {@link PressGesture} on timers. It has one clock, so each time given to it
|
|
3
|
+
* is raised to the latest it has been given or has settled, and what fell due
|
|
4
|
+
* is settled before each event: a late timer never makes an older event throw.
|
|
5
|
+
*/
|
|
6
|
+
export class PressDriver_ {
|
|
7
|
+
gesture;
|
|
8
|
+
sink_;
|
|
9
|
+
latest_ = Number.NEGATIVE_INFINITY;
|
|
10
|
+
timer_ = undefined;
|
|
11
|
+
isDisposed_ = false;
|
|
12
|
+
constructor(gesture, sink_) {
|
|
13
|
+
this.gesture = gesture;
|
|
14
|
+
this.sink_ = sink_;
|
|
15
|
+
}
|
|
16
|
+
get isPressed() {
|
|
17
|
+
return this.gesture.isPressed;
|
|
18
|
+
}
|
|
19
|
+
press(down) {
|
|
20
|
+
const time = this.clamp_(down.time);
|
|
21
|
+
this.flush_(time);
|
|
22
|
+
const accepted = this.gesture.press({ ...down, time });
|
|
23
|
+
this.schedule_();
|
|
24
|
+
return accepted;
|
|
25
|
+
}
|
|
26
|
+
move(sample) {
|
|
27
|
+
const time = this.clamp_(sample.time);
|
|
28
|
+
this.flush_(time);
|
|
29
|
+
const update = this.gesture.move({ ...sample, time });
|
|
30
|
+
this.schedule_();
|
|
31
|
+
if (update !== undefined) {
|
|
32
|
+
this.sink_.notify(() => this.sink_.drag?.(update));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
release(sample) {
|
|
36
|
+
const time = this.clamp_(sample.time);
|
|
37
|
+
this.flush_(time);
|
|
38
|
+
const wasDragging = this.gesture.isDragging;
|
|
39
|
+
const release = this.gesture.release({ ...sample, time });
|
|
40
|
+
this.schedule_();
|
|
41
|
+
switch (release.kind) {
|
|
42
|
+
case "drag": {
|
|
43
|
+
const update = release.update;
|
|
44
|
+
this.sink_.dragEnded();
|
|
45
|
+
if (!wasDragging) {
|
|
46
|
+
// A release past the slop that no move reported: a drag that starts and
|
|
47
|
+
// ends at once. Each call is guarded apart: the start may dispose.
|
|
48
|
+
this.sink_.notify(() => this.sink_.drag?.({ ...update, phase: "start" }));
|
|
49
|
+
}
|
|
50
|
+
this.sink_.notify(() => this.sink_.drag?.(update));
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
case "single-tap":
|
|
54
|
+
this.sink_.notify(() => this.sink_.tap?.(release.tap));
|
|
55
|
+
break;
|
|
56
|
+
case "double-tap":
|
|
57
|
+
this.sink_.notify(() => this.sink_.doubleTap?.(release.tap));
|
|
58
|
+
break;
|
|
59
|
+
default:
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
cancel(pointerId) {
|
|
64
|
+
const update = this.gesture.cancel(pointerId);
|
|
65
|
+
this.schedule_();
|
|
66
|
+
if (update !== undefined) {
|
|
67
|
+
this.sink_.notify(() => this.sink_.drag?.(update));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** A `contextmenu` during a still touch or pen press. */
|
|
71
|
+
signalLongPress(time) {
|
|
72
|
+
const at = this.clamp_(time);
|
|
73
|
+
this.flush_(at);
|
|
74
|
+
this.dispatch_(this.gesture.signalLongPress(at));
|
|
75
|
+
this.schedule_();
|
|
76
|
+
}
|
|
77
|
+
dispose() {
|
|
78
|
+
this.isDisposed_ = true;
|
|
79
|
+
clearTimeout(this.timer_);
|
|
80
|
+
this.timer_ = undefined;
|
|
81
|
+
}
|
|
82
|
+
clamp_(time) {
|
|
83
|
+
this.latest_ = Math.max(this.latest_, time);
|
|
84
|
+
return this.latest_;
|
|
85
|
+
}
|
|
86
|
+
flush_(time) {
|
|
87
|
+
for (;;) {
|
|
88
|
+
const resolution = this.gesture.resolve(time);
|
|
89
|
+
if (resolution.kind === "none") {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
this.dispatch_(resolution);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
dispatch_(resolution) {
|
|
96
|
+
if (resolution.kind === "single-tap") {
|
|
97
|
+
const tap = resolution.tap;
|
|
98
|
+
this.sink_.notify(() => this.sink_.tap?.(tap));
|
|
99
|
+
}
|
|
100
|
+
else if (resolution.kind === "long-press") {
|
|
101
|
+
const tap = resolution.tap;
|
|
102
|
+
this.sink_.notify(() => this.sink_.longPress?.(tap));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
schedule_() {
|
|
106
|
+
clearTimeout(this.timer_);
|
|
107
|
+
this.timer_ = undefined;
|
|
108
|
+
const deadline = this.gesture.deadline;
|
|
109
|
+
if (deadline === undefined || this.isDisposed_) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
this.timer_ = setTimeout(() => {
|
|
113
|
+
this.timer_ = undefined;
|
|
114
|
+
this.sink_.notify(() => {
|
|
115
|
+
this.flush_(this.clamp_(Math.max(deadline, performance.now())));
|
|
116
|
+
});
|
|
117
|
+
this.schedule_();
|
|
118
|
+
}, Math.max(0, deadline - performance.now()));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=_press-driver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_press-driver.js","sourceRoot":"","sources":["../../src/dom/_press-driver.ts"],"names":[],"mappings":"AAwBA;;;;GAIG;AACH,MAAM,OAAO,YAAY;IAMd,OAAO;IACC,KAAK;IANf,OAAO,GAAG,MAAM,CAAC,iBAAiB,CAAC;IACnC,MAAM,GAA8C,SAAS,CAAC;IAC9D,WAAW,GAAG,KAAK,CAAC;IAE5B,YACU,OAAqB,EACb,KAAiB;uBADzB,OAAO;qBACC,KAAK;IACpB,CAAC;IAEJ,IAAI,SAAS;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,IAAiB;QACtB,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAClB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACvD,IAAI,CAAC,SAAS,EAAE,CAAC;QAEjB,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED,IAAI,CAAC,MAAqB;QACzB,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAClB,MAAM,MAAM,GAAG,IAA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GAAG,SAAS,CAAC;YACxB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE;gBACtB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;YACjE,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,SAAS,EAAE,CAAC;QAClB,CAAC,EACD,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,CACzC,CAAC;IACH,CAAC;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dom/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dom/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { Callable, Predicate } from "@ac-kit/core";
|
|
2
|
+
import type { PointerDown, PointerSample } from "../pointer/pointer-input.js";
|
|
3
|
+
/** An element a binding listens on. */
|
|
4
|
+
export type GestureElement = HTMLElement | SVGElement;
|
|
5
|
+
/**
|
|
6
|
+
* A live binding: dispose it, or abort its signal, to remove every listener,
|
|
7
|
+
* timer and capture.
|
|
8
|
+
*/
|
|
9
|
+
export type GestureBinding = Disposable & {
|
|
10
|
+
/** Whether a gesture is under way. */
|
|
11
|
+
readonly isActive: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* The element's box measured for the gesture under way or the last one: the
|
|
14
|
+
* frame of `element` coordinates.
|
|
15
|
+
*/
|
|
16
|
+
readonly box: DOMRectReadOnly | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Abandons the gesture under way, as a `pointercancel` would: handlers get
|
|
19
|
+
* its `cancel`.
|
|
20
|
+
*/
|
|
21
|
+
cancel(): void;
|
|
22
|
+
};
|
|
23
|
+
/** Options shared by every binding. */
|
|
24
|
+
export type PointerBindingOptions = {
|
|
25
|
+
/** Aborting it disposes the binding. Already aborted: nothing is bound. */
|
|
26
|
+
readonly signal?: AbortSignal;
|
|
27
|
+
/**
|
|
28
|
+
* `element` (default): relative to the element's border box, measured by
|
|
29
|
+
* `getBoundingClientRect()` at the first press of a gesture and at each
|
|
30
|
+
* wheel, trackpad or hover event; `client`: `clientX` and `clientY`.
|
|
31
|
+
*/
|
|
32
|
+
readonly coordinates?: "element" | "client";
|
|
33
|
+
/** Capture each accepted pointer at its press. Default true. */
|
|
34
|
+
readonly capture?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Feed `getCoalescedEvents()` (secure contexts only) to the moves and the
|
|
37
|
+
* velocity, instead of the parent event alone. Default false.
|
|
38
|
+
*/
|
|
39
|
+
readonly coalesced?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Whether a `pointerdown` may start a gesture (a strip inside a swipe surface
|
|
42
|
+
* may not). Default: all.
|
|
43
|
+
*/
|
|
44
|
+
readonly accept?: Predicate<[event: PointerEvent]>;
|
|
45
|
+
/**
|
|
46
|
+
* What to do with a `pointerdown` an inner surface already claimed: `skip`
|
|
47
|
+
* (default) ignores it; `share` follows it too, through bubbling, never
|
|
48
|
+
* capturing it.
|
|
49
|
+
*/
|
|
50
|
+
readonly claimed?: "skip" | "share";
|
|
51
|
+
/**
|
|
52
|
+
* Focus the element at a press, without scrolling, so its keys work next.
|
|
53
|
+
* Default false.
|
|
54
|
+
*/
|
|
55
|
+
readonly focusOnPress?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Cancel `dragstart` and `selectstart` on the element while an accepted press
|
|
58
|
+
* is down. Default true.
|
|
59
|
+
*/
|
|
60
|
+
readonly preventDefaultActions?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Cancel `contextmenu` on the element (right-button drags). Default false;
|
|
63
|
+
* long press on implies it for touch and pen presses.
|
|
64
|
+
*/
|
|
65
|
+
readonly preventContextMenu?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* A `touch-action` set on the element at bind and restored at dispose; it
|
|
68
|
+
* must be in place before the first `pointerdown`. Default: left as styled
|
|
69
|
+
* (`pan-x pan-y pinch-zoom` for a cooperative surface).
|
|
70
|
+
*/
|
|
71
|
+
readonly touchAction?: string;
|
|
72
|
+
};
|
|
73
|
+
/** Hover of a mouse or pen with no button down; touch never hovers. */
|
|
74
|
+
export type HoverHandlers = {
|
|
75
|
+
readonly onHover?: Callable<[sample: PointerSample, event: PointerEvent]>;
|
|
76
|
+
/** The hovering pointer left, pressed, or was cancelled. */
|
|
77
|
+
readonly onHoverEnd?: Callable<[
|
|
78
|
+
pointerId: number,
|
|
79
|
+
event: PointerEvent | undefined
|
|
80
|
+
]>;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Raw pointers, normalised. Handlers are read at each call, so a caller may
|
|
84
|
+
* keep one object and update its members.
|
|
85
|
+
*/
|
|
86
|
+
export type PointerHandlers = HoverHandlers & {
|
|
87
|
+
readonly onDown?: Callable<[down: PointerDown, event: PointerEvent]>;
|
|
88
|
+
readonly onMove?: Callable<[sample: PointerSample, event: PointerEvent]>;
|
|
89
|
+
/**
|
|
90
|
+
* A release; also a tracked mouse or pen moving with no button (a release
|
|
91
|
+
* unseen), at the last position.
|
|
92
|
+
*/
|
|
93
|
+
readonly onUp?: Callable<[sample: PointerSample, event: PointerEvent]>;
|
|
94
|
+
/**
|
|
95
|
+
* A `pointercancel`, a capture lost before the release, or
|
|
96
|
+
* {@link GestureBinding.cancel} (no event).
|
|
97
|
+
*/
|
|
98
|
+
readonly onCancel?: Callable<[
|
|
99
|
+
pointerId: number,
|
|
100
|
+
event: PointerEvent | undefined
|
|
101
|
+
]>;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* The plumbing every recogniser shares, for callers that track pointers
|
|
105
|
+
* themselves (an on-screen keyboard): normalised samples, capture, claims, a
|
|
106
|
+
* single end per pointer whatever ends it, cancellation, hover. No recognition.
|
|
107
|
+
* Without `onDown` it accepts no press and claims nothing (a hover-only binding
|
|
108
|
+
* beside another one).
|
|
109
|
+
*/
|
|
110
|
+
export declare function bindPointers(element: GestureElement, handlers: PointerHandlers, options?: PointerBindingOptions): GestureBinding;
|
|
111
|
+
//# sourceMappingURL=pointer-binding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointer-binding.d.ts","sourceRoot":"","sources":["../../src/dom/pointer-binding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG9E,uCAAuC;AACvC,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,UAAU,CAAC;AAEtD;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG;IACzC,sCAAsC;IACtC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,eAAe,GAAG,SAAS,CAAC;IAC1C;;;OAGG;IACH,MAAM,IAAI,IAAI,CAAC;CACf,CAAC;AAEF,uCAAuC;AACvC,MAAM,MAAM,qBAAqB,GAAG;IACnC,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,WAAW,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;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC;IACvE;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAC3B;QAAC,SAAS,EAAE,MAAM;QAAE,KAAK,EAAE,YAAY,GAAG,SAAS;KAAC,CACpD,CAAC;CACF,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC3B,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,eAAe,EACzB,OAAO,CAAC,EAAE,qBAAqB,GAC7B,cAAc,CA+BhB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { PointerEngine_ } from "./_pointer-engine.js";
|
|
2
|
+
/**
|
|
3
|
+
* The plumbing every recogniser shares, for callers that track pointers
|
|
4
|
+
* themselves (an on-screen keyboard): normalised samples, capture, claims, a
|
|
5
|
+
* single end per pointer whatever ends it, cancellation, hover. No recognition.
|
|
6
|
+
* Without `onDown` it accepts no press and claims nothing (a hover-only binding
|
|
7
|
+
* beside another one).
|
|
8
|
+
*/
|
|
9
|
+
export function bindPointers(element, handlers, options) {
|
|
10
|
+
const engine = new PointerEngine_(element, {
|
|
11
|
+
down: () => handlers.onDown !== undefined,
|
|
12
|
+
// After the pointer is tracked, so a `cancel()` in the handler ends it.
|
|
13
|
+
accepted: (down, event) => {
|
|
14
|
+
handlers.onDown?.(down, event);
|
|
15
|
+
},
|
|
16
|
+
move: (sample, event) => {
|
|
17
|
+
handlers.onMove?.(sample, event);
|
|
18
|
+
},
|
|
19
|
+
up: (sample, event) => {
|
|
20
|
+
handlers.onUp?.(sample, event);
|
|
21
|
+
},
|
|
22
|
+
cancel: (pointerId, event) => {
|
|
23
|
+
handlers.onCancel?.(pointerId, event);
|
|
24
|
+
},
|
|
25
|
+
}, options ?? {}, {
|
|
26
|
+
impliesContextMenuPrevention: false,
|
|
27
|
+
suppressClickAfterDrag: false,
|
|
28
|
+
hover: handlers,
|
|
29
|
+
});
|
|
30
|
+
if (engine.begin()) {
|
|
31
|
+
engine.start();
|
|
32
|
+
}
|
|
33
|
+
return engine;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=pointer-binding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointer-binding.js","sourceRoot":"","sources":["../../src/dom/pointer-binding.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAyGtD;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAC3B,OAAuB,EACvB,QAAyB,EACzB,OAA+B;IAE/B,MAAM,MAAM,GAAG,IAAI,cAAc,CAChC,OAAO,EACP;QACC,IAAI,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,KAAK,SAAS;QACzC,wEAAwE;QACxE,QAAQ,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YACzB,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAChC,CAAC;QACD,IAAI,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YACvB,QAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAClC,CAAC;QACD,EAAE,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YACrB,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAChC,CAAC;QACD,MAAM,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE;YAC5B,QAAQ,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QACvC,CAAC;KACD,EACD,OAAO,IAAI,EAAE,EACb;QACC,4BAA4B,EAAE,KAAK;QACnC,sBAAsB,EAAE,KAAK;QAC7B,KAAK,EAAE,QAAQ;KACf,CACD,CAAC;IACF,IAAI,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;QACpB,MAAM,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Callable } from "@ac-kit/core";
|
|
2
|
+
import type { PointerDown, TapEvent } from "../pointer/pointer-input.js";
|
|
3
|
+
import { type DragUpdate, type PressGestureOptions } from "../press/press-gesture.js";
|
|
4
|
+
import type { GestureBinding, GestureElement, HoverHandlers, PointerBindingOptions } from "./pointer-binding.js";
|
|
5
|
+
export type PressBindingHandlers = HoverHandlers & {
|
|
6
|
+
/**
|
|
7
|
+
* At once on an accepted press, before any recognition (a slider jumps
|
|
8
|
+
* there).
|
|
9
|
+
*/
|
|
10
|
+
readonly onPress?: Callable<[down: PointerDown]>;
|
|
11
|
+
readonly onDrag?: Callable<[update: DragUpdate]>;
|
|
12
|
+
/** A settled single tap: after the double-tap interval when `doubleTap` is on. */
|
|
13
|
+
readonly onTap?: Callable<[tap: TapEvent]>;
|
|
14
|
+
readonly onDoubleTap?: Callable<[tap: TapEvent]>;
|
|
15
|
+
readonly onLongPress?: Callable<[tap: TapEvent]>;
|
|
16
|
+
};
|
|
17
|
+
export type PressBindingOptions = PointerBindingOptions & PressGestureOptions & {
|
|
18
|
+
/**
|
|
19
|
+
* Swallow the one `click` that follows a drag (not a keyboard click),
|
|
20
|
+
* unless a press disarms it first. Default true.
|
|
21
|
+
*/
|
|
22
|
+
readonly suppressClickAfterDrag?: boolean;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A {@link PressGesture} on an element, its deadlines on timers cleared at
|
|
26
|
+
* dispose.
|
|
27
|
+
*/
|
|
28
|
+
export declare function bindPressGesture(element: GestureElement, handlers: PressBindingHandlers, options?: PressBindingOptions): GestureBinding;
|
|
29
|
+
//# sourceMappingURL=press-binding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"press-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PressGesture, } from "../press/press-gesture.js";
|
|
2
|
+
import { PointerEngine_ } from "./_pointer-engine.js";
|
|
3
|
+
import { PressDriver_ } from "./_press-driver.js";
|
|
4
|
+
/**
|
|
5
|
+
* A {@link PressGesture} on an element, its deadlines on timers cleared at
|
|
6
|
+
* dispose.
|
|
7
|
+
*/
|
|
8
|
+
export function bindPressGesture(element, handlers, options) {
|
|
9
|
+
const gesture = new PressGesture(options);
|
|
10
|
+
const hasLongPress = options?.longPress !== undefined && options.longPress !== false;
|
|
11
|
+
const driver = new PressDriver_(gesture, {
|
|
12
|
+
drag: (update) => handlers.onDrag?.(update),
|
|
13
|
+
tap: (tap) => handlers.onTap?.(tap),
|
|
14
|
+
doubleTap: (tap) => handlers.onDoubleTap?.(tap),
|
|
15
|
+
longPress: (tap) => handlers.onLongPress?.(tap),
|
|
16
|
+
dragEnded: () => {
|
|
17
|
+
engine.armClickSuppression();
|
|
18
|
+
},
|
|
19
|
+
notify: (action) => {
|
|
20
|
+
engine.notify(action);
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
const engine = new PointerEngine_(element, {
|
|
24
|
+
down: (down) => driver.press(down),
|
|
25
|
+
accepted: (down) => handlers.onPress?.(down),
|
|
26
|
+
move: (sample) => {
|
|
27
|
+
driver.move(sample);
|
|
28
|
+
},
|
|
29
|
+
up: (sample) => {
|
|
30
|
+
driver.release(sample);
|
|
31
|
+
},
|
|
32
|
+
cancel: (pointerId) => {
|
|
33
|
+
driver.cancel(pointerId);
|
|
34
|
+
},
|
|
35
|
+
contextMenu: (event) => {
|
|
36
|
+
if (hasLongPress) {
|
|
37
|
+
driver.signalLongPress(event.timeStamp);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
}, options ?? {}, {
|
|
41
|
+
impliesContextMenuPrevention: hasLongPress,
|
|
42
|
+
suppressClickAfterDrag: options?.suppressClickAfterDrag !== false,
|
|
43
|
+
hover: handlers,
|
|
44
|
+
});
|
|
45
|
+
if (engine.begin()) {
|
|
46
|
+
engine.onDispose(() => {
|
|
47
|
+
driver.dispose();
|
|
48
|
+
});
|
|
49
|
+
engine.start();
|
|
50
|
+
}
|
|
51
|
+
return engine;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=press-binding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"press-binding.js","sourceRoot":"","sources":["../../src/dom/press-binding.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,YAAY,GAGZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA8BlD;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC/B,OAAuB,EACvB,QAA8B,EAC9B,OAA6B;IAE7B,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;IAC1C,MAAM,YAAY,GACjB,OAAO,EAAE,SAAS,KAAK,SAAS,IAAI,OAAO,CAAC,SAAS,KAAK,KAAK,CAAC;IACjE,MAAM,MAAM,GAAiB,IAAI,YAAY,CAAC,OAAO,EAAE;QACtD,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC;QAC3C,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC;QACnC,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC;QAC/C,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC;QAC/C,SAAS,EAAE,GAAG,EAAE;YACf,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAC9B,CAAC;QACD,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE;YAClB,MAAM,CAAC,MAA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.js";
|
|
3
|
+
import type { TapEvent } from "../pointer/pointer-input.js";
|
|
4
|
+
import { type DoubleTapOptions } from "../press/press-gesture.js";
|
|
5
|
+
import { type TransformGestureOptions, type TransformStep, type TransformUpdate } from "../transform/transform-gesture.js";
|
|
6
|
+
import { type WheelTransformOptions } from "../wheel/wheel.js";
|
|
7
|
+
import type { GestureBinding, GestureElement, HoverHandlers, PointerBindingOptions } from "./pointer-binding.js";
|
|
8
|
+
/**
|
|
9
|
+
* What a cooperative surface tells the person: use a modifier with the wheel,
|
|
10
|
+
* or two fingers.
|
|
11
|
+
*/
|
|
12
|
+
export type CooperativeHint = "wheel" | "touch";
|
|
13
|
+
export type TransformBindingHandlers = HoverHandlers & {
|
|
14
|
+
readonly onTransform?: Callable<[update: TransformUpdate]>;
|
|
15
|
+
/**
|
|
16
|
+
* Wheel and trackpad steps; present when the binding is made, the wheel
|
|
17
|
+
* listener is not passive and cancels the page's scroll or zoom for each step
|
|
18
|
+
* `acceptStep` accepts (never an unmodified wheel when cooperative).
|
|
19
|
+
*/
|
|
20
|
+
readonly onStep?: Callable<[step: TransformStep]>;
|
|
21
|
+
/**
|
|
22
|
+
* Navigation keys while the element itself is focused; present, the default
|
|
23
|
+
* of a key step `acceptKeyStep` accepts is cancelled.
|
|
24
|
+
*/
|
|
25
|
+
readonly onKeyStep?: Callable<[step: KeyStep, event: KeyboardEvent]>;
|
|
26
|
+
/**
|
|
27
|
+
* Taps of a single pointer that did not start a transform; present when the
|
|
28
|
+
* binding is made.
|
|
29
|
+
*/
|
|
30
|
+
readonly onTap?: Callable<[tap: TapEvent]>;
|
|
31
|
+
/** Present when the binding is made, it turns double-tap recognition on. */
|
|
32
|
+
readonly onDoubleTap?: Callable<[tap: TapEvent]>;
|
|
33
|
+
/**
|
|
34
|
+
* Cooperative mode only: an input left to the page; show the hint for a
|
|
35
|
+
* moment.
|
|
36
|
+
*/
|
|
37
|
+
readonly onCooperativeHint?: Callable<[hint: CooperativeHint]>;
|
|
38
|
+
};
|
|
39
|
+
export type TransformBindingOptions = PointerBindingOptions & TransformGestureOptions & {
|
|
40
|
+
/** How wheel events become steps. Default `{}` (zoom). */
|
|
41
|
+
readonly wheel?: WheelTransformOptions;
|
|
42
|
+
/**
|
|
43
|
+
* Cooperative gestures inside a scrolling page: only a modified wheel acts,
|
|
44
|
+
* and a touch needs two fingers. Expects `touch-action: pan-x pan-y
|
|
45
|
+
* pinch-zoom` on the element. Default false.
|
|
46
|
+
*/
|
|
47
|
+
readonly cooperative?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Safari's `gesture*` events for trackpad pinch and rotation, where the
|
|
50
|
+
* browser has `GestureEvent` (ignored while a touch pointer is down). Each
|
|
51
|
+
* accepted `gesturechange` is cancelled, and the `gestureend` of a sequence
|
|
52
|
+
* that had one; `gesturestart`, which carries no change, never is. Default
|
|
53
|
+
* true.
|
|
54
|
+
*/
|
|
55
|
+
readonly trackpadGestures?: boolean;
|
|
56
|
+
/** Used when `onDoubleTap` is given. */
|
|
57
|
+
readonly doubleTap?: DoubleTapOptions;
|
|
58
|
+
/**
|
|
59
|
+
* Whether the binding acts on a wheel or trackpad step (one that would move
|
|
60
|
+
* nothing, say). A refused step reaches no handler, and its event is
|
|
61
|
+
* neither cancelled nor stopped. Default: every step.
|
|
62
|
+
*/
|
|
63
|
+
readonly acceptStep?: Predicate<[step: TransformStep]>;
|
|
64
|
+
/**
|
|
65
|
+
* Whether the binding acts on a navigation key (an arrow along an axis that
|
|
66
|
+
* does not pan, say). A refused key reaches no handler, and its event is
|
|
67
|
+
* neither cancelled nor stopped. Default: every key step.
|
|
68
|
+
*/
|
|
69
|
+
readonly acceptKeyStep?: Predicate<[step: KeyStep, event: KeyboardEvent]>;
|
|
70
|
+
/**
|
|
71
|
+
* Swallow the one `click` that follows a transform (not a keyboard click),
|
|
72
|
+
* unless a press disarms it first. Default true.
|
|
73
|
+
*/
|
|
74
|
+
readonly suppressClickAfterDrag?: boolean;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* A {@link TransformGesture}, wheel and trackpad steps, navigation keys, taps
|
|
78
|
+
* and hover on one element.
|
|
79
|
+
*/
|
|
80
|
+
export declare function bindTransformGesture(element: GestureElement, handlers: TransformBindingHandlers, options?: TransformBindingOptions): GestureBinding;
|
|
81
|
+
//# sourceMappingURL=transform-binding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-binding.d.ts","sourceRoot":"","sources":["../../src/dom/transform-binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAG7E,OAAO,EAAW,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,KAAK,EAGX,QAAQ,EACR,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAgB,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAEN,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAkB,KAAK,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAG/E,OAAO,KAAK,EACX,cAAc,EACd,cAAc,EACd,aAAa,EACb,qBAAqB,EACrB,MAAM,sBAAsB,CAAC;AAE9B;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,CAAC;AAEhD,MAAM,MAAM,wBAAwB,GAAG,aAAa,GAAG;IACtD,QAAQ,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC;IAC3D;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC;IAClD;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,CAAC,IAAI,EAAE,OAA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