gesturx 1.7.6 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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 v, takeWhile as V, scan as U, map as c, BehaviorSubject as q, switchMap as y, distinctUntilChanged as re, startWith as H, shareReplay as M, combineLatest as W, exhaustMap as J, first as F, share as w, 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));
94
- return y(
91
+ return n.pipe(
92
+ S((r) => {
93
+ const l = oe(() => T(r));
94
+ return v(
95
95
  l,
96
- y(
97
- o,
98
- t,
96
+ v(
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));
201
- return y(
200
+ ).pipe(c(n));
201
+ return v(
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
+ y(
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
+ y((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 v(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
+ y((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
+ w()
286
+ ), Y = K(r), C = v(
287
+ ...m.map((g) => T(g)),
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
+ (g) => v(this.pointerMove$, T(g)).pipe(
292
+ X(g),
293
+ h(
294
+ (x) => Z(
295
+ g,
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
+ y(() => Y),
305
+ L(l),
306
+ c(([, { event: g, pointers: x }]) => ({
293
307
  type: "start",
294
- event: m,
295
- latestActivePointers: M
308
+ event: g,
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: g, pointers: x }) => ({
307
321
  type: "move",
308
- event: m,
309
- latestActivePointers: M
322
+ event: g,
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
+ ), P = C.pipe(
329
+ S(
330
+ () => D.pipe(
331
+ c(({ event: g, pointers: x }) => ({
318
332
  type: "end",
319
- event: m,
320
- latestActivePointers: M
333
+ event: g,
334
+ latestActivePointers: x
321
335
  }))
322
336
  )
323
337
  )
324
- ), R = y(I, w, L).pipe(
325
- x(1)
338
+ ), O = v(C, k, P).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(([g, { type: x }]) => ({
345
+ ...g,
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
+ w()
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,97 @@ 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
+ w()
406
+ ), s = this.panEnd$.pipe(
407
+ c((o) => ({
391
408
  type: "panEnd",
392
- ...a
409
+ ...o
393
410
  })),
394
- f()
411
+ w()
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$ = v(
419
+ i.pipe(
420
+ y((o) => {
421
+ let r = o;
422
+ const l = this.failWithActive$.pipe(
423
+ h((d) => d),
424
+ F()
425
+ ), u = v(T(o), p, s).pipe(
426
+ Q((d) => {
427
+ r = d;
428
+ }),
429
+ b(l)
430
+ ), f = l.pipe(
431
+ c(() => ({
432
+ ...r,
433
+ type: "panEnd"
434
+ })),
435
+ b(s)
436
+ );
437
+ return v(u, f);
438
+ })
439
+ )
440
+ ), this.start$ = this.events$.pipe(
441
+ h((o) => o.type === "panStart")
442
+ ), this.end$ = this.events$.pipe(h((o) => o.type === "panEnd"));
406
443
  }
407
444
  update(e) {
408
445
  super.update(e, e.options);
409
446
  }
410
447
  }
411
- const we = (n) => (s) => s.pipe(
412
- c((e) => Math.abs(e.velocityX) >= n || Math.abs(e.velocityY) >= n)
448
+ const we = (t) => (n) => n.pipe(
449
+ h((e) => Math.abs(e.velocityX) >= t || Math.abs(e.velocityY) >= t)
413
450
  );
414
- class Te extends z {
451
+ class Se extends z {
415
452
  constructor(e) {
416
453
  super(e, {
417
454
  posThreshold: 0,
418
455
  numInputs: 1
419
456
  });
420
- h(this, "events$");
457
+ $(this, "events$");
421
458
  this.events$ = this.config$.pipe(
422
- v((i) => {
423
- const { escapeVelocity: t = 0.9 } = i.options ?? {};
459
+ y((i) => {
460
+ const { escapeVelocity: s = 0.9 } = i.options ?? {};
424
461
  return this.panStart$.pipe(
425
- v((o) => this.panEnd$.pipe(
426
- we(t),
427
- u((a) => ({
462
+ y((p) => this.panEnd$.pipe(
463
+ we(s),
464
+ c((a) => ({
428
465
  type: "swipe",
429
- angle: ge(
430
- o.event,
466
+ angle: ve(
467
+ p.event,
431
468
  a.event
432
469
  ),
433
470
  ...a
434
471
  }))
435
472
  )),
436
- f()
473
+ w()
437
474
  );
438
475
  })
439
476
  );
@@ -443,27 +480,27 @@ class Te extends z {
443
480
  }
444
481
  }
445
482
  const Me = ({
446
- timeout: n,
447
- pointerEvent$: s
483
+ timeout: t,
484
+ pointerEvent$: n
448
485
  }) => (e) => e.pipe(
449
- T(
450
- (i) => G(n).pipe(
451
- k(
452
- s.pipe(Z, F(i))
486
+ S(
487
+ (i) => K(t).pipe(
488
+ b(
489
+ n.pipe(ie, X(i))
453
490
  )
454
491
  )
455
492
  )
456
- ), xe = ({
457
- initialPointerEvent: n,
458
- pointerEvent$: s,
493
+ ), Ee = ({
494
+ initialPointerEvent: t,
495
+ pointerEvent$: n,
459
496
  tolerance: e
460
497
  }) => (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)
498
+ S(
499
+ (s) => n.pipe(
500
+ X(s),
501
+ V((p) => !ee(p), !0),
502
+ h(
503
+ (p) => Z(t, p, e)
467
504
  )
468
505
  )
469
506
  )
@@ -471,76 +508,72 @@ const Me = ({
471
508
  class be extends z {
472
509
  constructor(e) {
473
510
  super(e);
474
- h(this, "events$");
511
+ $(this, "events$");
475
512
  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({
513
+ y((i) => {
514
+ var d, E;
515
+ 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(
516
+ te({
484
517
  pointerEvent$: this.pointerEvent$,
485
518
  trackMove: !0
486
519
  }),
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()
520
+ M(1)
521
+ ), l = r.pipe(
522
+ h(({ pointers: A }) => A.length > 1)
523
+ ), u = (A) => A.pipe(
524
+ he(this.pointerUp$.pipe(ce(p))),
525
+ F()
493
526
  );
494
- return y(
527
+ return v(
495
528
  this.pointerDown$,
496
- p.pipe(re())
529
+ r.pipe(le())
497
530
  ).pipe(
498
- _((d) => {
499
- const A = y(
500
- b(d),
531
+ J((A) => {
532
+ const m = v(
533
+ T(A),
501
534
  this.pointerDown$
502
- ).pipe(x(1)), P = A.pipe($), g = A.pipe(
503
- xe({
504
- initialPointerEvent: d,
535
+ ).pipe(M(1)), D = m.pipe(u), Y = m.pipe(
536
+ Ee({
537
+ initialPointerEvent: A,
505
538
  pointerEvent$: this.pointerEvent$,
506
- tolerance: r
539
+ tolerance: o
507
540
  })
508
- ), E = A.pipe(
541
+ ), B = m.pipe(
509
542
  Me({
510
543
  pointerEvent$: this.pointerEvent$,
511
- timeout: o
544
+ timeout: a
512
545
  })
513
- ), V = y(
514
- this.failWith$,
546
+ ), C = v(
547
+ this.failWithActive$.pipe(h((P) => P)),
515
548
  this.pointerCancel$,
516
549
  l,
517
- g,
518
- E
519
- ), I = P.pipe(
520
- De,
521
- c((w) => w.length <= a),
522
- u((w) => ({
550
+ Y,
551
+ B
552
+ ), k = D.pipe(
553
+ fe,
554
+ h((P) => P.length <= s),
555
+ c((P) => ({
523
556
  type: "tap",
524
- taps: w.length,
525
- latestActivePointers: w,
526
- event: w[0]
557
+ taps: P.length,
558
+ latestActivePointers: P,
559
+ event: P[0]
527
560
  })),
528
- x(1)
561
+ M(1)
529
562
  );
530
- return I.pipe(
531
- Q,
532
- Y(I),
533
- u(([w, { type: L, taps: R }]) => ({
534
- ...w,
535
- type: L,
536
- taps: R
563
+ return k.pipe(
564
+ ne,
565
+ L(k),
566
+ c(([P, { type: O, taps: g }]) => ({
567
+ ...P,
568
+ type: O,
569
+ taps: g
537
570
  })),
538
- k(V)
571
+ b(C)
539
572
  );
540
573
  })
541
574
  );
542
575
  }),
543
- f()
576
+ w()
544
577
  );
545
578
  }
546
579
  update(e) {
@@ -554,153 +587,156 @@ class Ce extends z {
554
587
  posThreshold: 15,
555
588
  ...e.options
556
589
  });
557
- h(this, "events$");
590
+ $(this, "events$");
558
591
  this.events$ = this.config$.pipe(
559
- v(() => {
592
+ y(() => {
560
593
  const i = this.panStart$.pipe(
561
- u((r) => ({
562
- ...r,
594
+ c((o) => ({
595
+ ...o,
563
596
  type: "rotateStart",
564
597
  angle: 0,
565
598
  deltaAngle: 0
566
599
  })),
567
- x(1)
568
- ), t = i.pipe(
569
- v(
600
+ M(1)
601
+ ), s = i.pipe(
602
+ y(
570
603
  () => this.pan$.pipe(
571
- O((r, p) => {
572
- const l = ((r == null ? void 0 : r.angle) ?? 0) + p.deltaPointersAngle;
604
+ U((o, r) => {
605
+ const l = ((o == null ? void 0 : o.angle) ?? 0) + r.deltaPointersAngle;
573
606
  return {
607
+ ...o,
574
608
  ...r,
575
- ...p,
576
609
  angle: l,
577
- deltaAngle: p.deltaPointersAngle
610
+ deltaAngle: r.deltaPointersAngle
578
611
  };
579
612
  }, void 0)
580
613
  )
581
614
  ),
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" }))
615
+ w()
616
+ ), p = s.pipe(
617
+ h((o) => o.type === "move"),
618
+ c((o) => ({ ...o, type: "rotateMove" }))
619
+ ), a = s.pipe(
620
+ h((o) => o.type === "end"),
621
+ c((o) => ({ ...o, type: "rotateEnd" }))
589
622
  );
590
- return y(i, o, a);
623
+ return v(i, p, a);
591
624
  }),
592
- f()
625
+ w()
593
626
  );
594
627
  }
595
628
  update(e) {
596
629
  super.update(e, e.options);
597
630
  }
598
631
  }
599
- const U = ({
600
- type: n,
601
- initialEvent: s
632
+ const j = ({
633
+ type: t,
634
+ initialEvent: n
602
635
  }) => (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;
636
+ U((i, s) => {
637
+ 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
638
  return {
606
639
  ...i,
607
- ...t,
608
- type: n,
609
- initialPointersAverageDistance: p,
640
+ ...s,
641
+ type: t,
642
+ initialPointersAverageDistance: r,
610
643
  scale: l,
611
- distance: $,
612
- deltaDistance: D,
644
+ distance: u,
645
+ deltaDistance: f,
613
646
  deltaDistanceScale: d
614
647
  };
615
- }, s),
616
- u(({ initialPointersAverageDistance: i, ...t }) => t)
648
+ }, n),
649
+ c(({ initialPointersAverageDistance: i, ...s }) => s)
617
650
  );
618
- class ze extends z {
651
+ class Re extends z {
619
652
  constructor(e) {
620
653
  super(e, {
621
654
  ...e == null ? void 0 : e.options,
622
655
  numInputs: 2
623
656
  });
624
- h(this, "events$");
625
- h(this, "start$");
657
+ $(this, "events$");
658
+ $(this, "start$");
659
+ $(this, "end$");
626
660
  const i = this.panStart$.pipe(
627
- v(
628
- (t) => b(t).pipe(
629
- U({
661
+ y(
662
+ (s) => T(s).pipe(
663
+ j({
630
664
  type: "pinchStart",
631
665
  initialEvent: void 0
632
666
  })
633
667
  )
634
668
  ),
635
- f()
669
+ w()
636
670
  );
637
671
  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({
672
+ y(() => {
673
+ const s = i.pipe(M(1)), p = s.pipe(
674
+ y((o) => this.pan$.pipe(
675
+ V((r) => r.type !== "end"),
676
+ j({
643
677
  type: "pinchMove",
644
- initialEvent: r
678
+ initialEvent: o
645
679
  })
646
680
  ))
647
- ), a = t.pipe(
648
- v(
649
- (r) => this.pan$.pipe(
681
+ ), a = s.pipe(
682
+ y(
683
+ (o) => this.pan$.pipe(
650
684
  // 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({
685
+ H(o),
686
+ $e(),
687
+ h(([, r]) => r.type === "end"),
688
+ y(
689
+ ([r, l]) => T(l).pipe(
690
+ j({
657
691
  type: "pinchEnd",
658
- initialEvent: p
692
+ initialEvent: r
659
693
  })
660
694
  )
661
695
  )
662
696
  )
663
697
  )
664
698
  );
665
- return y(t, o, a);
699
+ return v(s, p, a);
666
700
  }),
667
- f()
668
- ), this.start$ = i;
701
+ w()
702
+ ), this.start$ = this.events$.pipe(
703
+ h((s) => s.type === "pinchStart")
704
+ ), this.end$ = this.events$.pipe(h((s) => s.type === "pinchEnd"));
669
705
  }
670
706
  update(e) {
671
707
  super.update(e, e.options);
672
708
  }
673
709
  }
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(
710
+ class ze {
711
+ constructor(n) {
712
+ $(this, "events$");
713
+ $(this, "recognizers");
714
+ $(this, "state$");
715
+ this.options = n, this.recognizers = n.recognizers, this.events$ = v(
716
+ ...n.recognizers.map((e) => e.events$)
717
+ ).pipe(w()), this.state$ = W(
682
718
  this.recognizers.map((e) => e.state$)
683
719
  ).pipe(
684
- u(
685
- (e) => e.reduce((i, t) => ({
686
- fingers: Math.max(i.fingers, t.fingers)
720
+ c(
721
+ (e) => e.reduce((i, s) => ({
722
+ fingers: Math.max(i.fingers, s.fingers)
687
723
  }))
688
724
  )
689
- ), this.update(s);
725
+ ), this.update(n);
690
726
  }
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);
727
+ update(n) {
728
+ n.container && (n.container.style.touchAction = "none", n.container.style.userSelect = "none"), this.options.recognizers.forEach((e) => {
729
+ e.update(n);
694
730
  });
695
731
  }
696
732
  }
697
733
  export {
698
- Se as PanRecognizer,
699
- ze as PinchRecognizer,
700
- Re as Recognizable,
734
+ Ie as PanRecognizer,
735
+ Re as PinchRecognizer,
736
+ ze as Recognizable,
701
737
  z as Recognizer,
702
738
  Ce as RotateRecognizer,
703
- Te as SwipeRecognizer,
739
+ Se as SwipeRecognizer,
704
740
  be as TapRecognizer
705
741
  };
706
742
  //# sourceMappingURL=index.js.map