gesturx 1.7.6 → 1.8.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.
package/dist/index.js CHANGED
@@ -1,147 +1,147 @@
1
- var ee = Object.defineProperty;
2
- var te = (n, s, e) => s in n ? ee(n, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[s] = e;
3
- var h = (n, s, e) => te(n, typeof s != "symbol" ? s + "" : s, e);
4
- import { filter as c, fromEvent as S, mergeMap as T, defer as ne, of as b, merge as y, takeWhile as N, scan as O, map as u, BehaviorSubject as B, switchMap as v, distinctUntilChanged as se, NEVER as ie, shareReplay as x, exhaustMap as _, first as X, share as f, timer as G, withLatestFrom as Y, takeUntil as k, skip as pe, tap as oe, ignoreElements as re, buffer as ae, debounceTime as le, startWith as he, pairwise as ce, combineLatest as ue } from "rxjs";
5
- function $e(n, s) {
1
+ var se = Object.defineProperty;
2
+ var pe = (t, n, e) => n in t ? se(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
3
+ var $ = (t, n, e) => pe(t, typeof n != "symbol" ? n + "" : n, e);
4
+ import { filter as h, fromEvent as I, mergeMap as S, defer as oe, of as T, merge as y, takeWhile as V, scan as U, map as c, BehaviorSubject as q, switchMap as g, distinctUntilChanged as re, startWith as H, shareReplay as M, combineLatest as W, exhaustMap as J, first as F, share as P, timer as K, withLatestFrom as L, takeUntil as b, skip as ae, tap as Q, ignoreElements as le, buffer as he, debounceTime as ce, pairwise as $e } from "rxjs";
5
+ function ue(t, n) {
6
6
  return Math.sqrt(
7
- Math.pow(s.x - n.x, 2) + Math.pow(s.y - n.y, 2)
7
+ Math.pow(n.x - t.x, 2) + Math.pow(n.y - t.y, 2)
8
8
  );
9
9
  }
10
- function de(n) {
11
- const s = n.length;
12
- if (s < 2) return 0;
13
- const e = n.reduce((t, o, a) => t + n.slice(a + 1).reduce((r, p) => r + $e(o, p), 0), 0), i = s * (s - 1) / 2;
10
+ function de(t) {
11
+ const n = t.length;
12
+ if (n < 2) return 0;
13
+ const e = t.reduce((s, p, a) => s + t.slice(a + 1).reduce((o, r) => o + ue(p, r), 0), 0), i = n * (n - 1) / 2;
14
14
  return e / i;
15
15
  }
16
- function j(n, s) {
17
- const e = s.x - n.x, i = s.y - n.y;
16
+ function N(t, n) {
17
+ const e = n.x - t.x, i = n.y - t.y;
18
18
  return Math.atan2(i, e);
19
19
  }
20
- function ge(n, s) {
21
- return j(n, s) * (180 / Math.PI);
20
+ function ve(t, n) {
21
+ return N(t, n) * (180 / Math.PI);
22
22
  }
23
- function C(n) {
24
- const s = n.reduce(
25
- (i, t) => (i.x += t.x, i.y += t.y, i),
23
+ function R(t) {
24
+ const n = t.reduce(
25
+ (i, s) => (i.x += s.x, i.y += s.y, i),
26
26
  { x: 0, y: 0 }
27
- ), e = n.length || 1;
27
+ ), e = t.length || 1;
28
28
  return {
29
- x: s.x / e,
30
- y: s.y / e
29
+ x: n.x / e,
30
+ y: n.y / e
31
31
  };
32
32
  }
33
- function ve(n, s) {
34
- if (n.length !== s.length)
33
+ function ge(t, n) {
34
+ if (t.length !== n.length)
35
35
  throw new Error("Initial and new points arrays must have the same length.");
36
- const e = C(n), i = C(s);
37
- let t = 0;
38
- for (let r = 0; r < n.length; r++) {
39
- const p = j(
36
+ const e = R(t), i = R(n);
37
+ let s = 0;
38
+ for (let o = 0; o < t.length; o++) {
39
+ const r = N(
40
40
  e,
41
- n[r]
41
+ t[o]
42
42
  );
43
- let $ = j(
43
+ let u = N(
44
44
  i,
45
- s[r]
46
- ) - p;
47
- $ > Math.PI ? $ -= 2 * Math.PI : $ < -Math.PI && ($ += 2 * Math.PI), t += $;
45
+ n[o]
46
+ ) - r;
47
+ u > Math.PI ? u -= 2 * Math.PI : u < -Math.PI && (u += 2 * Math.PI), s += u;
48
48
  }
49
- const o = t / n.length, a = o * (180 / Math.PI);
50
- return { radianDelta: o, degreesDelta: a };
49
+ const p = s / t.length, a = p * (180 / Math.PI);
50
+ return { radianDelta: p, degreesDelta: a };
51
51
  }
52
- function ye(n) {
53
- return n != null;
52
+ function ye(t) {
53
+ return t != null;
54
54
  }
55
- const me = (n) => n.length > 0, De = (n) => n.pipe(c(me));
56
- function H(n, s, e) {
57
- const i = C([n]), t = C([s]);
58
- return Math.abs(t.x - i.x) >= e || Math.abs(t.y - i.y) >= e;
55
+ const me = (t) => t.length > 0, fe = (t) => t.pipe(h(me));
56
+ function Z(t, n, e) {
57
+ const i = R([t]), s = R([n]);
58
+ return Math.abs(s.x - i.x) >= e || Math.abs(s.y - i.y) >= e;
59
59
  }
60
- const Pe = (n, s, e) => {
61
- const i = n > 0 ? s / n : 0, t = n > 0 ? e / n : 0;
60
+ const Ae = (t, n, e) => {
61
+ const i = t > 0 ? n / t : 0, s = t > 0 ? e / t : 0;
62
62
  return {
63
63
  velocityX: i,
64
- velocityY: t
64
+ velocityY: s
65
65
  };
66
66
  };
67
- function F(n) {
68
- return (s) => s.pipe(
69
- c((e) => e.pointerId === n.pointerId)
67
+ function X(t) {
68
+ return (n) => n.pipe(
69
+ h((e) => e.pointerId === t.pointerId)
70
70
  );
71
71
  }
72
- const J = (n) => n.type === "pointerleave" || n.type === "pointercancel" || n.type === "pointerup", fe = ({
73
- container: n,
74
- afterEventReceived: s = (e) => e
75
- }) => S(n, "pointerdown").pipe(
76
- u(s)
77
- ), K = ({
78
- pointerEvent$: n
79
- }) => (s) => {
80
- const e = n.pipe(
81
- c((p) => p.type === "pointerup")
82
- ), i = n.pipe(
83
- c((p) => p.type === "pointerleave")
84
- ), t = n.pipe(
85
- c((p) => p.type === "pointercancel")
86
- ), o = n.pipe(
87
- c((p) => p.type === "pointermove")
88
- ), a = S(window, "contextmenu"), r = (p) => ["pointercancel", "pointerleave", "pointerup", "contextmenu"].includes(
89
- p.type
72
+ const ee = (t) => t.type === "pointerleave" || t.type === "pointercancel" || t.type === "pointerup", De = ({
73
+ container: t,
74
+ afterEventReceived: n = (e) => e
75
+ }) => I(t, "pointerdown").pipe(
76
+ c(n)
77
+ ), te = ({
78
+ pointerEvent$: t
79
+ }) => (n) => {
80
+ const e = t.pipe(
81
+ h((r) => r.type === "pointerup")
82
+ ), i = t.pipe(
83
+ h((r) => r.type === "pointerleave")
84
+ ), s = t.pipe(
85
+ h((r) => r.type === "pointercancel")
86
+ ), p = t.pipe(
87
+ h((r) => r.type === "pointermove")
88
+ ), a = I(window, "contextmenu"), o = (r) => ["pointercancel", "pointerleave", "pointerup", "contextmenu"].includes(
89
+ r.type
90
90
  );
91
- return s.pipe(
92
- T((p) => {
93
- const l = ne(() => b(p));
91
+ return n.pipe(
92
+ S((r) => {
93
+ const l = oe(() => T(r));
94
94
  return y(
95
95
  l,
96
96
  y(
97
- o,
98
- t,
97
+ p,
98
+ s,
99
99
  i,
100
100
  e,
101
101
  a
102
102
  )
103
103
  ).pipe(
104
- F(p),
105
- N((D) => !r(D), !0)
104
+ X(r),
105
+ V((f) => !o(f), !0)
106
106
  );
107
107
  }),
108
- O((p, l) => {
109
- if (r(l)) {
110
- const { [l.pointerId]: $, ...D } = (p == null ? void 0 : p.pointers) ?? {};
108
+ U((r, l) => {
109
+ if (o(l)) {
110
+ const { [l.pointerId]: u, ...f } = (r == null ? void 0 : r.pointers) ?? {};
111
111
  return {
112
112
  event: l,
113
- pointers: D
113
+ pointers: f
114
114
  };
115
115
  }
116
116
  return {
117
117
  event: l,
118
118
  pointers: {
119
- ...(p == null ? void 0 : p.pointers) ?? {},
119
+ ...(r == null ? void 0 : r.pointers) ?? {},
120
120
  [l.pointerId]: l
121
121
  }
122
122
  };
123
123
  }, void 0),
124
- u(({ event: p, pointers: l }) => ({
125
- event: p,
124
+ c(({ event: r, pointers: l }) => ({
125
+ event: r,
126
126
  pointers: Object.values(l).filter(ye)
127
127
  }))
128
128
  );
129
- }, q = (n, s, e, i) => {
130
- const t = n.x - s.x + e, o = n.y - s.y + i;
129
+ }, _ = (t, n, e, i) => {
130
+ const s = t.x - n.x + e, p = t.y - n.y + i;
131
131
  return {
132
- deltaX: t,
133
- deltaY: o
132
+ deltaX: s,
133
+ deltaY: p
134
134
  };
135
- }, Q = (n) => {
136
- const s = (e) => C(
135
+ }, ne = (t) => {
136
+ const n = (e) => R(
137
137
  e.latestActivePointers.length ? e.latestActivePointers : [e.event]
138
138
  );
139
- return n.pipe(
140
- O((e, i) => {
141
- var g, E;
142
- const t = s(i), o = (e == null ? void 0 : e.center) ?? t, a = (e == null ? void 0 : e.deltaX) ?? 0, r = (e == null ? void 0 : e.deltaY) ?? 0, p = ((g = e == null ? void 0 : e.latestActivePointers) == null ? void 0 : g.length) ?? 1, l = ((E = i.latestActivePointers) == null ? void 0 : E.length) ?? 1, $ = ["pointerdown", "pointercancel", "pointerleave", "pointerup"].includes(
139
+ return t.pipe(
140
+ U((e, i) => {
141
+ var m, D;
142
+ const s = n(i), p = (e == null ? void 0 : e.center) ?? s, a = (e == null ? void 0 : e.deltaX) ?? 0, o = (e == null ? void 0 : e.deltaY) ?? 0, r = ((m = e == null ? void 0 : e.latestActivePointers) == null ? void 0 : m.length) ?? 1, l = ((D = i.latestActivePointers) == null ? void 0 : D.length) ?? 1, u = ["pointerdown", "pointercancel", "pointerleave", "pointerup"].includes(
143
143
  i.event.type
144
- ) && p !== l, D = l > 0, { deltaX: d, deltaY: A } = $ && D ? q(t, t, a, r) : q(t, o, a, r), { degreesDelta: P } = p === l && p >= 2 && l >= 2 ? ve(
144
+ ) && r !== l, f = l > 0, { deltaX: d, deltaY: E } = u && f ? _(s, s, a, o) : _(s, p, a, o), { degreesDelta: A } = r === l && r >= 2 && l >= 2 ? ge(
145
145
  (e == null ? void 0 : e.latestActivePointers) ?? [],
146
146
  i.latestActivePointers ?? []
147
147
  ) : { degreesDelta: 0 };
@@ -149,216 +149,230 @@ const J = (n) => n.type === "pointerleave" || n.type === "pointercancel" || n.ty
149
149
  startTime: (/* @__PURE__ */ new Date()).getTime(),
150
150
  ...e,
151
151
  ...i,
152
- center: t,
152
+ center: s,
153
153
  deltaX: d,
154
- deltaY: A,
155
- deltaPointersAngle: P
154
+ deltaY: E,
155
+ deltaPointersAngle: A
156
156
  };
157
157
  }, void 0),
158
- u((e) => {
158
+ c((e) => {
159
159
  const {
160
160
  deltaX: i,
161
- deltaY: t,
162
- latestActivePointers: o,
161
+ deltaY: s,
162
+ latestActivePointers: p,
163
163
  startTime: a,
164
- center: r,
165
- event: p,
164
+ center: o,
165
+ event: r,
166
166
  deltaPointersAngle: l
167
- } = e, $ = o ?? [], d = Date.now() - a, { velocityX: A, velocityY: P } = Pe(d, i, t), g = de(o);
167
+ } = e, u = p ?? [], d = Date.now() - a, { velocityX: E, velocityY: A } = Ae(d, i, s), m = de(p);
168
168
  return {
169
169
  deltaX: i,
170
- deltaY: t,
171
- velocityX: A,
172
- velocityY: P,
170
+ deltaY: s,
171
+ velocityX: E,
172
+ velocityY: A,
173
173
  delay: d,
174
- center: r,
175
- pointers: $,
174
+ center: o,
175
+ pointers: u,
176
176
  startTime: a,
177
- event: p,
177
+ event: r,
178
178
  deltaPointersAngle: l,
179
- pointersAverageDistance: g
179
+ pointersAverageDistance: m
180
180
  };
181
181
  })
182
182
  );
183
- }, W = (n) => n.pipe(
184
- c(
185
- (s) => !!s.container
183
+ }, G = (t) => t.pipe(
184
+ h(
185
+ (n) => !!n.container
186
186
  )
187
- ), Z = (n) => n.pipe(c(J)), Ae = ({
188
- container: n,
189
- afterEventReceived: s = (e) => e
187
+ ), ie = (t) => t.pipe(h(ee)), Pe = ({
188
+ container: t,
189
+ afterEventReceived: n = (e) => e
190
190
  }) => {
191
- const e = fe({ afterEventReceived: s, container: n }), i = S(n, "pointerup").pipe(
192
- u(s)
193
- ), t = S(n, "pointermove").pipe(
194
- u(s)
195
- ), o = S(n, "pointerleave").pipe(
196
- u(s)
197
- ), a = S(
198
- n,
191
+ const e = De({ afterEventReceived: n, container: t }), i = I(t, "pointerup").pipe(
192
+ c(n)
193
+ ), s = I(t, "pointermove").pipe(
194
+ c(n)
195
+ ), p = I(t, "pointerleave").pipe(
196
+ c(n)
197
+ ), a = I(
198
+ t,
199
199
  "pointercancel"
200
- ).pipe(u(s));
200
+ ).pipe(c(n));
201
201
  return y(
202
202
  e,
203
203
  a,
204
- o,
204
+ p,
205
205
  i,
206
- t
206
+ s
207
207
  );
208
208
  };
209
209
  class z {
210
- constructor(s, e) {
211
- h(this, "configSubject", new B({}));
212
- h(this, "pan$");
213
- h(this, "panStart$");
214
- h(this, "panMove$");
215
- h(this, "panEnd$");
216
- h(this, "pointerEvent$");
217
- h(this, "pointerDown$");
218
- h(this, "pointerUp$");
219
- h(this, "pointerCancel$");
220
- h(this, "pointerMove$");
221
- h(this, "pointerOff$");
222
- h(this, "state$");
223
- h(this, "failWith$");
224
- h(this, "config$", this.configSubject.pipe(W));
225
- const i = new B({
210
+ constructor(n, e) {
211
+ $(this, "configSubject", new q({}));
212
+ $(this, "pan$");
213
+ $(this, "panStart$");
214
+ $(this, "panMove$");
215
+ $(this, "panEnd$");
216
+ $(this, "pointerEvent$");
217
+ $(this, "pointerDown$");
218
+ $(this, "pointerUp$");
219
+ $(this, "pointerCancel$");
220
+ $(this, "pointerMove$");
221
+ $(this, "pointerOff$");
222
+ $(this, "state$");
223
+ $(this, "config$", this.configSubject.pipe(G));
224
+ /**
225
+ * Track active running failWith recognizers
226
+ */
227
+ $(this, "failWithActive$");
228
+ const i = new q({
226
229
  fingers: 0
227
230
  });
228
231
  this.pointerEvent$ = this.config$.pipe(
229
- v(
230
- ({ container: t, afterEventReceived: o }) => Ae({
231
- container: t,
232
- afterEventReceived: o
232
+ g(
233
+ ({ container: p, afterEventReceived: a }) => Pe({
234
+ container: p,
235
+ afterEventReceived: a
233
236
  })
234
237
  )
235
238
  ), this.pointerDown$ = this.pointerEvent$.pipe(
236
- c((t) => t.type === "pointerdown")
239
+ h((p) => p.type === "pointerdown")
237
240
  ), this.pointerUp$ = this.pointerEvent$.pipe(
238
- c((t) => t.type === "pointerup")
241
+ h((p) => p.type === "pointerup")
239
242
  ), this.pointerMove$ = this.pointerEvent$.pipe(
240
- c((t) => t.type === "pointermove")
243
+ h((p) => p.type === "pointermove")
241
244
  ), this.pointerCancel$ = this.pointerEvent$.pipe(
242
- c((t) => t.type === "pointercancel")
243
- ), this.pointerOff$ = this.pointerEvent$.pipe(Z), this.failWith$ = this.config$.pipe(
244
- se(
245
- (t, o) => t.failWith === o.failWith
246
- ),
247
- v(
248
- ({ failWith: t }) => t != null && t.length ? y(...(t == null ? void 0 : t.map(({ start$: o }) => o)) ?? []) : ie
249
- )
245
+ h((p) => p.type === "pointercancel")
246
+ ), this.pointerOff$ = this.pointerEvent$.pipe(ie);
247
+ const s = this.config$.pipe(
248
+ c(({ failWith: p }) => p),
249
+ re()
250
+ );
251
+ this.failWithActive$ = s.pipe(
252
+ g((p) => {
253
+ const a = p == null ? void 0 : p.map((o) => {
254
+ const r = o.start$.pipe(c(() => !0)), l = o.end$.pipe(c(() => !1));
255
+ return y(r, l).pipe(
256
+ H(!1),
257
+ M(1)
258
+ );
259
+ });
260
+ return a != null && a.length ? W(a) : W([T(!1)]);
261
+ }),
262
+ c((p) => p.some((a) => a)),
263
+ M(1)
250
264
  ), this.pan$ = this.configSubject.pipe(
251
- W,
252
- v((t) => {
253
- var D, d, A;
254
- const o = Math.max(1, ((D = t.panConfig) == null ? void 0 : D.numInputs) ?? 1), a = Math.max(0, ((d = t.panConfig) == null ? void 0 : d.posThreshold) ?? 0), r = Math.max(0, ((A = t.panConfig) == null ? void 0 : A.delay) ?? 0), p = this.pointerDown$.pipe(
255
- K({
265
+ G,
266
+ g((p) => {
267
+ var d, E, A;
268
+ const a = Math.max(1, ((d = p.panConfig) == null ? void 0 : d.numInputs) ?? 1), o = Math.max(0, ((E = p.panConfig) == null ? void 0 : E.posThreshold) ?? 0), r = Math.max(0, ((A = p.panConfig) == null ? void 0 : A.delay) ?? 0), l = this.pointerDown$.pipe(
269
+ te({
256
270
  pointerEvent$: this.pointerEvent$,
257
271
  trackMove: !0
258
272
  }),
259
- x(1)
260
- ), l = (P) => P.pipe(
261
- c(
262
- (g) => g.pointers.length >= o
273
+ M(1)
274
+ ), u = (m) => m.pipe(
275
+ h(
276
+ (D) => D.pointers.length >= a
263
277
  )
264
- ), $ = (P) => P.pipe(c((g) => g.pointers.length < o));
265
- return p.pipe(
266
- l,
267
- _(({ pointers: P }) => {
268
- const g = p.pipe(
269
- $,
270
- X(),
271
- f()
272
- ), E = G(r), I = y(
273
- ...P.map((m) => b(m)),
278
+ ), f = (m) => m.pipe(h((D) => D.pointers.length < a));
279
+ return l.pipe(
280
+ u,
281
+ J(({ pointers: m }) => {
282
+ const D = l.pipe(
283
+ f,
284
+ F(),
285
+ P()
286
+ ), Y = K(r), C = y(
287
+ ...m.map((v) => T(v)),
274
288
  this.pointerDown$
275
289
  ).pipe(
276
- T(
277
- (m) => y(this.pointerMove$, b(m)).pipe(
278
- F(m),
279
- c(
280
- (M) => H(
281
- m,
282
- M,
283
- a
290
+ S(
291
+ (v) => y(this.pointerMove$, T(v)).pipe(
292
+ X(v),
293
+ h(
294
+ (x) => Z(
295
+ v,
296
+ x,
297
+ o
284
298
  )
285
299
  )
286
300
  )
287
301
  ),
288
- X()
302
+ F()
289
303
  ).pipe(
290
- v(() => E),
291
- Y(p),
292
- u(([, { event: m, pointers: M }]) => ({
304
+ g(() => Y),
305
+ L(l),
306
+ c(([, { event: v, pointers: x }]) => ({
293
307
  type: "start",
294
- event: m,
295
- latestActivePointers: M
308
+ event: v,
309
+ latestActivePointers: x
296
310
  })),
297
- x({
311
+ M({
298
312
  bufferSize: 1,
299
313
  refCount: !1
300
314
  }),
301
- k(g)
302
- ), w = I.pipe(
303
- T(
304
- () => p.pipe(
305
- pe(1),
306
- u(({ event: m, pointers: M }) => ({
315
+ b(D)
316
+ ), k = C.pipe(
317
+ S(
318
+ () => l.pipe(
319
+ ae(1),
320
+ c(({ event: v, pointers: x }) => ({
307
321
  type: "move",
308
- event: m,
309
- latestActivePointers: M
322
+ event: v,
323
+ latestActivePointers: x
310
324
  }))
311
325
  )
312
326
  ),
313
- k(g)
314
- ), L = I.pipe(
315
- T(
316
- () => g.pipe(
317
- u(({ event: m, pointers: M }) => ({
327
+ b(D)
328
+ ), w = C.pipe(
329
+ S(
330
+ () => D.pipe(
331
+ c(({ event: v, pointers: x }) => ({
318
332
  type: "end",
319
- event: m,
320
- latestActivePointers: M
333
+ event: v,
334
+ latestActivePointers: x
321
335
  }))
322
336
  )
323
337
  )
324
- ), R = y(I, w, L).pipe(
325
- x(1)
338
+ ), O = y(C, k, w).pipe(
339
+ M(1)
326
340
  );
327
- return R.pipe(
328
- Q,
329
- Y(R),
330
- u(([m, { type: M }]) => ({
331
- ...m,
332
- type: M
341
+ return O.pipe(
342
+ ne,
343
+ L(O),
344
+ c(([v, { type: x }]) => ({
345
+ ...v,
346
+ type: x
333
347
  }))
334
348
  );
335
349
  })
336
350
  );
337
351
  }),
338
- oe((t) => {
352
+ Q((p) => {
339
353
  i.next({
340
- fingers: t.pointers.length
354
+ fingers: p.pointers.length
341
355
  });
342
356
  }),
343
- f()
357
+ P()
344
358
  ), this.panStart$ = this.pan$.pipe(
345
- c((t) => t.type === "start"),
346
- u(({ type: t, ...o }) => o)
359
+ h((p) => p.type === "start"),
360
+ c(({ type: p, ...a }) => a)
347
361
  ), this.panMove$ = this.pan$.pipe(
348
- c((t) => t.type === "move"),
349
- u(({ type: t, ...o }) => o)
362
+ h((p) => p.type === "move"),
363
+ c(({ type: p, ...a }) => a)
350
364
  ), this.panEnd$ = this.pan$.pipe(
351
- c((t) => t.type === "end"),
352
- u(({ type: t, ...o }) => o)
353
- ), this.state$ = i.asObservable(), this.updateInternal(s ?? {}, e);
365
+ h((p) => p.type === "end"),
366
+ c(({ type: p, ...a }) => a)
367
+ ), this.state$ = i.asObservable(), this.updateInternal(n ?? {}, e);
354
368
  }
355
- updateInternal(s, e) {
369
+ updateInternal(n, e) {
356
370
  const i = this.configSubject.getValue();
357
371
  this.configSubject.next({
358
372
  ...i,
359
- ...s,
360
- ...s.options && {
361
- options: { ...i.options, ...s.options }
373
+ ...n,
374
+ ...n.options && {
375
+ options: { ...i.options, ...n.options }
362
376
  },
363
377
  panConfig: {
364
378
  ...i.panConfig,
@@ -366,74 +380,96 @@ class z {
366
380
  }
367
381
  });
368
382
  }
369
- update(s, e) {
370
- this.updateInternal(s, e);
383
+ update(n, e) {
384
+ this.updateInternal(n, e);
371
385
  }
372
386
  }
373
- class Se extends z {
387
+ class Ie extends z {
374
388
  constructor(e) {
375
- var o;
389
+ var a;
376
390
  super(e, {
377
391
  ...e,
378
- posThreshold: ((o = e == null ? void 0 : e.options) == null ? void 0 : o.posThreshold) ?? 15
392
+ posThreshold: ((a = e == null ? void 0 : e.options) == null ? void 0 : a.posThreshold) ?? 15
379
393
  });
380
- h(this, "events$");
381
- h(this, "start$");
382
- h(this, "end$");
394
+ $(this, "events$");
395
+ $(this, "start$");
396
+ $(this, "end$");
383
397
  const i = this.panStart$.pipe(
384
- u((a) => ({
398
+ c((o) => ({
385
399
  type: "panStart",
386
- ...a
400
+ ...o
387
401
  })),
388
- f()
389
- ), t = this.panEnd$.pipe(
390
- u((a) => ({
402
+ L(this.failWithActive$),
403
+ h(([, o]) => !o),
404
+ c(([o]) => o),
405
+ P()
406
+ ), s = this.panEnd$.pipe(
407
+ c((o) => ({
391
408
  type: "panEnd",
392
- ...a
409
+ ...o
393
410
  })),
394
- f()
411
+ P()
412
+ ), p = this.panMove$.pipe(
413
+ c((o) => ({
414
+ type: "panMove",
415
+ ...o
416
+ }))
395
417
  );
396
- this.events$ = y(
397
- i,
398
- this.panMove$.pipe(
399
- u((a) => ({
400
- type: "panMove",
401
- ...a
402
- }))
403
- ),
404
- t
405
- ), this.start$ = i, this.end$ = t;
418
+ this.events$ = i.pipe(
419
+ g((o) => {
420
+ let r = o;
421
+ const l = this.failWithActive$.pipe(
422
+ h((d) => d),
423
+ F()
424
+ ), u = y(T(o), p, s).pipe(
425
+ Q((d) => {
426
+ r = d;
427
+ }),
428
+ b(l)
429
+ ), f = l.pipe(
430
+ c(() => ({
431
+ ...r,
432
+ type: "panEnd"
433
+ })),
434
+ b(s)
435
+ );
436
+ return y(u, f);
437
+ }),
438
+ P()
439
+ ), this.start$ = this.events$.pipe(
440
+ h((o) => o.type === "panStart")
441
+ ), this.end$ = this.events$.pipe(h((o) => o.type === "panEnd"));
406
442
  }
407
443
  update(e) {
408
444
  super.update(e, e.options);
409
445
  }
410
446
  }
411
- const we = (n) => (s) => s.pipe(
412
- c((e) => Math.abs(e.velocityX) >= n || Math.abs(e.velocityY) >= n)
447
+ const we = (t) => (n) => n.pipe(
448
+ h((e) => Math.abs(e.velocityX) >= t || Math.abs(e.velocityY) >= t)
413
449
  );
414
- class Te extends z {
450
+ class Se extends z {
415
451
  constructor(e) {
416
452
  super(e, {
417
453
  posThreshold: 0,
418
454
  numInputs: 1
419
455
  });
420
- h(this, "events$");
456
+ $(this, "events$");
421
457
  this.events$ = this.config$.pipe(
422
- v((i) => {
423
- const { escapeVelocity: t = 0.9 } = i.options ?? {};
458
+ g((i) => {
459
+ const { escapeVelocity: s = 0.9 } = i.options ?? {};
424
460
  return this.panStart$.pipe(
425
- v((o) => this.panEnd$.pipe(
426
- we(t),
427
- u((a) => ({
461
+ g((p) => this.panEnd$.pipe(
462
+ we(s),
463
+ c((a) => ({
428
464
  type: "swipe",
429
- angle: ge(
430
- o.event,
465
+ angle: ve(
466
+ p.event,
431
467
  a.event
432
468
  ),
433
469
  ...a
434
470
  }))
435
471
  )),
436
- f()
472
+ P()
437
473
  );
438
474
  })
439
475
  );
@@ -443,27 +479,27 @@ class Te extends z {
443
479
  }
444
480
  }
445
481
  const Me = ({
446
- timeout: n,
447
- pointerEvent$: s
482
+ timeout: t,
483
+ pointerEvent$: n
448
484
  }) => (e) => e.pipe(
449
- T(
450
- (i) => G(n).pipe(
451
- k(
452
- s.pipe(Z, F(i))
485
+ S(
486
+ (i) => K(t).pipe(
487
+ b(
488
+ n.pipe(ie, X(i))
453
489
  )
454
490
  )
455
491
  )
456
- ), xe = ({
457
- initialPointerEvent: n,
458
- pointerEvent$: s,
492
+ ), Ee = ({
493
+ initialPointerEvent: t,
494
+ pointerEvent$: n,
459
495
  tolerance: e
460
496
  }) => (i) => i.pipe(
461
- T(
462
- (t) => s.pipe(
463
- F(t),
464
- N((o) => !J(o), !0),
465
- c(
466
- (o) => H(n, o, e)
497
+ S(
498
+ (s) => n.pipe(
499
+ X(s),
500
+ V((p) => !ee(p), !0),
501
+ h(
502
+ (p) => Z(t, p, e)
467
503
  )
468
504
  )
469
505
  )
@@ -471,76 +507,72 @@ const Me = ({
471
507
  class be extends z {
472
508
  constructor(e) {
473
509
  super(e);
474
- h(this, "events$");
510
+ $(this, "events$");
475
511
  this.events$ = this.config$.pipe(
476
- v((i) => {
477
- const {
478
- multiTapThreshold: t = 0,
479
- maximumPressTime: o = 150,
480
- maxTaps: a = 1,
481
- tolerance: r = 10
482
- } = i.options ?? {}, p = this.pointerDown$.pipe(
483
- K({
512
+ g((i) => {
513
+ var d, E;
514
+ const s = ((d = i.options) == null ? void 0 : d.maxTaps) ?? 1, p = ((E = i.options) == null ? void 0 : E.multiTapThreshold) ?? 100 * (s - 1), { maximumPressTime: a = 150, tolerance: o = 10 } = i.options ?? {}, r = this.pointerDown$.pipe(
515
+ te({
484
516
  pointerEvent$: this.pointerEvent$,
485
517
  trackMove: !0
486
518
  }),
487
- x(1)
488
- ), l = p.pipe(
489
- c(({ pointers: d }) => d.length > 1)
490
- ), $ = (d) => d.pipe(
491
- ae(this.pointerUp$.pipe(le(t))),
492
- X()
519
+ M(1)
520
+ ), l = r.pipe(
521
+ h(({ pointers: A }) => A.length > 1)
522
+ ), u = (A) => A.pipe(
523
+ he(this.pointerUp$.pipe(ce(p))),
524
+ F()
493
525
  );
494
526
  return y(
495
527
  this.pointerDown$,
496
- p.pipe(re())
528
+ r.pipe(le())
497
529
  ).pipe(
498
- _((d) => {
499
- const A = y(
500
- b(d),
530
+ J((A) => {
531
+ const m = y(
532
+ T(A),
501
533
  this.pointerDown$
502
- ).pipe(x(1)), P = A.pipe($), g = A.pipe(
503
- xe({
504
- initialPointerEvent: d,
534
+ ).pipe(M(1)), D = m.pipe(u), Y = m.pipe(
535
+ Ee({
536
+ initialPointerEvent: A,
505
537
  pointerEvent$: this.pointerEvent$,
506
- tolerance: r
538
+ tolerance: o
507
539
  })
508
- ), E = A.pipe(
540
+ ), B = m.pipe(
509
541
  Me({
510
542
  pointerEvent$: this.pointerEvent$,
511
- timeout: o
543
+ timeout: a
512
544
  })
513
- ), V = y(
514
- this.failWith$,
545
+ ), C = y(
546
+ this.failWithActive$.pipe(h((w) => w)),
515
547
  this.pointerCancel$,
516
548
  l,
517
- g,
518
- E
519
- ), I = P.pipe(
520
- De,
521
- c((w) => w.length <= a),
522
- u((w) => ({
549
+ Y,
550
+ B
551
+ ), k = D.pipe(
552
+ fe,
553
+ h((w) => w.length <= s),
554
+ c((w) => ({
523
555
  type: "tap",
524
556
  taps: w.length,
525
557
  latestActivePointers: w,
526
558
  event: w[0]
527
559
  })),
528
- x(1)
560
+ M(1)
529
561
  );
530
- return I.pipe(
531
- Q,
532
- Y(I),
533
- u(([w, { type: L, taps: R }]) => ({
562
+ return k.pipe(
563
+ ne,
564
+ L(k),
565
+ c(([w, { type: O, taps: v }]) => ({
534
566
  ...w,
535
- type: L,
536
- taps: R
567
+ type: O,
568
+ taps: v
537
569
  })),
538
- k(V)
570
+ b(C)
539
571
  );
540
572
  })
541
573
  );
542
574
  }),
543
- f()
575
+ P()
544
576
  );
545
577
  }
546
578
  update(e) {
@@ -554,153 +586,156 @@ class Ce extends z {
554
586
  posThreshold: 15,
555
587
  ...e.options
556
588
  });
557
- h(this, "events$");
589
+ $(this, "events$");
558
590
  this.events$ = this.config$.pipe(
559
- v(() => {
591
+ g(() => {
560
592
  const i = this.panStart$.pipe(
561
- u((r) => ({
562
- ...r,
593
+ c((o) => ({
594
+ ...o,
563
595
  type: "rotateStart",
564
596
  angle: 0,
565
597
  deltaAngle: 0
566
598
  })),
567
- x(1)
568
- ), t = i.pipe(
569
- v(
599
+ M(1)
600
+ ), s = i.pipe(
601
+ g(
570
602
  () => this.pan$.pipe(
571
- O((r, p) => {
572
- const l = ((r == null ? void 0 : r.angle) ?? 0) + p.deltaPointersAngle;
603
+ U((o, r) => {
604
+ const l = ((o == null ? void 0 : o.angle) ?? 0) + r.deltaPointersAngle;
573
605
  return {
606
+ ...o,
574
607
  ...r,
575
- ...p,
576
608
  angle: l,
577
- deltaAngle: p.deltaPointersAngle
609
+ deltaAngle: r.deltaPointersAngle
578
610
  };
579
611
  }, void 0)
580
612
  )
581
613
  ),
582
- f()
583
- ), o = t.pipe(
584
- c((r) => r.type === "move"),
585
- u((r) => ({ ...r, type: "rotateMove" }))
586
- ), a = t.pipe(
587
- c((r) => r.type === "end"),
588
- u((r) => ({ ...r, type: "rotateEnd" }))
614
+ P()
615
+ ), p = s.pipe(
616
+ h((o) => o.type === "move"),
617
+ c((o) => ({ ...o, type: "rotateMove" }))
618
+ ), a = s.pipe(
619
+ h((o) => o.type === "end"),
620
+ c((o) => ({ ...o, type: "rotateEnd" }))
589
621
  );
590
- return y(i, o, a);
622
+ return y(i, p, a);
591
623
  }),
592
- f()
624
+ P()
593
625
  );
594
626
  }
595
627
  update(e) {
596
628
  super.update(e, e.options);
597
629
  }
598
630
  }
599
- const U = ({
600
- type: n,
601
- initialEvent: s
631
+ const j = ({
632
+ type: t,
633
+ initialEvent: n
602
634
  }) => (e) => e.pipe(
603
- O((i, t) => {
604
- const a = ((i == null ? void 0 : i.pointers.length) ?? 0) !== t.pointers.length, r = (i == null ? void 0 : i.pointersAverageDistance) ?? t.pointersAverageDistance, p = a ? t.pointersAverageDistance : i && "initialPointersAverageDistance" in i ? i.initialPointersAverageDistance : t.pointersAverageDistance, l = p === 0 ? 1 : t.pointersAverageDistance / p, $ = t.pointersAverageDistance - p, D = t.pointersAverageDistance - p, d = a || r === 0 ? 1 : t.pointersAverageDistance / r;
635
+ U((i, s) => {
636
+ const a = ((i == null ? void 0 : i.pointers.length) ?? 0) !== s.pointers.length, o = (i == null ? void 0 : i.pointersAverageDistance) ?? s.pointersAverageDistance, r = a ? s.pointersAverageDistance : i && "initialPointersAverageDistance" in i ? i.initialPointersAverageDistance : s.pointersAverageDistance, l = r === 0 ? 1 : s.pointersAverageDistance / r, u = s.pointersAverageDistance - r, f = s.pointersAverageDistance - r, d = a || o === 0 ? 1 : s.pointersAverageDistance / o;
605
637
  return {
606
638
  ...i,
607
- ...t,
608
- type: n,
609
- initialPointersAverageDistance: p,
639
+ ...s,
640
+ type: t,
641
+ initialPointersAverageDistance: r,
610
642
  scale: l,
611
- distance: $,
612
- deltaDistance: D,
643
+ distance: u,
644
+ deltaDistance: f,
613
645
  deltaDistanceScale: d
614
646
  };
615
- }, s),
616
- u(({ initialPointersAverageDistance: i, ...t }) => t)
647
+ }, n),
648
+ c(({ initialPointersAverageDistance: i, ...s }) => s)
617
649
  );
618
- class ze extends z {
650
+ class Re extends z {
619
651
  constructor(e) {
620
652
  super(e, {
621
653
  ...e == null ? void 0 : e.options,
622
654
  numInputs: 2
623
655
  });
624
- h(this, "events$");
625
- h(this, "start$");
656
+ $(this, "events$");
657
+ $(this, "start$");
658
+ $(this, "end$");
626
659
  const i = this.panStart$.pipe(
627
- v(
628
- (t) => b(t).pipe(
629
- U({
660
+ g(
661
+ (s) => T(s).pipe(
662
+ j({
630
663
  type: "pinchStart",
631
664
  initialEvent: void 0
632
665
  })
633
666
  )
634
667
  ),
635
- f()
668
+ P()
636
669
  );
637
670
  this.events$ = this.config$.pipe(
638
- v(() => {
639
- const t = i.pipe(x(1)), o = t.pipe(
640
- v((r) => this.pan$.pipe(
641
- N((p) => p.type !== "end"),
642
- U({
671
+ g(() => {
672
+ const s = i.pipe(M(1)), p = s.pipe(
673
+ g((o) => this.pan$.pipe(
674
+ V((r) => r.type !== "end"),
675
+ j({
643
676
  type: "pinchMove",
644
- initialEvent: r
677
+ initialEvent: o
645
678
  })
646
679
  ))
647
- ), a = t.pipe(
648
- v(
649
- (r) => this.pan$.pipe(
680
+ ), a = s.pipe(
681
+ g(
682
+ (o) => this.pan$.pipe(
650
683
  // we cannot have a panEnd without a previous event so it will always emit
651
- he(r),
652
- ce(),
653
- c(([, p]) => p.type === "end"),
654
- v(
655
- ([p, l]) => b(l).pipe(
656
- U({
684
+ H(o),
685
+ $e(),
686
+ h(([, r]) => r.type === "end"),
687
+ g(
688
+ ([r, l]) => T(l).pipe(
689
+ j({
657
690
  type: "pinchEnd",
658
- initialEvent: p
691
+ initialEvent: r
659
692
  })
660
693
  )
661
694
  )
662
695
  )
663
696
  )
664
697
  );
665
- return y(t, o, a);
698
+ return y(s, p, a);
666
699
  }),
667
- f()
668
- ), this.start$ = i;
700
+ P()
701
+ ), this.start$ = this.events$.pipe(
702
+ h((s) => s.type === "pinchStart")
703
+ ), this.end$ = this.events$.pipe(h((s) => s.type === "pinchEnd"));
669
704
  }
670
705
  update(e) {
671
706
  super.update(e, e.options);
672
707
  }
673
708
  }
674
- class Re {
675
- constructor(s) {
676
- h(this, "events$");
677
- h(this, "recognizers");
678
- h(this, "state$");
679
- this.options = s, this.recognizers = s.recognizers, this.events$ = y(
680
- ...s.recognizers.map((e) => e.events$)
681
- ).pipe(f()), this.state$ = ue(
709
+ class ze {
710
+ constructor(n) {
711
+ $(this, "events$");
712
+ $(this, "recognizers");
713
+ $(this, "state$");
714
+ this.options = n, this.recognizers = n.recognizers, this.events$ = y(
715
+ ...n.recognizers.map((e) => e.events$)
716
+ ).pipe(P()), this.state$ = W(
682
717
  this.recognizers.map((e) => e.state$)
683
718
  ).pipe(
684
- u(
685
- (e) => e.reduce((i, t) => ({
686
- fingers: Math.max(i.fingers, t.fingers)
719
+ c(
720
+ (e) => e.reduce((i, s) => ({
721
+ fingers: Math.max(i.fingers, s.fingers)
687
722
  }))
688
723
  )
689
- ), this.update(s);
724
+ ), this.update(n);
690
725
  }
691
- update(s) {
692
- s.container && (s.container.style.touchAction = "none", s.container.style.userSelect = "none"), this.options.recognizers.forEach((e) => {
693
- e.update(s);
726
+ update(n) {
727
+ n.container && (n.container.style.touchAction = "none", n.container.style.userSelect = "none"), this.options.recognizers.forEach((e) => {
728
+ e.update(n);
694
729
  });
695
730
  }
696
731
  }
697
732
  export {
698
- Se as PanRecognizer,
699
- ze as PinchRecognizer,
700
- Re as Recognizable,
733
+ Ie as PanRecognizer,
734
+ Re as PinchRecognizer,
735
+ ze as Recognizable,
701
736
  z as Recognizer,
702
737
  Ce as RotateRecognizer,
703
- Te as SwipeRecognizer,
738
+ Se as SwipeRecognizer,
704
739
  be as TapRecognizer
705
740
  };
706
741
  //# sourceMappingURL=index.js.map