igniteui-react-core
Version:
Ignite UI React Core.
556 lines (555 loc) • 16.1 kB
JavaScript
/*
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 { __extends } from "tslib";
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
*/
var TouchGestureRecognizer = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(TouchGestureRecognizer, _super);
function TouchGestureRecognizer(a) {
var _this = _super.call(this) || this;
_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;
return _this;
}
Object.defineProperty(TouchGestureRecognizer.prototype, "aw", {
get: function () {
return this.y;
},
set: function (a) {
this.y = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TouchGestureRecognizer.prototype, "at", {
get: function () {
return this.u;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TouchGestureRecognizer.prototype, "au", {
get: function () {
return this.v;
},
enumerable: false,
configurable: true
});
TouchGestureRecognizer.prototype.bh = function () {
return { $type: Point_$type, x: Math.abs(this.w - this.ab), y: Math.abs(this.x - this.ac) };
};
TouchGestureRecognizer.prototype.bf = function (a) {
var 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();
}
};
TouchGestureRecognizer.prototype.a7 = function (a) {
var b = a.count;
var c = this.n;
var d = false;
var e = false;
var f = false;
var g = false;
var h = false;
var i = false;
var j = false;
var k = false;
var l = 0;
var m = 0;
var n = 0;
var 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;
}
}
}
var p = 0;
var q = 0;
for (var 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) {
var s = a._inner[0].a - a._inner[1].a;
var 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) {
var u = a._inner[0].a - a._inner[1].a;
var 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());
}
}
};
TouchGestureRecognizer.prototype.s = function (a) {
var 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;
};
TouchGestureRecognizer.prototype.ba = function () {
this.ay = this.a1();
if (!this.q) {
this.q = true;
this.b.executeDelayed(runOn(this, this.a3), 1000);
}
};
TouchGestureRecognizer.prototype.a3 = function () {
if (!this.q) {
return;
}
var a = this.a1();
if (a - this.ay >= this.a0) {
this.a9();
}
else {
this.b.executeDelayed(runOn(this, this.a3), (this.a0 - (a - this.ay)));
}
};
TouchGestureRecognizer.prototype.be = function () {
this.q = false;
};
TouchGestureRecognizer.prototype.a6 = function () {
this.p.f();
if (this.zoomEnding != null) {
this.zoomEnding(this, this.c());
}
};
TouchGestureRecognizer.prototype.a9 = function () {
if (this.holdStarting != null) {
this.holdStarting(this, this.c());
}
};
TouchGestureRecognizer.prototype.bc = function () {
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());
}
};
TouchGestureRecognizer.prototype.a4 = function () {
if (this.holdEnding != null) {
this.holdEnding(this, this.c());
}
};
TouchGestureRecognizer.prototype.bb = function () {
this.p.f();
this.a2();
this.ae = this.u;
this.af = this.v;
if (this.panStarting != null) {
this.panStarting(this, this.c());
}
};
TouchGestureRecognizer.prototype.bd = function () {
if (this.n == 5) {
this.r = true;
}
};
TouchGestureRecognizer.prototype.a2 = function () {
this.r = false;
if (this.n == 5) {
this.n = 0;
}
};
TouchGestureRecognizer.prototype.bg = function () {
if (this.n != 5) {
this.r = false;
return;
}
if (this.o == null || this.ax == -1) {
this.a2();
return;
}
var a = this.a1();
var b = a - this.ax;
if (b < 16) {
this.a8(runOn(this, this.bg));
return;
}
this.ax = a;
var c = b / 1000;
var d = this.av * c;
var 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));
};
TouchGestureRecognizer.prototype.t = function (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;
};
TouchGestureRecognizer.prototype.a8 = function (a) {
this.b.enqueueAnimationAction(a);
};
TouchGestureRecognizer.prototype.a5 = function () {
var 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());
}
}
}
};
TouchGestureRecognizer.prototype.c = function () {
var 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;
};
TouchGestureRecognizer.prototype.a1 = function () {
return this.b.getCurrentRelativeTime();
};
TouchGestureRecognizer.$t = markType(TouchGestureRecognizer, 'TouchGestureRecognizer');
return TouchGestureRecognizer;
}(Base));
export { TouchGestureRecognizer };