gesturx 1.8.4 → 1.8.5

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,7 +1,7 @@
1
1
  var ie = Object.defineProperty;
2
2
  var se = (t, n, e) => n in t ? ie(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
3
- var u = (t, n, e) => se(t, typeof n != "symbol" ? n + "" : n, e);
4
- import { filter as c, fromEvent as S, mergeMap as b, defer as pe, of as I, merge as g, takeWhile as V, scan as U, map as h, BehaviorSubject as q, switchMap as v, distinctUntilChanged as oe, startWith as re, shareReplay as E, combineLatest as j, exhaustMap as H, first as R, share as w, timer as J, withLatestFrom as z, takeUntil as T, skip as ae, tap as K, ignoreElements as le, buffer as he, debounceTime as ce, NEVER as ue, defaultIfEmpty as $e } from "rxjs";
3
+ var $ = (t, n, e) => se(t, typeof n != "symbol" ? n + "" : n, e);
4
+ import { filter as c, fromEvent as S, mergeMap as b, defer as pe, of as I, merge as g, takeWhile as V, scan as U, map as h, BehaviorSubject as q, switchMap as v, share as P, distinctUntilChanged as oe, startWith as re, shareReplay as M, combineLatest as j, exhaustMap as H, first as R, timer as J, withLatestFrom as z, takeUntil as T, skip as ae, tap as K, ignoreElements as le, buffer as he, debounceTime as ce, NEVER as $e, defaultIfEmpty as ue } from "rxjs";
5
5
  function de(t, n) {
6
6
  return Math.sqrt(
7
7
  Math.pow(n.x - t.x, 2) + Math.pow(n.y - t.y, 2)
@@ -40,11 +40,11 @@ function ye(t, n) {
40
40
  e,
41
41
  t[s]
42
42
  );
43
- let $ = N(
43
+ let u = N(
44
44
  i,
45
45
  n[s]
46
46
  ) - r;
47
- $ > Math.PI ? $ -= 2 * Math.PI : $ < -Math.PI && ($ += 2 * Math.PI), o += $;
47
+ u > Math.PI ? u -= 2 * Math.PI : u < -Math.PI && (u += 2 * Math.PI), o += u;
48
48
  }
49
49
  const p = o / t.length, a = p * (180 / Math.PI);
50
50
  return { radianDelta: p, degreesDelta: a };
@@ -107,7 +107,7 @@ const Z = (t) => t.type === "pointerleave" || t.type === "pointercancel" || t.ty
107
107
  }),
108
108
  U((r, l) => {
109
109
  if (s(l)) {
110
- const { [l.pointerId]: $, ...m } = (r == null ? void 0 : r.pointers) ?? {};
110
+ const { [l.pointerId]: u, ...m } = (r == null ? void 0 : r.pointers) ?? {};
111
111
  return {
112
112
  event: l,
113
113
  pointers: m
@@ -138,10 +138,10 @@ const Z = (t) => t.type === "pointerleave" || t.type === "pointercancel" || t.ty
138
138
  );
139
139
  return t.pipe(
140
140
  U((e, i) => {
141
- var f, P;
142
- const o = n(i), p = (e == null ? void 0 : e.center) ?? o, a = (e == null ? void 0 : e.deltaX) ?? 0, s = (e == null ? void 0 : e.deltaY) ?? 0, r = ((f = e == null ? void 0 : e.latestActivePointers) == null ? void 0 : f.length) ?? 1, l = ((P = i.latestActivePointers) == null ? void 0 : P.length) ?? 1, $ = ["pointerdown", "pointercancel", "pointerleave", "pointerup"].includes(
141
+ var f, E;
142
+ const o = n(i), p = (e == null ? void 0 : e.center) ?? o, a = (e == null ? void 0 : e.deltaX) ?? 0, s = (e == null ? void 0 : e.deltaY) ?? 0, r = ((f = e == null ? void 0 : e.latestActivePointers) == null ? void 0 : f.length) ?? 1, l = ((E = i.latestActivePointers) == null ? void 0 : E.length) ?? 1, u = ["pointerdown", "pointercancel", "pointerleave", "pointerup"].includes(
143
143
  i.event.type
144
- ) && r !== l, m = l > 0, { deltaX: y, deltaY: A } = $ && m ? _(o, o, a, s) : _(o, p, a, s), { degreesDelta: D } = r === l && r >= 2 && l >= 2 ? ye(
144
+ ) && r !== l, m = l > 0, { deltaX: y, deltaY: A } = u && m ? _(o, o, a, s) : _(o, p, a, s), { degreesDelta: D } = r === l && r >= 2 && l >= 2 ? ye(
145
145
  (e == null ? void 0 : e.latestActivePointers) ?? [],
146
146
  i.latestActivePointers ?? []
147
147
  ) : { degreesDelta: 0 };
@@ -164,7 +164,7 @@ const Z = (t) => t.type === "pointerleave" || t.type === "pointercancel" || t.ty
164
164
  center: s,
165
165
  event: r,
166
166
  deltaPointersAngle: l
167
- } = e, $ = p ?? [], y = Date.now() - a, { velocityX: A, velocityY: D } = De(y, i, o), f = ve(p);
167
+ } = e, u = p ?? [], y = Date.now() - a, { velocityX: A, velocityY: D } = De(y, i, o), f = ve(p);
168
168
  return {
169
169
  deltaX: i,
170
170
  deltaY: o,
@@ -172,7 +172,7 @@ const Z = (t) => t.type === "pointerleave" || t.type === "pointercancel" || t.ty
172
172
  velocityY: D,
173
173
  delay: y,
174
174
  center: s,
175
- pointers: $,
175
+ pointers: u,
176
176
  startTime: a,
177
177
  event: r,
178
178
  deltaPointersAngle: l,
@@ -184,7 +184,7 @@ const Z = (t) => t.type === "pointerleave" || t.type === "pointercancel" || t.ty
184
184
  c(
185
185
  (n) => !!n.container
186
186
  )
187
- ), ne = (t) => t.pipe(c(Z)), we = ({
187
+ ), ne = (t) => t.pipe(c(Z)), Ee = ({
188
188
  container: t,
189
189
  afterEventReceived: n = (e) => e
190
190
  }) => {
@@ -198,43 +198,51 @@ const Z = (t) => t.type === "pointerleave" || t.type === "pointercancel" || t.ty
198
198
  t,
199
199
  "pointercancel"
200
200
  ).pipe(h(n));
201
- return g(
202
- e,
203
- a,
204
- p,
205
- i,
206
- o
207
- );
201
+ return {
202
+ pointerEvents$: g(
203
+ e,
204
+ a,
205
+ p,
206
+ i,
207
+ o
208
+ ),
209
+ pointerDown$: e,
210
+ pointerCancel$: a,
211
+ pointerLeave$: p,
212
+ pointerUp$: i,
213
+ pointerMove$: o
214
+ };
208
215
  };
209
216
  class F {
210
217
  constructor(n, e) {
211
- u(this, "configSubject", new q({}));
212
- u(this, "pan$");
213
- u(this, "panStart$");
214
- u(this, "panMove$");
215
- u(this, "panEnd$");
216
- u(this, "pointerEvent$");
217
- u(this, "pointerDown$");
218
- u(this, "pointerUp$");
219
- u(this, "pointerCancel$");
220
- u(this, "pointerMove$");
221
- u(this, "pointerOff$");
222
- u(this, "state$");
223
- u(this, "config$", this.configSubject.pipe(G));
218
+ $(this, "configSubject", new q({}));
219
+ $(this, "pan$");
220
+ $(this, "panStart$");
221
+ $(this, "panMove$");
222
+ $(this, "panEnd$");
223
+ $(this, "pointerEvent$");
224
+ $(this, "pointerDown$");
225
+ $(this, "pointerUp$");
226
+ $(this, "pointerCancel$");
227
+ $(this, "pointerMove$");
228
+ $(this, "pointerOff$");
229
+ $(this, "state$");
230
+ $(this, "config$", this.configSubject.pipe(G));
224
231
  /**
225
232
  * Track active running failWith recognizers
226
233
  */
227
- u(this, "failWithActive$");
234
+ $(this, "failWithActive$");
228
235
  const i = new q({
229
236
  fingers: 0
230
237
  });
231
238
  this.pointerEvent$ = this.config$.pipe(
232
239
  v(
233
- ({ container: p, afterEventReceived: a }) => we({
240
+ ({ container: p, afterEventReceived: a }) => Ee({
234
241
  container: p,
235
242
  afterEventReceived: a
236
- })
237
- )
243
+ }).pointerEvents$
244
+ ),
245
+ P()
238
246
  ), this.pointerDown$ = this.pointerEvent$.pipe(
239
247
  c((p) => p.type === "pointerdown")
240
248
  ), this.pointerUp$ = this.pointerEvent$.pipe(
@@ -254,13 +262,13 @@ class F {
254
262
  const r = s.start$.pipe(h(() => !0)), l = s.end$.pipe(h(() => !1));
255
263
  return g(r, l).pipe(
256
264
  re(!1),
257
- E(1)
265
+ M(1)
258
266
  );
259
267
  });
260
268
  return a != null && a.length ? j(a) : j([I(!1)]);
261
269
  }),
262
270
  h((p) => p.some((a) => a)),
263
- E(1)
271
+ M(1)
264
272
  ), this.pan$ = this.configSubject.pipe(
265
273
  G,
266
274
  v((p) => {
@@ -270,19 +278,19 @@ class F {
270
278
  pointerEvent$: this.pointerEvent$,
271
279
  trackMove: !0
272
280
  }),
273
- E(1)
274
- ), $ = (f) => f.pipe(
281
+ M(1)
282
+ ), u = (f) => f.pipe(
275
283
  c(
276
- (P) => P.pointers.length >= a
284
+ (E) => E.pointers.length >= a
277
285
  )
278
- ), m = (f) => f.pipe(c((P) => P.pointers.length < a));
286
+ ), m = (f) => f.pipe(c((E) => E.pointers.length < a));
279
287
  return l.pipe(
280
- $,
288
+ u,
281
289
  H(({ pointers: f }) => {
282
- const P = l.pipe(
290
+ const E = l.pipe(
283
291
  m,
284
292
  R(),
285
- w()
293
+ P()
286
294
  ), X = J(r), C = g(
287
295
  ...f.map((d) => I(d)),
288
296
  this.pointerDown$
@@ -308,11 +316,11 @@ class F {
308
316
  event: d,
309
317
  latestActivePointers: x
310
318
  })),
311
- E({
319
+ M({
312
320
  bufferSize: 1,
313
321
  refCount: !1
314
322
  }),
315
- T(P)
323
+ T(E)
316
324
  ), O = C.pipe(
317
325
  b(
318
326
  () => l.pipe(
@@ -324,10 +332,10 @@ class F {
324
332
  }))
325
333
  )
326
334
  ),
327
- T(P)
328
- ), M = C.pipe(
335
+ T(E)
336
+ ), w = C.pipe(
329
337
  b(
330
- () => P.pipe(
338
+ () => E.pipe(
331
339
  h(({ event: d, pointers: x }) => ({
332
340
  type: "end",
333
341
  event: d,
@@ -335,8 +343,8 @@ class F {
335
343
  }))
336
344
  )
337
345
  )
338
- ), L = g(C, O, M).pipe(
339
- E(1)
346
+ ), L = g(C, O, w).pipe(
347
+ M(1)
340
348
  );
341
349
  return L.pipe(
342
350
  te,
@@ -354,7 +362,7 @@ class F {
354
362
  fingers: p.pointers.length
355
363
  });
356
364
  }),
357
- w()
365
+ P()
358
366
  ), this.panStart$ = this.pan$.pipe(
359
367
  c((p) => p.type === "start"),
360
368
  h(({ type: p, ...a }) => a)
@@ -391,9 +399,9 @@ class Se extends F {
391
399
  ...e,
392
400
  posThreshold: ((a = e == null ? void 0 : e.options) == null ? void 0 : a.posThreshold) ?? 15
393
401
  });
394
- u(this, "events$");
395
- u(this, "start$");
396
- u(this, "end$");
402
+ $(this, "events$");
403
+ $(this, "start$");
404
+ $(this, "end$");
397
405
  const i = this.panStart$.pipe(
398
406
  h((s) => ({
399
407
  type: "panStart",
@@ -402,13 +410,13 @@ class Se extends F {
402
410
  z(this.failWithActive$),
403
411
  c(([, s]) => !s),
404
412
  h(([s]) => s),
405
- w()
413
+ P()
406
414
  ), o = this.panEnd$.pipe(
407
415
  h((s) => ({
408
416
  type: "panEnd",
409
417
  ...s
410
418
  })),
411
- w()
419
+ P()
412
420
  ), p = this.panMove$.pipe(
413
421
  h((s) => ({
414
422
  type: "panMove",
@@ -418,15 +426,15 @@ class Se extends F {
418
426
  this.events$ = i.pipe(
419
427
  v((s) => {
420
428
  let r = s;
421
- const l = I(s), $ = this.failWithActive$.pipe(
429
+ const l = I(s), u = this.failWithActive$.pipe(
422
430
  c((A) => A),
423
431
  R()
424
432
  ), m = g(l, p, o).pipe(
425
433
  K((A) => {
426
434
  r = A;
427
435
  }),
428
- T($)
429
- ), y = $.pipe(
436
+ T(u)
437
+ ), y = u.pipe(
430
438
  h(() => ({
431
439
  ...r,
432
440
  type: "panEnd"
@@ -435,7 +443,7 @@ class Se extends F {
435
443
  );
436
444
  return g(m, y);
437
445
  }),
438
- w()
446
+ P()
439
447
  ), this.start$ = this.events$.pipe(
440
448
  c((s) => s.type === "panStart")
441
449
  ), this.end$ = this.events$.pipe(c((s) => s.type === "panEnd"));
@@ -444,7 +452,7 @@ class Se extends F {
444
452
  super.update(e, e.options);
445
453
  }
446
454
  }
447
- const Me = (t) => (n) => n.pipe(
455
+ const we = (t) => (n) => n.pipe(
448
456
  c((e) => Math.abs(e.velocityX) >= t || Math.abs(e.velocityY) >= t)
449
457
  );
450
458
  class be extends F {
@@ -453,13 +461,13 @@ class be extends F {
453
461
  posThreshold: 0,
454
462
  numInputs: 1
455
463
  });
456
- u(this, "events$");
464
+ $(this, "events$");
457
465
  this.events$ = this.config$.pipe(
458
466
  v((i) => {
459
467
  const { escapeVelocity: o = 0.9 } = i.options ?? {};
460
468
  return this.panStart$.pipe(
461
469
  v((p) => this.panEnd$.pipe(
462
- Me(o),
470
+ we(o),
463
471
  h((a) => ({
464
472
  type: "swipe",
465
473
  angle: ge(
@@ -469,7 +477,7 @@ class be extends F {
469
477
  ...a
470
478
  }))
471
479
  )),
472
- w()
480
+ P()
473
481
  );
474
482
  })
475
483
  );
@@ -478,7 +486,7 @@ class be extends F {
478
486
  super.update(e);
479
487
  }
480
488
  }
481
- const Ee = ({
489
+ const Me = ({
482
490
  timeout: t,
483
491
  pointerEvent$: n
484
492
  }) => (e) => e.pipe(
@@ -507,7 +515,7 @@ const Ee = ({
507
515
  class Ce extends F {
508
516
  constructor(e) {
509
517
  super(e);
510
- u(this, "events$");
518
+ $(this, "events$");
511
519
  this.events$ = this.config$.pipe(
512
520
  v((i) => {
513
521
  var y, A;
@@ -516,10 +524,10 @@ class Ce extends F {
516
524
  pointerEvent$: this.pointerEvent$,
517
525
  trackMove: !0
518
526
  }),
519
- E(1)
527
+ M(1)
520
528
  ), l = r.pipe(
521
529
  c(({ pointers: D }) => D.length > 1)
522
- ), $ = (D) => D.pipe(
530
+ ), u = (D) => D.pipe(
523
531
  he(this.pointerUp$.pipe(ce(p))),
524
532
  R()
525
533
  );
@@ -531,39 +539,39 @@ class Ce extends F {
531
539
  const f = g(
532
540
  I(D),
533
541
  this.pointerDown$
534
- ).pipe(E(1)), P = f.pipe($), X = f.pipe(
542
+ ).pipe(M(1)), E = f.pipe(u), X = f.pipe(
535
543
  xe({
536
544
  initialPointerEvent: D,
537
545
  pointerEvent$: this.pointerEvent$,
538
546
  tolerance: s
539
547
  })
540
548
  ), B = f.pipe(
541
- Ee({
549
+ Me({
542
550
  pointerEvent$: this.pointerEvent$,
543
551
  timeout: a
544
552
  })
545
553
  ), C = g(
546
- this.failWithActive$.pipe(c((M) => M)),
554
+ this.failWithActive$.pipe(c((w) => w)),
547
555
  this.pointerCancel$,
548
556
  l,
549
557
  X,
550
558
  B
551
- ), O = P.pipe(
559
+ ), O = E.pipe(
552
560
  Ae,
553
- c((M) => M.length <= o),
554
- h((M) => ({
561
+ c((w) => w.length <= o),
562
+ h((w) => ({
555
563
  type: "tap",
556
- taps: M.length,
557
- latestActivePointers: M,
558
- event: M[0]
564
+ taps: w.length,
565
+ latestActivePointers: w,
566
+ event: w[0]
559
567
  })),
560
- E(1)
568
+ M(1)
561
569
  );
562
570
  return O.pipe(
563
571
  te,
564
572
  z(O),
565
- h(([M, { type: L, taps: d }]) => ({
566
- ...M,
573
+ h(([w, { type: L, taps: d }]) => ({
574
+ ...w,
567
575
  type: L,
568
576
  taps: d
569
577
  })),
@@ -572,7 +580,7 @@ class Ce extends F {
572
580
  })
573
581
  );
574
582
  }),
575
- w()
583
+ P()
576
584
  );
577
585
  }
578
586
  update(e) {
@@ -586,7 +594,7 @@ class Re extends F {
586
594
  posThreshold: 15,
587
595
  ...e.options
588
596
  });
589
- u(this, "events$");
597
+ $(this, "events$");
590
598
  this.events$ = this.config$.pipe(
591
599
  v(() => {
592
600
  const i = this.panStart$.pipe(
@@ -596,7 +604,7 @@ class Re extends F {
596
604
  angle: 0,
597
605
  deltaAngle: 0
598
606
  })),
599
- E(1)
607
+ M(1)
600
608
  ), o = i.pipe(
601
609
  v(
602
610
  () => this.pan$.pipe(
@@ -611,7 +619,7 @@ class Re extends F {
611
619
  }, void 0)
612
620
  )
613
621
  ),
614
- w()
622
+ P()
615
623
  ), p = o.pipe(
616
624
  c((s) => s.type === "move"),
617
625
  h((s) => ({ ...s, type: "rotateMove" }))
@@ -621,7 +629,7 @@ class Re extends F {
621
629
  );
622
630
  return g(i, p, a);
623
631
  }),
624
- w()
632
+ P()
625
633
  );
626
634
  }
627
635
  update(e) {
@@ -633,14 +641,14 @@ const Y = ({
633
641
  initialEvent: n
634
642
  }) => (e) => e.pipe(
635
643
  U((i, o) => {
636
- const a = ((i == null ? void 0 : i.pointers.length) ?? 0) !== o.pointers.length, s = (i == null ? void 0 : i.pointersAverageDistance) ?? o.pointersAverageDistance, r = a ? o.pointersAverageDistance : i && "initialPointersAverageDistance" in i ? i.initialPointersAverageDistance : o.pointersAverageDistance, l = r === 0 ? 1 : o.pointersAverageDistance / r, $ = o.pointersAverageDistance - r, m = o.pointersAverageDistance - r, y = a || s === 0 ? 1 : o.pointersAverageDistance / s;
644
+ const a = ((i == null ? void 0 : i.pointers.length) ?? 0) !== o.pointers.length, s = (i == null ? void 0 : i.pointersAverageDistance) ?? o.pointersAverageDistance, r = a ? o.pointersAverageDistance : i && "initialPointersAverageDistance" in i ? i.initialPointersAverageDistance : o.pointersAverageDistance, l = r === 0 ? 1 : o.pointersAverageDistance / r, u = o.pointersAverageDistance - r, m = o.pointersAverageDistance - r, y = a || s === 0 ? 1 : o.pointersAverageDistance / s;
637
645
  return {
638
646
  ...i,
639
647
  ...o,
640
648
  type: t,
641
649
  initialPointersAverageDistance: r,
642
650
  scale: l,
643
- distance: $,
651
+ distance: u,
644
652
  deltaDistance: m,
645
653
  deltaDistanceScale: y
646
654
  };
@@ -653,9 +661,9 @@ class ze extends F {
653
661
  ...e == null ? void 0 : e.options,
654
662
  numInputs: 2
655
663
  });
656
- u(this, "events$");
657
- u(this, "start$");
658
- u(this, "end$");
664
+ $(this, "events$");
665
+ $(this, "start$");
666
+ $(this, "end$");
659
667
  this.events$ = this.config$.pipe(
660
668
  v(() => {
661
669
  const i = this.panStart$.pipe(
@@ -671,7 +679,7 @@ class ze extends F {
671
679
  })
672
680
  )
673
681
  ),
674
- E(1)
682
+ M(1)
675
683
  ), o = this.failWithActive$.pipe(
676
684
  c((s) => s),
677
685
  R()
@@ -688,9 +696,9 @@ class ze extends F {
688
696
  v((s) => {
689
697
  let r = s;
690
698
  return this.pan$.pipe(
691
- v((l) => l.type === "end" ? I(l) : (r = l, ue)),
699
+ v((l) => l.type === "end" ? I(l) : (r = l, $e)),
692
700
  T(o),
693
- $e(null),
701
+ ue(null),
694
702
  h(
695
703
  (l) => l || r
696
704
  ),
@@ -698,13 +706,13 @@ class ze extends F {
698
706
  type: "pinchEnd",
699
707
  initialEvent: r
700
708
  }),
701
- w()
709
+ P()
702
710
  );
703
711
  })
704
712
  );
705
713
  return g(i, p, a);
706
714
  }),
707
- w()
715
+ P()
708
716
  ), this.start$ = this.events$.pipe(
709
717
  c((i) => i.type === "pinchStart")
710
718
  ), this.end$ = this.events$.pipe(c((i) => i.type === "pinchEnd"));
@@ -715,12 +723,12 @@ class ze extends F {
715
723
  }
716
724
  class ke {
717
725
  constructor(n) {
718
- u(this, "events$");
719
- u(this, "recognizers");
720
- u(this, "state$");
726
+ $(this, "events$");
727
+ $(this, "recognizers");
728
+ $(this, "state$");
721
729
  this.options = n, this.recognizers = n.recognizers, this.events$ = g(
722
730
  ...n.recognizers.map((e) => e.events$)
723
- ).pipe(w()), this.state$ = j(
731
+ ).pipe(P()), this.state$ = j(
724
732
  this.recognizers.map((e) => e.state$)
725
733
  ).pipe(
726
734
  h(