UNPKG

igniteui-react-core

Version:
542 lines (541 loc) 16.6 kB
/* THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE: https://www.infragistics.com/legal/license/igultimate-la https://www.infragistics.com/legal/license/igultimate-eula GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company. */ import { Base, Point_$type, runOn, markType } from "./type"; import { TouchVelocityTracker } from "./TouchVelocityTracker"; import { TouchPointInfo } from "./TouchPointInfo"; import { TouchGestureEventArgs } from "./TouchGestureEventArgs"; import { isNaN_ } from "./number"; /** * @hidden */ export let TouchGestureRecognizer = /*@__PURE__*/ (() => { class TouchGestureRecognizer extends Base { constructor(a) { super(); this.n = 0; this.p = new TouchVelocityTracker(); this.u = 0; this.v = 0; this.ab = 0; this.ac = 0; this.w = 0; this.x = 0; this.an = NaN; this.ao = NaN; this.am = NaN; this.ak = 1; this.al = 1; this.z = 1; this.y = 10; this.az = -1; this.ap = 0; this.aq = 0; this.a0 = 0; this.ag = 1; this.ah = 1; this.ad = 1; this.ae = NaN; this.af = NaN; this.r = false; this.o = null; this.av = 800; this.ax = -1; this.b = null; this.q = false; this.ay = -1; this.holdStarting = null; this.holdEnding = null; this.panStarting = null; this.manipulationStarting = null; this.manipulationChanging = null; this.manipulationEnding = null; this.panEnding = null; this.zoomStarting = null; this.zoomEnding = null; this.flingStarting = null; this.doubleTapped = null; this.ai = 0; this.aj = 0; this.aa = 0; this.ar = 0; this.as = 0; this.a0 = 500; this.n = 0; this.b = a; } get aw() { return this.y; } set aw(a) { this.y = a; } get at() { return this.u; } get au() { return this.v; } bh() { return { $type: Point_$type, x: Math.abs(this.w - this.ab), y: Math.abs(this.x - this.ac) }; } bf(a) { let b = false; if (!isNaN_(this.ab) && !isNaN_(this.ac)) { this.w = a._inner[0].a; this.x = a._inner[0].b; if (Math.abs(a._inner[0].a - this.ab) > this.y || Math.abs(a._inner[0].b - this.ac) > this.y) { b = true; } } if (b) { this.be(); } } a7(a) { let b = a.count; let c = this.n; let d = false; let e = false; let f = false; let g = false; let h = false; let i = false; let j = false; let k = false; let l = 0; let m = 0; let n = 0; let o = this.n; if (b > 0 && b < 2) { switch (this.n) { case 5: this.r = false; c = 4; e = true; j = true; break; case 0: c = 4; e = true; break; case 2: c = 1; j = true; g = true; break; } } if (b > 1) { switch (this.n) { case 5: this.r = false; c = 2; h = true; k = true; break; case 4: f = true; c = 2; h = true; break; case 0: c = 2; h = true; break; case 1: c = 2; i = true; h = true; break; } } if (b == 0) { switch (this.n) { case 4: if (this.s(new TouchPointInfo(0, this.u, this.v))) { c = 0; f = true; if (this.doubleTapped != null) { this.doubleTapped(this, this.c()); } } else { f = true; c = 0; } break; case 1: c = 0; i = true; break; case 2: c = 0; g = true; break; case 3: c = 0; d = true; break; } } if (k || this.r) { if (j) { if (this.panEnding != null) { this.panEnding(this, this.c()); } if (this.manipulationEnding != null) { this.manipulationEnding(this, this.c()); } } this.a2(); } if (e) { this.ab = a._inner[0].a; this.ac = a._inner[0].b; } if (c == 4) { if (!isNaN_(this.ab) && !isNaN_(this.ac)) { this.w = a._inner[0].a; this.x = a._inner[0].b; if (Math.abs(a._inner[0].a - this.ab) > this.y || Math.abs(a._inner[0].b - this.ac) > this.y) { f = true; j = true; c = 1; } } } let p = 0; let q = 0; for (let r = 0; r < b; r++) { p += a._inner[r].a; q += a._inner[r].b; } p /= b; q /= b; if (b == 0) { p = this.ae; q = this.af; } this.u = p; this.v = q; this.p.g(this.u, this.v, this.a1()); if (h) { let s = a._inner[0].a - a._inner[1].a; let t = a._inner[0].b - a._inner[1].b; this.an = Math.abs(s); this.ao = Math.abs(t); this.am = Math.sqrt(s * s + t * t); if (this.an < 1) { this.an = 1; } if (this.ao < 1) { this.ao = 1; } if (this.am < 1) { this.am = 1; } } if (c == 2) { let u = a._inner[0].a - a._inner[1].a; let v = a._inner[0].b - a._inner[1].b; l = Math.abs(u); m = Math.abs(v); n = Math.sqrt(u * u + v * v); if (l < 1) { l = 1; } if (m < 1) { m = 1; } if (n < 1) { n = 1; } this.ak = l / this.an; this.al = m / this.ao; this.z = n / this.am; } else { this.an = NaN; this.ao = NaN; this.ak = 1; this.al = 1; this.ai = 1; this.aj = 1; this.aa = 1; } this.n = c; if (o == 0 && this.n == 1 || this.n == 2) { if (this.manipulationStarting != null) { this.manipulationStarting(this, this.c()); } } if (g) { this.a6(); } if (i) { this.a5(); } if (d) { this.a4(); } if (f) { this.be(); } if (j) { this.bb(); } if (e) { this.ba(); } if (h) { this.bc(); } if (this.n == 2) { this.ai = this.ak / this.ag; this.aj = this.al / this.ah; this.aa = this.z / this.ad; this.ar = this.u - this.ae; this.as = this.v - this.af; this.ag = this.ag * this.ai; this.ah = this.ah * this.aj; this.ad = this.ad * this.aa; this.ae = this.u; this.af = this.v; if (this.manipulationChanging != null) { this.manipulationChanging(this, this.c()); } } if (this.n == 1) { this.ar = this.u - this.ae; this.as = this.v - this.af; this.ae = this.u; this.af = this.v; if (this.manipulationChanging != null) { this.manipulationChanging(this, this.c()); } } this.ae = this.u; this.af = this.v; if ((i || g) && this.n == 0) { if (this.manipulationEnding != null) { this.manipulationEnding(this, this.c()); } } } s(a) { let b = this.a1(); if ((b - this.az) < 500) { if (Math.abs(a.a - this.ap) < 50 && Math.abs(a.b - this.aq) < 50) { return true; } } this.ap = a.a; this.aq = a.b; this.az = b; return false; } ba() { this.ay = this.a1(); if (!this.q) { this.q = true; this.b.executeDelayed(runOn(this, this.a3), 1000); } } a3() { if (!this.q) { return; } let a = this.a1(); if (a - this.ay >= this.a0) { this.a9(); } else { this.b.executeDelayed(runOn(this, this.a3), (this.a0 - (a - this.ay))); } } be() { this.q = false; } a6() { this.p.f(); if (this.zoomEnding != null) { this.zoomEnding(this, this.c()); } } a9() { if (this.holdStarting != null) { this.holdStarting(this, this.c()); } } bc() { this.p.f(); this.a2(); this.ag = 1; this.ah = 1; this.ad = 1; this.ae = this.u; this.af = this.v; if (this.zoomStarting != null) { this.zoomStarting(this, this.c()); } } a4() { if (this.holdEnding != null) { this.holdEnding(this, this.c()); } } bb() { this.p.f(); this.a2(); this.ae = this.u; this.af = this.v; if (this.panStarting != null) { this.panStarting(this, this.c()); } } bd() { if (this.n == 5) { this.r = true; } } a2() { this.r = false; if (this.n == 5) { this.n = 0; } } bg() { if (this.n != 5) { this.r = false; return; } if (this.o == null || this.ax == -1) { this.a2(); return; } let a = this.a1(); let b = a - this.ax; if (b < 16) { this.a8(runOn(this, this.bg)); return; } this.ax = a; let c = b / 1000; let d = this.av * c; let e = this.o; if (e.a > 0) { e.a -= d; if (e.a < 0) { e.a = 0; } } if (e.a < 0) { e.a += d; if (e.a > 0) { e.a = 0; } } if (e.b > 0) { e.b -= d; if (e.b < 0) { e.b = 0; } } if (e.b < 0) { e.b += d; if (e.b > 0) { e.b = 0; } } if ((e.a == 0 && e.b == 0) || this.r) { this.n = 0; if (this.panEnding != null) { this.panEnding(this, this.c()); } if (this.manipulationEnding != null) { this.manipulationEnding(this, this.c()); } this.a2(); return; } this.u += e.a * c; this.v += e.b * c; this.ar = this.u - this.ae; this.as = this.v - this.af; this.ae = this.u; this.af = this.v; if (this.manipulationChanging != null) { this.manipulationChanging(this, this.c()); } this.a8(runOn(this, this.bg)); } t(a) { this.r = false; if (this.n == 5) { this.a2(); } this.ax = this.a1(); this.o = a; this.n = 5; this.a8(runOn(this, this.bg)); if (this.flingStarting != null) { if (!this.flingStarting(this, this.c())) { this.a2(); return false; } } return true; } a8(a) { this.b.enqueueAnimationAction(a); } a5() { let a = this.p.b(this.a1()); if ((a.a > 5 || a.a < -5 || a.b > 5 || a.b < -5) && this.n == 0) { this.n = 1; if (!this.t(a)) { if (this.n == 0) { if (this.panEnding != null) { this.panEnding(this, this.c()); } if (this.manipulationEnding != null) { this.manipulationEnding(this, this.c()); } } } } else { if (this.panEnding != null) { this.panEnding(this, this.c()); } if (this.n == 0) { if (this.manipulationEnding != null) { this.manipulationEnding(this, this.c()); } } } } c() { let a = new TouchGestureEventArgs(); a.a = this.u; a.b = this.v; a.d = this.ai; a.e = this.aj; a.c = this.aa; a.f = this.ar; a.g = this.as; a.h = this.o != null ? this.o.a : this.p.b(this.a1()).a; a.i = this.o != null ? this.o.b : this.p.b(this.a1()).b; return a; } a1() { return this.b.getCurrentRelativeTime(); } } TouchGestureRecognizer.$t = /*@__PURE__*/ markType(TouchGestureRecognizer, 'TouchGestureRecognizer'); return TouchGestureRecognizer; })();