gesturx 1.0.0 → 1.2.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/README.md +17 -1
- package/dist/index.d.ts +192 -0
- package/dist/index.js +627 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.cjs +2 -0
- package/dist/index.umd.cjs.map +1 -0
- package/package.json +12 -1
- package/.github/workflows/publish.yml +0 -17
- package/.prettierrc.json +0 -3
- package/eslint.config.js +0 -18
- package/index.html +0 -13
- package/src/core/index.ts +0 -4
- package/src/core/manager.ts +0 -46
- package/src/core/pan/PanRecognizer.ts +0 -192
- package/src/core/pinch/PinchRecognizer.ts +0 -131
- package/src/core/recognizer/Recognizer.ts +0 -54
- package/src/core/recognizer/RecognizerEvent.ts +0 -39
- package/src/core/recognizer/mapToRecognizerEvent.ts +0 -142
- package/src/core/rotate/RotateRecognizer.ts +0 -115
- package/src/core/swipe/SwipeRecognizer.test.ts +0 -160
- package/src/core/swipe/SwipeRecognizer.ts +0 -82
- package/src/core/swipe/isRecognizedAsSwipe.ts +0 -13
- package/src/core/tap/TapRecognizer.test.ts +0 -567
- package/src/core/tap/TapRecognizer.ts +0 -172
- package/src/core/utils/events.ts +0 -186
- package/src/core/utils/geometry.ts +0 -115
- package/src/core/utils/utils.test.ts +0 -26
- package/src/core/utils/utils.ts +0 -58
- package/src/demo/App.tsx +0 -171
- package/src/demo/DebugBox.tsx +0 -10
- package/src/demo/useManager.ts +0 -40
- package/src/demo/useTap.tsx +0 -87
- package/src/index.css +0 -66
- package/src/main.tsx +0 -14
- package/src/theme.ts +0 -11
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -26
- package/tsconfig.node.json +0 -11
- package/vite.config.ts +0 -38
- package/vitest.config.ts +0 -8
- /package/{public → dist}/vite.svg +0 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,627 @@
|
|
|
1
|
+
var ae = Object.defineProperty;
|
|
2
|
+
var ce = (e, n, t) => n in e ? ae(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
|
|
3
|
+
var w = (e, n, t) => (ce(e, typeof n != "symbol" ? n + "" : n, t), t);
|
|
4
|
+
import { filter as v, NEVER as K, merge as A, BehaviorSubject as le, scan as E, map as h, fromEvent as b, mergeMap as T, defer as ge, of as q, takeUntil as x, endWith as he, switchMap as R, exhaustMap as j, shareReplay as Q, withLatestFrom as Y, first as O, share as M, skipUntil as $e, combineLatest as S, ignoreElements as ue, timer as de, buffer as ve, debounceTime as fe, distinctUntilChanged as z } from "rxjs";
|
|
5
|
+
function Ae(e, n) {
|
|
6
|
+
return Math.sqrt(
|
|
7
|
+
Math.pow(n.x - e.x, 2) + Math.pow(n.y - e.y, 2)
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
function De(e) {
|
|
11
|
+
const n = e.length;
|
|
12
|
+
if (n < 2)
|
|
13
|
+
return 0;
|
|
14
|
+
const t = e.reduce((o, r, p) => o + e.slice(p + 1).reduce((l, a) => l + Ae(r, a), 0), 0), s = n * (n - 1) / 2;
|
|
15
|
+
return t / s;
|
|
16
|
+
}
|
|
17
|
+
function _(e, n) {
|
|
18
|
+
const t = n.x - e.x, s = n.y - e.y;
|
|
19
|
+
return Math.atan2(s, t);
|
|
20
|
+
}
|
|
21
|
+
function ye(e, n) {
|
|
22
|
+
return _(e, n) * (180 / Math.PI);
|
|
23
|
+
}
|
|
24
|
+
function C(e) {
|
|
25
|
+
const n = e.reduce(
|
|
26
|
+
(s, o) => (s.x += o.x, s.y += o.y, s),
|
|
27
|
+
{ x: 0, y: 0 }
|
|
28
|
+
), t = e.length || 1;
|
|
29
|
+
return {
|
|
30
|
+
x: n.x / t,
|
|
31
|
+
y: n.y / t
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function me(e, n) {
|
|
35
|
+
if (e.length !== n.length)
|
|
36
|
+
throw new Error("Initial and new points arrays must have the same length.");
|
|
37
|
+
const t = C(e), s = C(n);
|
|
38
|
+
let o = 0;
|
|
39
|
+
for (let l = 0; l < e.length; l++) {
|
|
40
|
+
const a = _(
|
|
41
|
+
t,
|
|
42
|
+
e[l]
|
|
43
|
+
);
|
|
44
|
+
let c = _(
|
|
45
|
+
s,
|
|
46
|
+
n[l]
|
|
47
|
+
) - a;
|
|
48
|
+
c > Math.PI ? c -= 2 * Math.PI : c < -Math.PI && (c += 2 * Math.PI), o += c;
|
|
49
|
+
}
|
|
50
|
+
const r = o / e.length, p = r * (180 / Math.PI);
|
|
51
|
+
return { radianDelta: r, degreesDelta: p };
|
|
52
|
+
}
|
|
53
|
+
function we(e) {
|
|
54
|
+
return e != null;
|
|
55
|
+
}
|
|
56
|
+
const Pe = (e) => e.length > 0, Me = (e) => e.pipe(v(Pe));
|
|
57
|
+
function Z(e, n, t) {
|
|
58
|
+
const s = C([e]), o = C([n]);
|
|
59
|
+
return Math.abs(o.x - s.x) > t || Math.abs(o.y - s.y) > t;
|
|
60
|
+
}
|
|
61
|
+
const Te = (e) => e != null && e.length ? A(...(e == null ? void 0 : e.map(({ start$: n }) => n)) ?? []) : K, xe = (e, n, t) => {
|
|
62
|
+
const s = e > 0 ? n / e : 0, o = e > 0 ? t / e : 0;
|
|
63
|
+
return {
|
|
64
|
+
velocityX: s,
|
|
65
|
+
velocityY: o
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
class F {
|
|
69
|
+
constructor(n) {
|
|
70
|
+
w(this, "config$", new le({}));
|
|
71
|
+
w(this, "validConfig$", this.config$.pipe(
|
|
72
|
+
v(
|
|
73
|
+
(n) => !!n.container
|
|
74
|
+
)
|
|
75
|
+
));
|
|
76
|
+
this.update(n);
|
|
77
|
+
}
|
|
78
|
+
initialize(n) {
|
|
79
|
+
const t = this.config$.getValue();
|
|
80
|
+
this.config$.next({
|
|
81
|
+
...t,
|
|
82
|
+
...n,
|
|
83
|
+
options: {
|
|
84
|
+
...t.options,
|
|
85
|
+
...n.options
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
update(n) {
|
|
90
|
+
const t = this.config$.getValue();
|
|
91
|
+
this.config$.next({
|
|
92
|
+
...t,
|
|
93
|
+
options: {
|
|
94
|
+
...t.options,
|
|
95
|
+
...n
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const J = (e, n, t, s) => {
|
|
101
|
+
const o = e.x - n.x + t, r = e.y - n.y + s;
|
|
102
|
+
return {
|
|
103
|
+
deltaX: o,
|
|
104
|
+
deltaY: r
|
|
105
|
+
};
|
|
106
|
+
}, W = (e) => {
|
|
107
|
+
const n = (t) => C(
|
|
108
|
+
t.latestActivePointers.length ? t.latestActivePointers : [t.event]
|
|
109
|
+
);
|
|
110
|
+
return e.pipe(
|
|
111
|
+
E(
|
|
112
|
+
(t, s) => {
|
|
113
|
+
var D, m;
|
|
114
|
+
const o = n(s), r = t.center, p = t.deltaX, l = t.deltaY, a = ((D = t.latestActivePointers) == null ? void 0 : D.length) ?? 0, $ = ((m = s.latestActivePointers) == null ? void 0 : m.length) ?? 0, c = [
|
|
115
|
+
"pointerdown",
|
|
116
|
+
"pointercancel",
|
|
117
|
+
"pointerleave",
|
|
118
|
+
"pointerup"
|
|
119
|
+
].includes(s.event.type) && a !== $, i = $ > 0, { deltaX: g, deltaY: d } = c && i ? J(o, o, p, l) : J(o, r, p, l), { degreesDelta: f } = a === $ && a >= 2 && $ >= 2 ? me(
|
|
120
|
+
t.latestActivePointers ?? [],
|
|
121
|
+
s.latestActivePointers ?? []
|
|
122
|
+
) : { degreesDelta: 0 };
|
|
123
|
+
return {
|
|
124
|
+
startTime: (/* @__PURE__ */ new Date()).getTime(),
|
|
125
|
+
...t,
|
|
126
|
+
...s,
|
|
127
|
+
center: o,
|
|
128
|
+
deltaX: g,
|
|
129
|
+
deltaY: d,
|
|
130
|
+
deltaPointersAngle: f
|
|
131
|
+
};
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
deltaX: 0,
|
|
135
|
+
deltaY: 0,
|
|
136
|
+
center: { x: 0, y: 0 },
|
|
137
|
+
latestActivePointers: []
|
|
138
|
+
}
|
|
139
|
+
),
|
|
140
|
+
h((t) => {
|
|
141
|
+
const {
|
|
142
|
+
deltaX: s,
|
|
143
|
+
deltaY: o,
|
|
144
|
+
latestActivePointers: r,
|
|
145
|
+
startTime: p,
|
|
146
|
+
center: l,
|
|
147
|
+
event: a,
|
|
148
|
+
deltaPointersAngle: $
|
|
149
|
+
} = t, c = r ?? [], g = Date.now() - p, { velocityX: d, velocityY: f } = xe(g, s, o), D = De(r);
|
|
150
|
+
return {
|
|
151
|
+
deltaX: s,
|
|
152
|
+
deltaY: o,
|
|
153
|
+
velocityX: d,
|
|
154
|
+
velocityY: f,
|
|
155
|
+
delay: g,
|
|
156
|
+
center: l,
|
|
157
|
+
pointers: c,
|
|
158
|
+
startTime: p,
|
|
159
|
+
event: a,
|
|
160
|
+
deltaPointersAngle: $,
|
|
161
|
+
pointersAverageDistance: D
|
|
162
|
+
};
|
|
163
|
+
})
|
|
164
|
+
);
|
|
165
|
+
};
|
|
166
|
+
function U(e) {
|
|
167
|
+
return (n) => n.pipe(
|
|
168
|
+
v((t) => t.pointerId === e.pointerId)
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
const N = ({
|
|
172
|
+
container: e,
|
|
173
|
+
afterEventReceived: n = (t) => t
|
|
174
|
+
}) => {
|
|
175
|
+
const t = ee({ afterEventReceived: n, container: e }), s = b(e, "pointerup").pipe(
|
|
176
|
+
h(n)
|
|
177
|
+
), o = b(e, "pointermove").pipe(
|
|
178
|
+
h(n)
|
|
179
|
+
), r = b(e, "pointerleave").pipe(
|
|
180
|
+
h(n)
|
|
181
|
+
), p = b(
|
|
182
|
+
e,
|
|
183
|
+
"pointercancel"
|
|
184
|
+
).pipe(h(n));
|
|
185
|
+
return {
|
|
186
|
+
pointerDown$: t,
|
|
187
|
+
pointerCancel$: p,
|
|
188
|
+
pointerLeave$: r,
|
|
189
|
+
pointerUp$: s,
|
|
190
|
+
pointerMove$: o
|
|
191
|
+
};
|
|
192
|
+
}, ee = ({
|
|
193
|
+
container: e,
|
|
194
|
+
afterEventReceived: n = (t) => t
|
|
195
|
+
}) => b(e, "pointerdown").pipe(
|
|
196
|
+
h(n)
|
|
197
|
+
), V = ({
|
|
198
|
+
pointerCancel$: e,
|
|
199
|
+
pointerLeave$: n,
|
|
200
|
+
pointerUp$: t,
|
|
201
|
+
pointerMove$: s,
|
|
202
|
+
trackMove: o
|
|
203
|
+
}) => (r) => r.pipe(
|
|
204
|
+
T((p) => {
|
|
205
|
+
const l = A(
|
|
206
|
+
t,
|
|
207
|
+
n,
|
|
208
|
+
e
|
|
209
|
+
).pipe(U(p)), a = ge(() => q(p));
|
|
210
|
+
return A(
|
|
211
|
+
a,
|
|
212
|
+
o ? s : K
|
|
213
|
+
).pipe(
|
|
214
|
+
U(p),
|
|
215
|
+
h((c) => ({ id: c.pointerId, event: c })),
|
|
216
|
+
x(l),
|
|
217
|
+
he({ id: p.pointerId, event: void 0 })
|
|
218
|
+
);
|
|
219
|
+
}),
|
|
220
|
+
E(
|
|
221
|
+
(p, { event: l, id: a }) => {
|
|
222
|
+
if (!l) {
|
|
223
|
+
const { [a]: $, ...c } = p;
|
|
224
|
+
return c;
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
...p,
|
|
228
|
+
[a]: l
|
|
229
|
+
};
|
|
230
|
+
},
|
|
231
|
+
{}
|
|
232
|
+
),
|
|
233
|
+
h((p) => Object.values(p).filter(we))
|
|
234
|
+
);
|
|
235
|
+
class B extends F {
|
|
236
|
+
constructor(t = {}) {
|
|
237
|
+
super(t);
|
|
238
|
+
w(this, "events$");
|
|
239
|
+
w(this, "start$");
|
|
240
|
+
w(this, "end$");
|
|
241
|
+
w(this, "fingers$");
|
|
242
|
+
this.options = t, this.events$ = this.validConfig$.pipe(
|
|
243
|
+
R((s) => {
|
|
244
|
+
const { container: o, afterEventReceived: r } = s, { posThreshold: p = 15 } = s.options ?? {}, {
|
|
245
|
+
pointerCancel$: l,
|
|
246
|
+
pointerDown$: a,
|
|
247
|
+
pointerLeave$: $,
|
|
248
|
+
pointerMove$: c,
|
|
249
|
+
pointerUp$: i
|
|
250
|
+
} = N({
|
|
251
|
+
container: o,
|
|
252
|
+
afterEventReceived: r
|
|
253
|
+
});
|
|
254
|
+
return a.pipe(
|
|
255
|
+
j((g) => {
|
|
256
|
+
const d = A(
|
|
257
|
+
q(g),
|
|
258
|
+
a
|
|
259
|
+
), f = A(
|
|
260
|
+
l,
|
|
261
|
+
a,
|
|
262
|
+
$,
|
|
263
|
+
c,
|
|
264
|
+
i
|
|
265
|
+
), D = d.pipe(
|
|
266
|
+
V({
|
|
267
|
+
pointerCancel$: l,
|
|
268
|
+
pointerLeave$: $,
|
|
269
|
+
pointerUp$: i,
|
|
270
|
+
pointerMove$: c,
|
|
271
|
+
trackMove: !0
|
|
272
|
+
}),
|
|
273
|
+
Q()
|
|
274
|
+
), m = A(
|
|
275
|
+
i,
|
|
276
|
+
$,
|
|
277
|
+
l
|
|
278
|
+
).pipe(
|
|
279
|
+
Y(D),
|
|
280
|
+
v(([u, y]) => !y.length),
|
|
281
|
+
h(([u]) => u),
|
|
282
|
+
O(),
|
|
283
|
+
M()
|
|
284
|
+
), I = d.pipe(
|
|
285
|
+
T(
|
|
286
|
+
(u) => c.pipe(
|
|
287
|
+
U(u),
|
|
288
|
+
// we start pan only if the user started moving a certain distance
|
|
289
|
+
v(
|
|
290
|
+
(y) => Z(
|
|
291
|
+
u,
|
|
292
|
+
y,
|
|
293
|
+
p
|
|
294
|
+
)
|
|
295
|
+
)
|
|
296
|
+
)
|
|
297
|
+
),
|
|
298
|
+
O()
|
|
299
|
+
).pipe(
|
|
300
|
+
h(() => ({
|
|
301
|
+
type: "panStart",
|
|
302
|
+
event: g
|
|
303
|
+
})),
|
|
304
|
+
M(),
|
|
305
|
+
x(m)
|
|
306
|
+
), k = I.pipe(
|
|
307
|
+
T(
|
|
308
|
+
() => m.pipe(
|
|
309
|
+
h((u) => ({
|
|
310
|
+
type: "panEnd",
|
|
311
|
+
event: u
|
|
312
|
+
}))
|
|
313
|
+
)
|
|
314
|
+
)
|
|
315
|
+
), L = f.pipe(
|
|
316
|
+
$e(I),
|
|
317
|
+
h((u) => ({
|
|
318
|
+
type: "panMove",
|
|
319
|
+
event: u
|
|
320
|
+
})),
|
|
321
|
+
x(m)
|
|
322
|
+
), X = A(I, L, k).pipe(
|
|
323
|
+
Y(D),
|
|
324
|
+
h(([u, y]) => ({
|
|
325
|
+
...u,
|
|
326
|
+
latestActivePointers: y
|
|
327
|
+
})),
|
|
328
|
+
M()
|
|
329
|
+
);
|
|
330
|
+
return S([
|
|
331
|
+
X.pipe(W),
|
|
332
|
+
X
|
|
333
|
+
]).pipe(
|
|
334
|
+
h(([u, { type: y }]) => ({
|
|
335
|
+
...u,
|
|
336
|
+
type: y
|
|
337
|
+
}))
|
|
338
|
+
);
|
|
339
|
+
})
|
|
340
|
+
);
|
|
341
|
+
}),
|
|
342
|
+
M()
|
|
343
|
+
), this.start$ = this.events$.pipe(
|
|
344
|
+
v((s) => s.type === "panStart")
|
|
345
|
+
), this.end$ = this.events$.pipe(v((s) => s.type === "panEnd")), this.fingers$ = this.validConfig$.pipe(
|
|
346
|
+
R(({ container: s, afterEventReceived: o }) => {
|
|
347
|
+
const r = N({
|
|
348
|
+
container: s,
|
|
349
|
+
afterEventReceived: o
|
|
350
|
+
});
|
|
351
|
+
return r.pointerDown$.pipe(
|
|
352
|
+
V({
|
|
353
|
+
...r,
|
|
354
|
+
trackMove: !1
|
|
355
|
+
})
|
|
356
|
+
);
|
|
357
|
+
}),
|
|
358
|
+
h((s) => s.length)
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
const Re = (e) => (n) => n.pipe(
|
|
363
|
+
v((t) => Math.abs(t.velocityX) >= e || Math.abs(t.velocityY) >= e)
|
|
364
|
+
);
|
|
365
|
+
class be extends F {
|
|
366
|
+
constructor(t = {}) {
|
|
367
|
+
super(t);
|
|
368
|
+
w(this, "events$");
|
|
369
|
+
this.options = t, this.events$ = this.validConfig$.pipe(
|
|
370
|
+
R((s) => {
|
|
371
|
+
const { escapeVelocity: o = 0.9, posThreshold: r } = s.options ?? {}, p = new B({ posThreshold: r });
|
|
372
|
+
p.initialize(s);
|
|
373
|
+
const l = p.events$.pipe(
|
|
374
|
+
v(({ pointers: a }) => a.length > 1)
|
|
375
|
+
);
|
|
376
|
+
return p.start$.pipe(
|
|
377
|
+
j((a) => p.end$.pipe(
|
|
378
|
+
O(),
|
|
379
|
+
Re(o),
|
|
380
|
+
h(({ type: $, ...c }) => ({
|
|
381
|
+
type: "swipe",
|
|
382
|
+
angle: ye(
|
|
383
|
+
a.event,
|
|
384
|
+
c.event
|
|
385
|
+
),
|
|
386
|
+
...c
|
|
387
|
+
})),
|
|
388
|
+
x(l)
|
|
389
|
+
)),
|
|
390
|
+
M()
|
|
391
|
+
);
|
|
392
|
+
})
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
class Ce extends F {
|
|
397
|
+
constructor(t) {
|
|
398
|
+
super(t);
|
|
399
|
+
w(this, "events$");
|
|
400
|
+
this.options = t, this.events$ = this.validConfig$.pipe(
|
|
401
|
+
R((s) => {
|
|
402
|
+
const { container: o, afterEventReceived: r } = s, {
|
|
403
|
+
multiTapThreshold: p = 200,
|
|
404
|
+
maximumPressTime: l = 250,
|
|
405
|
+
maxTaps: a = 2,
|
|
406
|
+
// threshold should be high because of fingers size
|
|
407
|
+
// and potential margin due to it. clicks are nearly perfect
|
|
408
|
+
// not fingers.
|
|
409
|
+
posThreshold: $ = 10,
|
|
410
|
+
failWith: c
|
|
411
|
+
} = s.options ?? {}, { pointerUp$: i, pointerLeave$: g, pointerCancel$: d, pointerMove$: f } = N({
|
|
412
|
+
container: o,
|
|
413
|
+
afterEventReceived: r
|
|
414
|
+
}), D = ee({ container: o, afterEventReceived: r }), m = D.pipe(
|
|
415
|
+
V({
|
|
416
|
+
pointerCancel$: d,
|
|
417
|
+
pointerLeave$: g,
|
|
418
|
+
pointerMove$: f,
|
|
419
|
+
pointerUp$: i,
|
|
420
|
+
trackMove: !1
|
|
421
|
+
}),
|
|
422
|
+
Q(1)
|
|
423
|
+
), G = m.pipe(
|
|
424
|
+
v((u) => u.length > 1)
|
|
425
|
+
), I = (u) => u.pipe(
|
|
426
|
+
Y(m),
|
|
427
|
+
v(([, y]) => y.length === 1),
|
|
428
|
+
h(([y]) => y)
|
|
429
|
+
), k = (u) => u.pipe(
|
|
430
|
+
ve(i.pipe(fe(p))),
|
|
431
|
+
O()
|
|
432
|
+
), L = Te(c);
|
|
433
|
+
return A(
|
|
434
|
+
D,
|
|
435
|
+
m.pipe(ue())
|
|
436
|
+
).pipe(
|
|
437
|
+
I,
|
|
438
|
+
j((u) => {
|
|
439
|
+
const y = A(q(u), D), te = A(
|
|
440
|
+
i,
|
|
441
|
+
g,
|
|
442
|
+
d,
|
|
443
|
+
f
|
|
444
|
+
), ne = y.pipe(k), se = te.pipe(
|
|
445
|
+
v(
|
|
446
|
+
(P) => Z(
|
|
447
|
+
u,
|
|
448
|
+
P,
|
|
449
|
+
$
|
|
450
|
+
)
|
|
451
|
+
),
|
|
452
|
+
O()
|
|
453
|
+
), oe = m.pipe(
|
|
454
|
+
R(() => de(l))
|
|
455
|
+
), ie = A(
|
|
456
|
+
L,
|
|
457
|
+
d,
|
|
458
|
+
G,
|
|
459
|
+
se,
|
|
460
|
+
oe
|
|
461
|
+
), H = ne.pipe(
|
|
462
|
+
Me,
|
|
463
|
+
v((P) => P.length <= a),
|
|
464
|
+
h((P) => ({
|
|
465
|
+
type: "tap",
|
|
466
|
+
taps: P.length,
|
|
467
|
+
latestActivePointers: P,
|
|
468
|
+
event: P[0]
|
|
469
|
+
}))
|
|
470
|
+
);
|
|
471
|
+
return S([
|
|
472
|
+
H.pipe(W),
|
|
473
|
+
H
|
|
474
|
+
]).pipe(
|
|
475
|
+
h(([P, { type: re, taps: pe }]) => ({
|
|
476
|
+
...P,
|
|
477
|
+
type: re,
|
|
478
|
+
taps: pe
|
|
479
|
+
})),
|
|
480
|
+
x(ie)
|
|
481
|
+
);
|
|
482
|
+
})
|
|
483
|
+
);
|
|
484
|
+
}),
|
|
485
|
+
M()
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
class Fe extends F {
|
|
490
|
+
constructor(t = {}) {
|
|
491
|
+
super(t);
|
|
492
|
+
w(this, "events$");
|
|
493
|
+
this.options = t, this.events$ = this.config$.pipe(
|
|
494
|
+
R((s) => {
|
|
495
|
+
const { posThreshold: o } = s.options ?? {}, r = new B({ posThreshold: o });
|
|
496
|
+
r.initialize(s);
|
|
497
|
+
const p = r.events$.pipe(
|
|
498
|
+
v(({ pointers: i }) => i.length < 2),
|
|
499
|
+
z()
|
|
500
|
+
), a = r.events$.pipe(
|
|
501
|
+
h((i) => [i, i.pointers.length > 1]),
|
|
502
|
+
z(
|
|
503
|
+
([i, g], [d, f]) => g === f
|
|
504
|
+
),
|
|
505
|
+
v(([i, g]) => g)
|
|
506
|
+
).pipe(
|
|
507
|
+
h(([i]) => ({
|
|
508
|
+
...i,
|
|
509
|
+
type: "rotateStart",
|
|
510
|
+
angle: 0,
|
|
511
|
+
deltaAngle: 0
|
|
512
|
+
}))
|
|
513
|
+
), $ = a.pipe(
|
|
514
|
+
T(
|
|
515
|
+
() => r.events$.pipe(
|
|
516
|
+
E(
|
|
517
|
+
(i, g) => {
|
|
518
|
+
const d = i.angle + g.deltaPointersAngle;
|
|
519
|
+
return {
|
|
520
|
+
...i,
|
|
521
|
+
...g,
|
|
522
|
+
type: "rotate",
|
|
523
|
+
angle: d,
|
|
524
|
+
deltaAngle: g.deltaPointersAngle
|
|
525
|
+
};
|
|
526
|
+
},
|
|
527
|
+
{ angle: 0, deltaAngle: 0 }
|
|
528
|
+
),
|
|
529
|
+
x(p)
|
|
530
|
+
)
|
|
531
|
+
)
|
|
532
|
+
), c = a.pipe(
|
|
533
|
+
T(
|
|
534
|
+
() => S([$, p]).pipe(
|
|
535
|
+
O(),
|
|
536
|
+
h(([i]) => ({
|
|
537
|
+
...i,
|
|
538
|
+
type: "rotateEnd"
|
|
539
|
+
}))
|
|
540
|
+
)
|
|
541
|
+
)
|
|
542
|
+
);
|
|
543
|
+
return A(a, $, c);
|
|
544
|
+
})
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
class ze extends F {
|
|
549
|
+
constructor(t = {}) {
|
|
550
|
+
super(t);
|
|
551
|
+
w(this, "events$");
|
|
552
|
+
this.options = t, this.events$ = this.config$.pipe(
|
|
553
|
+
R((s) => {
|
|
554
|
+
const { posThreshold: o } = s.options ?? {}, r = new B({ posThreshold: o });
|
|
555
|
+
r.initialize(s);
|
|
556
|
+
const p = r.events$.pipe(
|
|
557
|
+
v(({ pointers: i }) => i.length < 2),
|
|
558
|
+
z()
|
|
559
|
+
), a = r.events$.pipe(
|
|
560
|
+
h((i) => [i, i.pointers.length > 1]),
|
|
561
|
+
z(
|
|
562
|
+
([i, g], [d, f]) => g === f
|
|
563
|
+
),
|
|
564
|
+
v(([i, g]) => g)
|
|
565
|
+
).pipe(
|
|
566
|
+
h(([i]) => ({
|
|
567
|
+
...i,
|
|
568
|
+
type: "pinchStart",
|
|
569
|
+
scale: 1,
|
|
570
|
+
distance: 0,
|
|
571
|
+
deltaDistance: 0,
|
|
572
|
+
deltaDistanceScale: 1
|
|
573
|
+
}))
|
|
574
|
+
), $ = a.pipe(
|
|
575
|
+
T((i) => r.events$.pipe(
|
|
576
|
+
E(
|
|
577
|
+
(g, d) => {
|
|
578
|
+
const f = g.pointersAverageDistance ?? d.pointersAverageDistance, D = d.pointersAverageDistance / i.pointersAverageDistance;
|
|
579
|
+
return {
|
|
580
|
+
...g,
|
|
581
|
+
...d,
|
|
582
|
+
scale: D,
|
|
583
|
+
distance: d.pointersAverageDistance - i.pointersAverageDistance,
|
|
584
|
+
deltaDistance: d.pointersAverageDistance - f,
|
|
585
|
+
deltaDistanceScale: d.pointersAverageDistance / f,
|
|
586
|
+
type: "pinchMove"
|
|
587
|
+
};
|
|
588
|
+
},
|
|
589
|
+
{ scale: 0 }
|
|
590
|
+
),
|
|
591
|
+
x(p)
|
|
592
|
+
))
|
|
593
|
+
), c = a.pipe(
|
|
594
|
+
T(
|
|
595
|
+
() => S([$, p]).pipe(
|
|
596
|
+
O(),
|
|
597
|
+
h(([i]) => ({
|
|
598
|
+
...i,
|
|
599
|
+
type: "pinchEnd"
|
|
600
|
+
}))
|
|
601
|
+
)
|
|
602
|
+
)
|
|
603
|
+
);
|
|
604
|
+
return A(a, $, c);
|
|
605
|
+
})
|
|
606
|
+
);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
const Ee = ({
|
|
610
|
+
afterEventReceived: e = (t) => t,
|
|
611
|
+
recognizers: n
|
|
612
|
+
}) => ({ events$: A(
|
|
613
|
+
...n.map((o) => o.events$)
|
|
614
|
+
).pipe(M()), initialize: (o) => {
|
|
615
|
+
o.style.touchAction = "none", o.style.userSelect = "none", n.forEach((r) => {
|
|
616
|
+
r.initialize({ container: o, afterEventReceived: e });
|
|
617
|
+
});
|
|
618
|
+
}, recognizers: n });
|
|
619
|
+
export {
|
|
620
|
+
B as PanRecognizer,
|
|
621
|
+
ze as PinchRecognizer,
|
|
622
|
+
Fe as RotateRecognizer,
|
|
623
|
+
be as SwipeRecognizer,
|
|
624
|
+
Ce as TapRecognizer,
|
|
625
|
+
Ee as createManager
|
|
626
|
+
};
|
|
627
|
+
//# sourceMappingURL=index.js.map
|