UNPKG

igniteui-react-core

Version:
1,185 lines (1,184 loc) 34.4 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, String_$type, runOn, Type, markType, BaseError, Number_$type } from "./type"; import { LinkedList$1 } from "./LinkedList$1"; import { Dictionary$2 } from "./Dictionary$2"; import { LinkedListNode$1 } from "./LinkedListNode$1"; import { GlobalAnimationState } from "./GlobalAnimationState"; import { timeSpanTotalMilliseconds } from "./timespan"; import { dateNow } from "./date"; import { TaskCompletionSource$1 } from "./TaskCompletionSource$1"; import { isInfinity, isNaN_ } from "./number"; import { AnimationKeyFrame } from "./AnimationKeyFrame"; import { List$1 } from "./List$1"; import { UIElementPropertyId_$type } from "./UIElementPropertyId"; import { UIElementPropertyAccessor } from "./UIElementPropertyAccessor"; import { EasingFunctions } from "./EasingFunctions"; import { AnimationKeyFrameProperty } from "./AnimationKeyFrameProperty"; import { BrushUtil } from "./BrushUtil"; import { InterpolationUtil } from "./InterpolationUtil"; import { MatrixTransform } from "./MatrixTransform"; import { TransformMatrixHelpler } from "./TransformMatrixHelpler"; import { UIElementPropertyAccessorFactory } from "./UIElementPropertyAccessorFactory"; import { HashSet$1 } from "./HashSet$1"; /** * @hidden */ export let KeyFrameAnimationTimeline = /*@__PURE__*/ (() => { class KeyFrameAnimationTimeline extends Base { get b() { return this.a; } get j() { if (this.d) { return this.i; } return timeSpanTotalMilliseconds((+(dateNow()) - +(this.h))); } constructor(a, b) { super(); this.c = null; this.a = null; this.h = new Date(); this.g = new LinkedList$1(IKeyFrameAnimation_$type); this.f = new Dictionary$2(String_$type, IKeyFrameAnimation_$type, 0); this.e = new Dictionary$2(IKeyFrameAnimation_$type, LinkedListNode$1.$.specialize(IKeyFrameAnimation_$type), 0); this.k = 0; this.d = false; this.i = 0; this.l = -1; this.c = a; this.a = b; this.h = dateNow(); } m(a) { if (this.f.containsKey(a.id)) { return; } this.g.f(a); let b = this.g.d; this.e.addItem(a, b); this.f.addItem(a.id, a); let c = false; if (this.k == 0) { c = true; } this.k++; if (c) { this.n(); } GlobalAnimationState.d.l(); } o(a) { if (!this.e.containsKey(a)) { return; } let b = this.e.item(a); this.g.h(b); this.f.removeItem(a.id); this.e.removeItem(a); let c = false; this.k--; if (this.k == 0) { c = true; } if (c) { this.p(); } GlobalAnimationState.d.k(); } p() { if (this.l >= 0) { this.c.teardownTicking(this.l); this.l = -1; } } n() { this.l = this.c.setupTicking(runOn(this, this.q)); this.c.requestFrame(this.l); } q() { let a = this.j; this.i = a; try { this.d = true; let b = this.g.c; if (b == null) { this.p(); this.d = false; return; } while (b != null) { let c = b.c; let d = b.a; if (c.playState == 1) { c.aq(); } else { c.aq(); this.o(b.c); } b = d; } this.c.requestFrame(this.l); } finally { this.d = false; } } } KeyFrameAnimationTimeline.$t = /*@__PURE__*/ markType(KeyFrameAnimationTimeline, 'KeyFrameAnimationTimeline'); return KeyFrameAnimationTimeline; })(); /** * @hidden */ export let IKeyFrameAnimation_$type = /*@__PURE__*/ new Type(null, 'IKeyFrameAnimation'); /** * @hidden */ export let KeyFrameAnimationDirect = /*@__PURE__*/ (() => { class KeyFrameAnimationDirect extends Base { get effect() { return this.a; } set effect(a) { this.a = a; } get l() { if (this.d) { return true; } if (this.j) { return true; } return false; } get currentTime() { if (this.d) { return this.m; } return (this.c.j - this.startTime) * this.playbackRate; } set currentTime(a) { this.ar(a); this.as(true, false); } as(a, b) { let c; let d = false; if (!a) { let e = this.d; this.d = false; c = this.currentTime; d = this.l; this.d = e; } else { c = this.currentTime; d = this.l; } if (d && this.j && !this.f && !this.h) { if (this.playbackRate > 0 && c >= this.r) { if (a) { this.m = c; this.d = true; } else { if (this.i) { this.m = Math.max(this.p, this.r); } else { this.m = this.r; } } } else if (this.playbackRate < 0 && c <= 0) { if (a) { this.m = c; } else { if (this.i) { this.m = Math.min(this.p, 0); } else { this.m = 0; } } } if (this.playbackRate != 0) { if (a && this.d) { this.q = this.c.j - (this.m / this.playbackRate); this.j = true; this.d = false; } } } this.p = this.currentTime; this.i = true; let f = this.playState == 3; if (!b && f && !this.k()) { this.an(() => this.ad()); } if (f && !this.k()) { if (b) { this.aa(); this.ad(); } } if (!f && this.k()) { this.v = this.x(); } } x() { return new TaskCompletionSource$1(IKeyFrameAnimation_$type, 0); } aa() { this.e = false; } ad() { if (!this.e) { return; } this.e = false; if (this.playState != 3) { return; } this.al(this); this.ah(); } ah() { } al(a) { this.v.e(a); } an(a) { if (!this.e) { this.e = true; this.c.b.enqueueAction(() => a()); } } k() { return this.v == null || this.v.b.c; } ar(a) { if (this.d || !this.j || this.playbackRate == 0) { this.m = a; this.d = true; } else { this.q = this.c.j - (a / this.playbackRate); } } get finished() { return this.v != null ? this.v.b : null; } get ready() { return this.w != null ? this.w.b : null; } get id() { return this.u; } set id(a) { this.u = a; } get r() { return this.effect != null ? this.effect.as : 0; } get playState() { if (!this.l && !this.f && !this.h) { return 0; } else if (this.f || (!this.j && !this.h)) { return 2; } else if (this.l && (this.s > 0 && this.currentTime >= this.r || this.s < 0 && this.currentTime <= 0)) { return 3; } return 1; } get s() { if (this.g) { return this.n; } return this.o; } get playbackRate() { return this.o; } set playbackRate(a) { this.o = a; } get startTime() { return this.q; } set startTime(a) { let b = this.c.j; let c = this.p; this.q = a; this.j = true; if (this.playbackRate != 0) { this.d = false; } this.as(true, false); } get c() { return this.b; } constructor(a, b) { super(); this.a = null; this.m = NaN; this.d = false; this.p = NaN; this.i = false; this.u = null; this.n = NaN; this.g = false; this.o = 1; this.q = NaN; this.j = false; this.b = null; this.onFinished = null; this.onCanceled = null; this.h = false; this.f = false; this.e = false; this.w = null; this.v = null; this.u = "AUTO_ID_" + KeyFrameAnimationDirect.t.toString(); KeyFrameAnimationDirect.t++; this.effect = a; this.effect.r = this; this.b = b; } cancel() { if (this.playState != 0) { this.ak(); this.ai("AbortError"); this.v = this.x(); this.ag(); this.d = false; this.j = false; } } ai(a) { if (this.v != null) { this.v.d(new BaseError(1, a)); } } aj(a) { if (this.w != null) { this.w.d(new BaseError(1, a)); } } ag() { } ak() { if (this.h) { this.h = false; } if (this.f) { this.f = false; } this.z(); this.aj("AbortError"); } finish() { if (this.s == 0 || (this.s > 0 && isInfinity(this.r))) { return; } this.z(); let a; if (this.playbackRate > 0) { a = this.r; } else { a = 0; } this.ar(a); if (!this.j) { this.q = this.c.j - (a / this.playbackRate); this.j = true; } if (this.f && this.j) { this.d = false; this.ab(); this.am(this); } if (this.h && this.j) { this.ac(); this.am(this); } this.as(true, true); } pause() { this.ae(); } ae() { if (this.f) { return; } if (this.playState == 2) { return; } if (!this.l) { if (this.playbackRate >= 0) { this.d = true; this.m = 0; } if (isInfinity(this.r)) { return; } this.m = this.r; this.d = true; } let a = false; if (this.h) { a = true; } if (!a) { this.w = this.y(); } this.ao(() => { if (!this.f) { return; } this.f = false; let b = this.c.j; if (this.j && !this.d) { this.m = (b - this.q) * this.playbackRate; } this.z(); this.j = false; this.am(this); this.as(false, false); }); this.as(false, false); } y() { return new TaskCompletionSource$1(IKeyFrameAnimation_$type, 0); } ao(a) { if (!this.f) { this.f = true; this.c.b.enqueueAction(() => a()); } } play() { this.af(true); } af(a) { let b = this.f; if (this.s > 0 && a && (!this.l || this.currentTime < 0 || this.currentTime >= this.r)) { this.m = 0; this.d = true; } else if (this.s < 0 && a && (!this.l || this.currentTime <= 0 || this.currentTime > this.r)) { if (isInfinity(this.r)) { return; } this.m = this.r; this.d = true; } else if (this.s == 0 && !this.l) { this.m = 0; this.d = true; } let c = false; if (this.f) { this.ab(); c = true; } if (this.h) { this.ac(); c = true; } if (!this.d && !b && !this.g) { return; } if (this.d) { this.j = false; } if (!c) { this.w = this.y(); } this.ap(() => { if (!this.h) { return; } this.h = false; if (!this.j && !this.d) { return; } let d = this.c.j; if (this.d) { this.z(); let e = d; if (this.playbackRate != 0) { e = d - this.m / this.playbackRate; } this.q = e; this.j = true; if (this.playbackRate != 0) { this.d = false; } } else if (this.j && this.g) { let f = (d - this.q) * this.playbackRate; this.z(); if (this.playbackRate == 0) { this.m = f; this.d = true; } let g = d; if (this.playbackRate != 0) { g = d - f / this.playbackRate; } this.q = g; this.j = true; } this.am(this); this.as(false, false); this.c.m(this); }); this.as(false, false); } am(a) { if (this.w != null) { this.w.e(a); this.w = null; } } ab() { this.f = false; } ac() { this.h = false; } ap(a) { if (!this.h) { this.h = true; this.c.b.enqueueAction(() => a()); } } reverse() { let a = this.n; this.n = -this.s; this.g = true; this.af(true); } updatePlaybackRate(a) { let b = this.playState; this.n = a; this.g = true; if (b == 0 || b == 2) { this.z(); } else if (b == 3) { let c = this.d; this.d = false; let d = this.currentTime; this.d = c; if (this.n == 0) { this.q = this.c.j; } else { this.q = this.c.j - (d / this.n); } this.z(); } else { this.af(false); } } z() { if (this.g) { this.o = this.n; this.g = false; } } commitStyles() { this.effect.a6(); } aq() { this.effect.a7(); this.as(false, false); } } KeyFrameAnimationDirect.$t = /*@__PURE__*/ markType(KeyFrameAnimationDirect, 'KeyFrameAnimationDirect', Base.$, [IKeyFrameAnimation_$type]); KeyFrameAnimationDirect.t = 0; return KeyFrameAnimationDirect; })(); /** * @hidden */ export let AnimationKeyFrameEffect = /*@__PURE__*/ (() => { class AnimationKeyFrameEffect extends Base { get an() { return this.aj * this.ai; } get as() { return Math.max(this.al + this.an + this.ah, 0); } a8() { this.al = this.p.f; this.ah = this.p.h; this.t = this.p.a; this.ai = this.p.i; this.aj = this.p.g; this.v = this.p.c; this.ak = this.p.j; this.u = this.p.b; this.az = this.a0(this.u); } a0(a) { switch (a) { case 3: return (b) => b; case 1: return EasingFunctions.exponentialEase; case 2: return EasingFunctions.circleEase; case 0: return EasingFunctions.cubicEase; } return (b) => b; } constructor(a, ..._rest) { super(); this.r = null; this.a4 = null; this.o = 0; this.q = null; this.ag = new List$1(AnimationKeyFrame.$, 0); this.c = null; this.al = 0; this.ah = 0; this.az = null; this.t = 0; this.ai = 0; this.aj = 0; this.v = 0; this.ak = 0; this.u = 0; this.d = null; this.a = null; this.b = null; this.p = null; a = (a == void 0) ? 0 : a; switch (a) { case 0: { let c = _rest[0]; let d = _rest[1]; let e = _rest[2]; let f = _rest[3]; this.a4 = c; this.o = d; this.p = f; this.a8(); this.q = e; } break; case 1: { let c = _rest[0]; let d = _rest[1]; let e = _rest[2]; let f = _rest[3]; let g = _rest[4]; this.a4 = c; this.o = d; this.q = e; this.p = f; this.a8(); this.ag.o(g); } break; } } get k() { if (this.d == null) { this.d = this.e(); } return this.d; } e() { let a = this.h; if (a.length <= 1) { return [0]; } let b = new Array(a.length); let c = 1 / (a.length - 1); let d = 0; for (let e = 0; e < a.length; e++) { if (isNaN_(a[e].j)) { b[e] = d; } else { b[e] = a[e].j; d = a[e].j; if (((a.length - 1) - e) > 0) { c = (1 - d) / ((a.length - 1) - e); } } d += c; } return b; } l(a) { this.ag.add(a); this.c = null; this.a = null; return this; } m(...a) { let b = new AnimationKeyFrame(0); if (a != null) { for (let c = 0; c < a.length; c++) { b.c(a[c]); } } this.l(b); return this; } n(a, ...b) { let c = new AnimationKeyFrame(1, a); if (b != null) { for (let d = 0; d < b.length; d++) { c.c(b[d]); } } this.l(c); return this; } get au() { if (this.r != null) { return this.r.currentTime; } return NaN; } get ac() { if (this.r != null) { return this.r.l; } return false; } get ap() { return Math.max(Math.min(this.al, this.as), 0); } get am() { return Math.max(Math.min(this.al + this.an, this.as), 0); } get w() { if (this.r != null && this.r.playbackRate < 0) { return false; } return true; } get s() { if (this.ac && (this.au < this.ap || !this.w && this.au == this.ap)) { return 0; } if (this.ac && (this.au > this.am || this.w && this.au == this.am)) { return 2; } if (this.ac) { return 1; } return 3; } get ao() { let a = this.s; switch (a) { case 0: if (this.t == 3 || this.t == 4) { return Math.max(this.au - this.al, 0); } else { return NaN; } case 1: return this.au - this.al; case 2: if (this.t == 2 || this.t == 4) { return Math.max(Math.min(this.au - this.al, this.an), 0); } else { return NaN; } default: return NaN; } } get y() { if (!this.ac) { return false; } let a = this.s; switch (a) { case 0: if (this.t == 3 || this.t == 4) { return true; } else { return false; } case 1: return true; case 2: if (this.t == 2 || this.t == 4) { return true; } else { return false; } default: return false; } return false; } get ad() { if (!this.y) { return false; } return true; } get av() { if (!this.y) { return NaN; } let a = 0; if (this.aj == 0) { if (this.s == 0) { a = 0; } else { a = this.ai; } } else { a = this.ao / this.aj; } return a + this.ak; } get ae() { if (!this.ad) { return false; } return true; } get aw() { if (!this.ad) { return NaN; } let a = 1; if (isInfinity(this.av)) { a = this.ak % 1; } else { a = this.av % 1; } if (a == 0 && (this.s == 1 || this.s == 2) && this.ao == this.an && this.ai != 0) { a = 1; } return a; } get z() { if (!this.y) { return false; } return true; } get aq() { if (!this.y) { return NaN; } if (this.s == 2 && isInfinity(this.ai)) { return Number.POSITIVE_INFINITY; } if (this.aw == 1) { return Math.floor(this.av) - 1; } return Math.floor(this.av); } get aa() { return this.ae; } get ar() { if (!this.ae) { return NaN; } let a = this.x(); if (a) { return this.aw; } else { return 1 - this.aw; } } x() { let a = true; if (this.v == 0) { a = true; } else if (this.v == 1) { a = false; } else { let b = this.aq; if (this.v == 3) { b++; } if (isInfinity(b)) { a = true; } else { if (b % 2 == 0) { a = true; } else { a = false; } } } return a; } get af() { return this.aa; } get ay() { if (!this.aa) { return NaN; } let a = false; let b = this.x(); if (b && this.s == 0) { a = true; } if (!b && this.s == 2) { a = true; } return this.ax(this.ar, a); } get at() { return this.ay; } get ab() { return this.af; } ax(a, b) { return this.az(a); } a7() { if (!this.af) { return; } let a = this.ay; for (let b = 0; b < this.f.length; b++) { let c = this.a1(this.f[b], this.g[b]); this.a5(this.f[b], this.g[b], c); } } a5(a, b, c) { b.c(this.a4, c); } a1(a, b) { if (!this.ab) { return null; } let c = a; let d = this.at; if (this.a4 == null) { return null; } let e = this.a2(c, b); let f = new List$1(AnimationKeyFrame.$, 0); let g = new List$1(Number_$type, 0); for (let h = 0; h < this.h.length; h++) { for (let i = 0; i < this.h[h].b.length; i++) { if (this.h[h].b[i].a == c) { f.add(this.h[h]); g.add(this.k[h]); } } } if (f.count == 0) { return e; } if (g._inner[0] != 0) { f.insert(0, new AnimationKeyFrame(1, 0).c(new AnimationKeyFrameProperty(c, e))); g.insert(0, 0); } if (g._inner[f.count - 1] != 1) { f.add(new AnimationKeyFrame(1, 1).c(new AnimationKeyFrameProperty(c, e))); g.add(1); } let j = false; let k = new List$1(AnimationKeyFrame.$, 0); let l = new List$1(Number_$type, 0); if (d < 0) { let m = 0; for (let n = 0; n < f.count; n++) { if (g._inner[n] == 0) { m++; } else { break; } } if (m > 1) { j = true; k.add(f._inner[0]); l.add(g._inner[0]); } } if (d >= 1) { let o = 0; for (let p = f.count - 1; p >= 0; p--) { if (g._inner[p] == 1) { o++; } else { break; } } if (o > 1) { j = true; k.add(f._inner[f.count - 1]); l.add(g._inner[f.count - 1]); } } if (!j) { let q = null; let r = -1; for (let s = 0; s < f.count; s++) { if (g._inner[s] <= d) { q = f._inner[s]; r = s; } else { break; } } if (r == -1) { for (let t = 0; t < f.count; t++) { if (g._inner[t] == 0) { q = f._inner[t]; r = t; } else { break; } } } k.add(q); l.add(g._inner[r]); if (r < g.count - 1) { k.add(f._inner[r + 1]); l.add(g._inner[r + 1]); } } if (k.count == 1) { for (let u = 0; u < k._inner[0].b.length; u++) { if (k._inner[0].b[u].a == c) { return k._inner[0].b[u].d; } } return null; } let v = l._inner[0]; let w = l._inner[k.count - 1]; let x = k._inner[0].g(c).d; let y = k._inner[1].g(c).d; let z = (d - v) / (w - v); return this.a3(c, z, x, y); } a3(a, b, c, d) { switch (a) { case 2: case 3: case 7: case 15: case 16: return BrushUtil.n(c, b, d, 0); case 4: case 13: case 6: return InterpolationUtil.g(b, c, d); case 11: case 10: case 12: case 8: case 9: case 17: case 19: case 22: case 23: return c + b * (d - c); case 1: return c + b * (d - c); case 5: return InterpolationUtil.e(b, c, d); case 14: return this.a9(b, c, d); case 18: return InterpolationUtil.b(b, c, d); default: if (b < 0.5) { return c; } else { return d; } } return null; } a9(a, b, c) { let d = TransformMatrixHelpler.d(a, b.j, c.j); let e = new MatrixTransform(); e.j = d; return e; } a2(a, b) { return b.b(this.a4); } get h() { if (this.c == null) { this.c = this.ag.toArray(); this.a = this.i(); this.b = this.j(); } return this.c; } get f() { if (this.c == null) { this.c = this.ag.toArray(); this.a = this.i(); this.b = this.j(); } return this.a; } get g() { if (this.c == null) { this.c = this.ag.toArray(); this.a = this.i(); this.b = this.j(); } return this.b; } j() { let a = new List$1(UIElementPropertyAccessor.$, 0); for (let b = 0; b < this.f.length; b++) { a.add(UIElementPropertyAccessorFactory.c.a(this.f[b], this.o)); } return a.toArray(); } i() { let a = new List$1(UIElementPropertyId_$type, 0); let b = new HashSet$1(UIElementPropertyId_$type, 0); for (let c = 0; c < this.h.length; c++) { for (let d = 0; d < this.h[c].b.length; d++) { if (!b.contains(this.h[c].b[d].a)) { b.add_1(this.h[c].b[d].a); a.add(this.h[c].b[d].a); } } } return a.toArray(); } a6() { let a = this.t; this.t = 4; this.a7(); this.t = a; } } AnimationKeyFrameEffect.$t = /*@__PURE__*/ markType(AnimationKeyFrameEffect, 'AnimationKeyFrameEffect'); return AnimationKeyFrameEffect; })();