@eva/plugin-transition 1.1.1-fix.2 → 1.1.1-fix.3

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.
@@ -1,1204 +1,259 @@
1
- window.EVA = window.EVA || {};
2
- window.EVA.plugin = window.EVA.plugin || {};
3
-
4
- var _EVA_IIFE_transition = function (exports, eva_js) {
5
- 'use strict';
6
-
7
- var _extendStatics = function extendStatics(d, b) {
8
- _extendStatics = Object.setPrototypeOf || {
9
- __proto__: []
10
- } instanceof Array && function (d, b) {
11
- d.__proto__ = b;
12
- } || function (d, b) {
13
- for (var p in b) {
14
- if (b.hasOwnProperty(p)) d[p] = b[p];
15
- }
16
- };
17
-
18
- return _extendStatics(d, b);
19
- };
20
-
21
- function __extends(d, b) {
22
- _extendStatics(d, b);
23
-
24
- function __() {
25
- this.constructor = d;
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tweenjs/tween.js'), require('@eva/eva.js')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@tweenjs/tween.js', '@eva/eva.js'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.EVA = global.EVA || {}, global.EVA.plugin = global.EVA.plugin || {}, global.EVA.plugin.transition = {}), global.tween_js, global.EVA));
5
+ }(this, (function (exports, tween_js, eva_js) { 'use strict';
6
+
7
+ /*! *****************************************************************************
8
+ Copyright (c) Microsoft Corporation.
9
+
10
+ Permission to use, copy, modify, and/or distribute this software for any
11
+ purpose with or without fee is hereby granted.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
+ PERFORMANCE OF THIS SOFTWARE.
20
+ ***************************************************************************** */
21
+ /* global Reflect, Promise */
22
+
23
+ var extendStatics = function(d, b) {
24
+ extendStatics = Object.setPrototypeOf ||
25
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
26
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
27
+ return extendStatics(d, b);
28
+ };
29
+
30
+ function __extends(d, b) {
31
+ extendStatics(d, b);
32
+ function __() { this.constructor = d; }
33
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
26
34
  }
27
35
 
28
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
29
- }
30
-
31
- function __values(o) {
32
- var s = typeof Symbol === "function" && Symbol.iterator,
33
- m = s && o[s],
34
- i = 0;
35
- if (m) return m.call(o);
36
- if (o && typeof o.length === "number") return {
37
- next: function next() {
38
- if (o && i >= o.length) o = void 0;
39
- return {
40
- value: o && o[i++],
41
- done: !o
42
- };
43
- }
44
- };
45
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
46
- }
47
-
48
- var Easing = {
49
- Linear: {
50
- None: function None(amount) {
51
- return amount;
52
- }
53
- },
54
- Quadratic: {
55
- In: function In(amount) {
56
- return amount * amount;
57
- },
58
- Out: function Out(amount) {
59
- return amount * (2 - amount);
60
- },
61
- InOut: function InOut(amount) {
62
- if ((amount *= 2) < 1) {
63
- return 0.5 * amount * amount;
64
- }
65
-
66
- return -0.5 * (--amount * (amount - 2) - 1);
67
- }
68
- },
69
- Cubic: {
70
- In: function In(amount) {
71
- return amount * amount * amount;
72
- },
73
- Out: function Out(amount) {
74
- return --amount * amount * amount + 1;
75
- },
76
- InOut: function InOut(amount) {
77
- if ((amount *= 2) < 1) {
78
- return 0.5 * amount * amount * amount;
79
- }
80
-
81
- return 0.5 * ((amount -= 2) * amount * amount + 2);
82
- }
83
- },
84
- Quartic: {
85
- In: function In(amount) {
86
- return amount * amount * amount * amount;
87
- },
88
- Out: function Out(amount) {
89
- return 1 - --amount * amount * amount * amount;
90
- },
91
- InOut: function InOut(amount) {
92
- if ((amount *= 2) < 1) {
93
- return 0.5 * amount * amount * amount * amount;
94
- }
95
-
96
- return -0.5 * ((amount -= 2) * amount * amount * amount - 2);
97
- }
98
- },
99
- Quintic: {
100
- In: function In(amount) {
101
- return amount * amount * amount * amount * amount;
102
- },
103
- Out: function Out(amount) {
104
- return --amount * amount * amount * amount * amount + 1;
105
- },
106
- InOut: function InOut(amount) {
107
- if ((amount *= 2) < 1) {
108
- return 0.5 * amount * amount * amount * amount * amount;
109
- }
110
-
111
- return 0.5 * ((amount -= 2) * amount * amount * amount * amount + 2);
112
- }
113
- },
114
- Sinusoidal: {
115
- In: function In(amount) {
116
- return 1 - Math.cos(amount * Math.PI / 2);
117
- },
118
- Out: function Out(amount) {
119
- return Math.sin(amount * Math.PI / 2);
120
- },
121
- InOut: function InOut(amount) {
122
- return 0.5 * (1 - Math.cos(Math.PI * amount));
123
- }
124
- },
125
- Exponential: {
126
- In: function In(amount) {
127
- return amount === 0 ? 0 : Math.pow(1024, amount - 1);
128
- },
129
- Out: function Out(amount) {
130
- return amount === 1 ? 1 : 1 - Math.pow(2, -10 * amount);
131
- },
132
- InOut: function InOut(amount) {
133
- if (amount === 0) {
134
- return 0;
135
- }
136
-
137
- if (amount === 1) {
138
- return 1;
139
- }
140
-
141
- if ((amount *= 2) < 1) {
142
- return 0.5 * Math.pow(1024, amount - 1);
143
- }
144
-
145
- return 0.5 * (-Math.pow(2, -10 * (amount - 1)) + 2);
146
- }
147
- },
148
- Circular: {
149
- In: function In(amount) {
150
- return 1 - Math.sqrt(1 - amount * amount);
151
- },
152
- Out: function Out(amount) {
153
- return Math.sqrt(1 - --amount * amount);
154
- },
155
- InOut: function InOut(amount) {
156
- if ((amount *= 2) < 1) {
157
- return -0.5 * (Math.sqrt(1 - amount * amount) - 1);
158
- }
159
-
160
- return 0.5 * (Math.sqrt(1 - (amount -= 2) * amount) + 1);
161
- }
162
- },
163
- Elastic: {
164
- In: function In(amount) {
165
- if (amount === 0) {
166
- return 0;
167
- }
168
-
169
- if (amount === 1) {
170
- return 1;
171
- }
172
-
173
- return -Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI);
174
- },
175
- Out: function Out(amount) {
176
- if (amount === 0) {
177
- return 0;
178
- }
179
-
180
- if (amount === 1) {
181
- return 1;
182
- }
183
-
184
- return Math.pow(2, -10 * amount) * Math.sin((amount - 0.1) * 5 * Math.PI) + 1;
185
- },
186
- InOut: function InOut(amount) {
187
- if (amount === 0) {
188
- return 0;
189
- }
190
-
191
- if (amount === 1) {
192
- return 1;
193
- }
194
-
195
- amount *= 2;
196
-
197
- if (amount < 1) {
198
- return -0.5 * Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI);
199
- }
200
-
201
- return 0.5 * Math.pow(2, -10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI) + 1;
202
- }
203
- },
204
- Back: {
205
- In: function In(amount) {
206
- var s = 1.70158;
207
- return amount * amount * ((s + 1) * amount - s);
208
- },
209
- Out: function Out(amount) {
210
- var s = 1.70158;
211
- return --amount * amount * ((s + 1) * amount + s) + 1;
212
- },
213
- InOut: function InOut(amount) {
214
- var s = 1.70158 * 1.525;
215
-
216
- if ((amount *= 2) < 1) {
217
- return 0.5 * (amount * amount * ((s + 1) * amount - s));
218
- }
219
-
220
- return 0.5 * ((amount -= 2) * amount * ((s + 1) * amount + s) + 2);
221
- }
222
- },
223
- Bounce: {
224
- In: function In(amount) {
225
- return 1 - Easing.Bounce.Out(1 - amount);
226
- },
227
- Out: function Out(amount) {
228
- if (amount < 1 / 2.75) {
229
- return 7.5625 * amount * amount;
230
- } else if (amount < 2 / 2.75) {
231
- return 7.5625 * (amount -= 1.5 / 2.75) * amount + 0.75;
232
- } else if (amount < 2.5 / 2.75) {
233
- return 7.5625 * (amount -= 2.25 / 2.75) * amount + 0.9375;
234
- } else {
235
- return 7.5625 * (amount -= 2.625 / 2.75) * amount + 0.984375;
236
- }
237
- },
238
- InOut: function InOut(amount) {
239
- if (amount < 0.5) {
240
- return Easing.Bounce.In(amount * 2) * 0.5;
241
- }
242
-
243
- return Easing.Bounce.Out(amount * 2 - 1) * 0.5 + 0.5;
244
- }
245
- }
246
- };
247
- var now;
248
-
249
- if (typeof self === 'undefined' && typeof process !== 'undefined' && process.hrtime) {
250
- now = function now() {
251
- var time = process.hrtime();
252
- return time[0] * 1000 + time[1] / 1000000;
253
- };
254
- } else if (typeof self !== 'undefined' && self.performance !== undefined && self.performance.now !== undefined) {
255
- now = self.performance.now.bind(self.performance);
256
- } else if (Date.now !== undefined) {
257
- now = Date.now;
258
- } else {
259
- now = function now() {
260
- return new Date().getTime();
261
- };
262
- }
263
-
264
- var now$1 = now;
265
-
266
- var Group = function () {
267
- function Group() {
268
- this._tweens = {};
269
- this._tweensAddedDuringUpdate = {};
270
- }
271
-
272
- Group.prototype.getAll = function () {
273
- var _this = this;
274
-
275
- return Object.keys(this._tweens).map(function (tweenId) {
276
- return _this._tweens[tweenId];
277
- });
278
- };
279
-
280
- Group.prototype.removeAll = function () {
281
- this._tweens = {};
282
- };
283
-
284
- Group.prototype.add = function (tween) {
285
- this._tweens[tween.getId()] = tween;
286
- this._tweensAddedDuringUpdate[tween.getId()] = tween;
287
- };
288
-
289
- Group.prototype.remove = function (tween) {
290
- delete this._tweens[tween.getId()];
291
- delete this._tweensAddedDuringUpdate[tween.getId()];
292
- };
293
-
294
- Group.prototype.update = function (time, preserve) {
295
- if (time === void 0) {
296
- time = now$1();
297
- }
298
-
299
- if (preserve === void 0) {
300
- preserve = false;
301
- }
302
-
303
- var tweenIds = Object.keys(this._tweens);
304
-
305
- if (tweenIds.length === 0) {
306
- return false;
307
- }
308
-
309
- while (tweenIds.length > 0) {
310
- this._tweensAddedDuringUpdate = {};
311
-
312
- for (var i = 0; i < tweenIds.length; i++) {
313
- var tween = this._tweens[tweenIds[i]];
314
- var autoStart = !preserve;
315
-
316
- if (tween && tween.update(time, autoStart) === false && !preserve) {
317
- delete this._tweens[tweenIds[i]];
318
- }
319
- }
320
-
321
- tweenIds = Object.keys(this._tweensAddedDuringUpdate);
322
- }
323
-
324
- return true;
325
- };
326
-
327
- return Group;
328
- }();
329
-
330
- var Interpolation = {
331
- Linear: function Linear(v, k) {
332
- var m = v.length - 1;
333
- var f = m * k;
334
- var i = Math.floor(f);
335
- var fn = Interpolation.Utils.Linear;
336
-
337
- if (k < 0) {
338
- return fn(v[0], v[1], f);
339
- }
340
-
341
- if (k > 1) {
342
- return fn(v[m], v[m - 1], m - f);
343
- }
344
-
345
- return fn(v[i], v[i + 1 > m ? m : i + 1], f - i);
346
- },
347
- Bezier: function Bezier(v, k) {
348
- var b = 0;
349
- var n = v.length - 1;
350
- var pw = Math.pow;
351
- var bn = Interpolation.Utils.Bernstein;
352
-
353
- for (var i = 0; i <= n; i++) {
354
- b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i);
355
- }
356
-
357
- return b;
358
- },
359
- CatmullRom: function CatmullRom(v, k) {
360
- var m = v.length - 1;
361
- var f = m * k;
362
- var i = Math.floor(f);
363
- var fn = Interpolation.Utils.CatmullRom;
364
-
365
- if (v[0] === v[m]) {
366
- if (k < 0) {
367
- i = Math.floor(f = m * (1 + k));
368
- }
369
-
370
- return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i);
371
- } else {
372
- if (k < 0) {
373
- return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]);
374
- }
375
-
376
- if (k > 1) {
377
- return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]);
378
- }
379
-
380
- return fn(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i);
381
- }
382
- },
383
- Utils: {
384
- Linear: function Linear(p0, p1, t) {
385
- return (p1 - p0) * t + p0;
386
- },
387
- Bernstein: function Bernstein(n, i) {
388
- var fc = Interpolation.Utils.Factorial;
389
- return fc(n) / fc(i) / fc(n - i);
390
- },
391
- Factorial: function () {
392
- var a = [1];
393
- return function (n) {
394
- var s = 1;
395
-
396
- if (a[n]) {
397
- return a[n];
398
- }
399
-
400
- for (var i = n; i > 1; i--) {
401
- s *= i;
402
- }
403
-
404
- a[n] = s;
405
- return s;
406
- };
407
- }(),
408
- CatmullRom: function CatmullRom(p0, p1, p2, p3, t) {
409
- var v0 = (p2 - p0) * 0.5;
410
- var v1 = (p3 - p1) * 0.5;
411
- var t2 = t * t;
412
- var t3 = t * t2;
413
- return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;
414
- }
415
- }
416
- };
417
-
418
- var Sequence = function () {
419
- function Sequence() {}
420
-
421
- Sequence.nextId = function () {
422
- return Sequence._nextId++;
423
- };
424
-
425
- Sequence._nextId = 0;
426
- return Sequence;
427
- }();
428
-
429
- var mainGroup = new Group();
430
-
431
- var Tween = function () {
432
- function Tween(_object, _group) {
433
- if (_group === void 0) {
434
- _group = mainGroup;
435
- }
436
-
437
- this._object = _object;
438
- this._group = _group;
439
- this._isPaused = false;
440
- this._pauseStart = 0;
441
- this._valuesStart = {};
442
- this._valuesEnd = {};
443
- this._valuesStartRepeat = {};
444
- this._duration = 1000;
445
- this._initialRepeat = 0;
446
- this._repeat = 0;
447
- this._yoyo = false;
448
- this._isPlaying = false;
449
- this._reversed = false;
450
- this._delayTime = 0;
451
- this._startTime = 0;
452
- this._easingFunction = Easing.Linear.None;
453
- this._interpolationFunction = Interpolation.Linear;
454
- this._chainedTweens = [];
455
- this._onStartCallbackFired = false;
456
- this._id = Sequence.nextId();
457
- this._isChainStopped = false;
458
- this._goToEnd = false;
459
- }
460
-
461
- Tween.prototype.getId = function () {
462
- return this._id;
463
- };
464
-
465
- Tween.prototype.isPlaying = function () {
466
- return this._isPlaying;
467
- };
468
-
469
- Tween.prototype.isPaused = function () {
470
- return this._isPaused;
471
- };
472
-
473
- Tween.prototype.to = function (properties, duration) {
474
- this._valuesEnd = Object.create(properties);
475
-
476
- if (duration !== undefined) {
477
- this._duration = duration;
478
- }
479
-
480
- return this;
481
- };
482
-
483
- Tween.prototype.duration = function (d) {
484
- this._duration = d;
485
- return this;
486
- };
487
-
488
- Tween.prototype.start = function (time) {
489
- if (this._isPlaying) {
490
- return this;
491
- }
492
-
493
- this._group && this._group.add(this);
494
- this._repeat = this._initialRepeat;
495
-
496
- if (this._reversed) {
497
- this._reversed = false;
498
-
499
- for (var property in this._valuesStartRepeat) {
500
- this._swapEndStartRepeatValues(property);
501
-
502
- this._valuesStart[property] = this._valuesStartRepeat[property];
503
- }
504
- }
505
-
506
- this._isPlaying = true;
507
- this._isPaused = false;
508
- this._onStartCallbackFired = false;
509
- this._isChainStopped = false;
510
- this._startTime = time !== undefined ? typeof time === 'string' ? now$1() + parseFloat(time) : time : now$1();
511
- this._startTime += this._delayTime;
512
-
513
- this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat);
514
-
515
- return this;
516
- };
517
-
518
- Tween.prototype._setupProperties = function (_object, _valuesStart, _valuesEnd, _valuesStartRepeat) {
519
- for (var property in _valuesEnd) {
520
- var startValue = _object[property];
521
- var startValueIsArray = Array.isArray(startValue);
522
- var propType = startValueIsArray ? 'array' : typeof startValue;
523
- var isInterpolationList = !startValueIsArray && Array.isArray(_valuesEnd[property]);
524
-
525
- if (propType === 'undefined' || propType === 'function') {
526
- continue;
527
- }
528
-
529
- if (isInterpolationList) {
530
- var endValues = _valuesEnd[property];
531
-
532
- if (endValues.length === 0) {
533
- continue;
534
- }
535
-
536
- endValues = endValues.map(this._handleRelativeValue.bind(this, startValue));
537
- _valuesEnd[property] = [startValue].concat(endValues);
538
- }
539
-
540
- if ((propType === 'object' || startValueIsArray) && startValue && !isInterpolationList) {
541
- _valuesStart[property] = startValueIsArray ? [] : {};
542
-
543
- for (var prop in startValue) {
544
- _valuesStart[property][prop] = startValue[prop];
545
- }
546
-
547
- _valuesStartRepeat[property] = startValueIsArray ? [] : {};
548
-
549
- this._setupProperties(startValue, _valuesStart[property], _valuesEnd[property], _valuesStartRepeat[property]);
550
- } else {
551
- if (typeof _valuesStart[property] === 'undefined') {
552
- _valuesStart[property] = startValue;
553
- }
554
-
555
- if (!startValueIsArray) {
556
- _valuesStart[property] *= 1.0;
557
- }
558
-
559
- if (isInterpolationList) {
560
- _valuesStartRepeat[property] = _valuesEnd[property].slice().reverse();
561
- } else {
562
- _valuesStartRepeat[property] = _valuesStart[property] || 0;
563
- }
564
- }
565
- }
566
- };
567
-
568
- Tween.prototype.stop = function () {
569
- if (!this._isChainStopped) {
570
- this._isChainStopped = true;
571
- this.stopChainedTweens();
572
- }
573
-
574
- if (!this._isPlaying) {
575
- return this;
576
- }
577
-
578
- this._group && this._group.remove(this);
579
- this._isPlaying = false;
580
- this._isPaused = false;
581
-
582
- if (this._onStopCallback) {
583
- this._onStopCallback(this._object);
584
- }
585
-
586
- return this;
587
- };
588
-
589
- Tween.prototype.end = function () {
590
- this._goToEnd = true;
591
- this.update(Infinity);
592
- return this;
593
- };
594
-
595
- Tween.prototype.pause = function (time) {
596
- if (time === void 0) {
597
- time = now$1();
598
- }
599
-
600
- if (this._isPaused || !this._isPlaying) {
601
- return this;
602
- }
603
-
604
- this._isPaused = true;
605
- this._pauseStart = time;
606
- this._group && this._group.remove(this);
607
- return this;
608
- };
609
-
610
- Tween.prototype.resume = function (time) {
611
- if (time === void 0) {
612
- time = now$1();
613
- }
614
-
615
- if (!this._isPaused || !this._isPlaying) {
616
- return this;
617
- }
618
-
619
- this._isPaused = false;
620
- this._startTime += time - this._pauseStart;
621
- this._pauseStart = 0;
622
- this._group && this._group.add(this);
623
- return this;
624
- };
625
-
626
- Tween.prototype.stopChainedTweens = function () {
627
- for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
628
- this._chainedTweens[i].stop();
629
- }
630
-
631
- return this;
632
- };
633
-
634
- Tween.prototype.group = function (group) {
635
- this._group = group;
636
- return this;
637
- };
638
-
639
- Tween.prototype.delay = function (amount) {
640
- this._delayTime = amount;
641
- return this;
642
- };
643
-
644
- Tween.prototype.repeat = function (times) {
645
- this._initialRepeat = times;
646
- this._repeat = times;
647
- return this;
648
- };
649
-
650
- Tween.prototype.repeatDelay = function (amount) {
651
- this._repeatDelayTime = amount;
652
- return this;
653
- };
654
-
655
- Tween.prototype.yoyo = function (yoyo) {
656
- this._yoyo = yoyo;
657
- return this;
658
- };
659
-
660
- Tween.prototype.easing = function (easingFunction) {
661
- this._easingFunction = easingFunction;
662
- return this;
663
- };
664
-
665
- Tween.prototype.interpolation = function (interpolationFunction) {
666
- this._interpolationFunction = interpolationFunction;
667
- return this;
668
- };
669
-
670
- Tween.prototype.chain = function () {
671
- var tweens = [];
672
-
673
- for (var _i = 0; _i < arguments.length; _i++) {
674
- tweens[_i] = arguments[_i];
675
- }
676
-
677
- this._chainedTweens = tweens;
678
- return this;
679
- };
680
-
681
- Tween.prototype.onStart = function (callback) {
682
- this._onStartCallback = callback;
683
- return this;
684
- };
685
-
686
- Tween.prototype.onUpdate = function (callback) {
687
- this._onUpdateCallback = callback;
688
- return this;
689
- };
690
-
691
- Tween.prototype.onRepeat = function (callback) {
692
- this._onRepeatCallback = callback;
693
- return this;
694
- };
695
-
696
- Tween.prototype.onComplete = function (callback) {
697
- this._onCompleteCallback = callback;
698
- return this;
699
- };
700
-
701
- Tween.prototype.onStop = function (callback) {
702
- this._onStopCallback = callback;
703
- return this;
704
- };
705
-
706
- Tween.prototype.update = function (time, autoStart) {
707
- if (time === void 0) {
708
- time = now$1();
709
- }
710
-
711
- if (autoStart === void 0) {
712
- autoStart = true;
713
- }
714
-
715
- if (this._isPaused) return true;
716
- var property;
717
- var elapsed;
718
- var endTime = this._startTime + this._duration;
719
-
720
- if (!this._goToEnd && !this._isPlaying) {
721
- if (time > endTime) return false;
722
- if (autoStart) this.start(time);
723
- }
724
-
725
- this._goToEnd = false;
726
-
727
- if (time < this._startTime) {
728
- return true;
729
- }
730
-
731
- if (this._onStartCallbackFired === false) {
732
- if (this._onStartCallback) {
733
- this._onStartCallback(this._object);
734
- }
735
-
736
- this._onStartCallbackFired = true;
737
- }
738
-
739
- elapsed = (time - this._startTime) / this._duration;
740
- elapsed = this._duration === 0 || elapsed > 1 ? 1 : elapsed;
741
-
742
- var value = this._easingFunction(elapsed);
743
-
744
- this._updateProperties(this._object, this._valuesStart, this._valuesEnd, value);
745
-
746
- if (this._onUpdateCallback) {
747
- this._onUpdateCallback(this._object, elapsed);
748
- }
749
-
750
- if (elapsed === 1) {
751
- if (this._repeat > 0) {
752
- if (isFinite(this._repeat)) {
753
- this._repeat--;
754
- }
755
-
756
- for (property in this._valuesStartRepeat) {
757
- if (!this._yoyo && typeof this._valuesEnd[property] === 'string') {
758
- this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]);
759
- }
760
-
761
- if (this._yoyo) {
762
- this._swapEndStartRepeatValues(property);
763
- }
764
-
765
- this._valuesStart[property] = this._valuesStartRepeat[property];
766
- }
767
-
768
- if (this._yoyo) {
769
- this._reversed = !this._reversed;
770
- }
771
-
772
- if (this._repeatDelayTime !== undefined) {
773
- this._startTime = time + this._repeatDelayTime;
774
- } else {
775
- this._startTime = time + this._delayTime;
776
- }
777
-
778
- if (this._onRepeatCallback) {
779
- this._onRepeatCallback(this._object);
780
- }
781
-
782
- return true;
783
- } else {
784
- if (this._onCompleteCallback) {
785
- this._onCompleteCallback(this._object);
786
- }
787
-
788
- for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
789
- this._chainedTweens[i].start(this._startTime + this._duration);
790
- }
791
-
792
- this._isPlaying = false;
793
- return false;
794
- }
795
- }
796
-
797
- return true;
798
- };
799
-
800
- Tween.prototype._updateProperties = function (_object, _valuesStart, _valuesEnd, value) {
801
- for (var property in _valuesEnd) {
802
- if (_valuesStart[property] === undefined) {
803
- continue;
804
- }
805
-
806
- var start = _valuesStart[property] || 0;
807
- var end = _valuesEnd[property];
808
- var startIsArray = Array.isArray(_object[property]);
809
- var endIsArray = Array.isArray(end);
810
- var isInterpolationList = !startIsArray && endIsArray;
811
-
812
- if (isInterpolationList) {
813
- _object[property] = this._interpolationFunction(end, value);
814
- } else if (typeof end === 'object' && end) {
815
- this._updateProperties(_object[property], start, end, value);
816
- } else {
817
- end = this._handleRelativeValue(start, end);
818
-
819
- if (typeof end === 'number') {
820
- _object[property] = start + (end - start) * value;
821
- }
822
- }
823
- }
824
- };
825
-
826
- Tween.prototype._handleRelativeValue = function (start, end) {
827
- if (typeof end !== 'string') {
828
- return end;
829
- }
830
-
831
- if (end.charAt(0) === '+' || end.charAt(0) === '-') {
832
- return start + parseFloat(end);
833
- } else {
834
- return parseFloat(end);
835
- }
836
- };
837
-
838
- Tween.prototype._swapEndStartRepeatValues = function (property) {
839
- var tmp = this._valuesStartRepeat[property];
840
- var endValue = this._valuesEnd[property];
841
-
842
- if (typeof endValue === 'string') {
843
- this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(endValue);
844
- } else {
845
- this._valuesStartRepeat[property] = this._valuesEnd[property];
846
- }
847
-
848
- this._valuesEnd[property] = tmp;
849
- };
850
-
851
- return Tween;
852
- }();
853
-
854
- var TWEEN = mainGroup;
855
- TWEEN.getAll.bind(TWEEN);
856
- TWEEN.removeAll.bind(TWEEN);
857
- TWEEN.add.bind(TWEEN);
858
- TWEEN.remove.bind(TWEEN);
859
- TWEEN.update.bind(TWEEN);
860
- var easingMap = {
861
- linear: Easing.Linear.None,
862
- 'ease-in': Easing.Quadratic.In,
863
- 'ease-out': Easing.Quadratic.Out,
864
- 'ease-in-out': Easing.Quadratic.InOut,
865
- 'bounce-in': Easing.Bounce.In,
866
- 'bounce-out': Easing.Bounce.Out,
867
- 'bounce-in-out': Easing.Bounce.InOut,
868
- none: function none(p) {
869
- return ~~p;
870
- }
871
- };
872
-
873
- var Animation = function () {
874
- function Animation(timelines, tweenGroup) {
875
- this.tweens = [];
876
- this.timelines = [];
877
- this.finishCount = 0;
878
- this.callbacks = new Map();
879
- this.objectCache = {};
880
- this.currIteration = 0;
881
- this.timelines = timelines;
882
- this.tweenGroup = tweenGroup;
883
- }
884
-
885
- Animation.prototype.on = function (eventName, callback) {
886
- if (!this.callbacks[eventName]) {
887
- this.callbacks.set(eventName, []);
888
- }
889
-
890
- this.callbacks.get(eventName).push(callback);
891
- };
892
-
893
- Animation.prototype.emit = function (eventName) {
894
- var callbacks = this.callbacks.get(eventName);
895
- if (!callbacks || !callbacks.length) return;
896
- callbacks.forEach(function (fn) {
897
- return fn();
898
- });
899
- };
900
-
901
- Animation.prototype.checkFinish = function () {
902
- if (++this.finishCount == this.tweens.length) {
903
- if (++this.currIteration == this.iteration) {
904
- this.emit('finish');
905
- } else {
906
- if (this.stoped) return;
907
- this.start();
908
- }
909
- }
910
- };
911
-
912
- Animation.prototype.getObjectCache = function (component, name) {
913
- var key = "" + component.gameObject.id + component.name;
914
-
915
- if (!this.objectCache[key]) {
916
- this.objectCache[key] = {};
917
- }
918
-
919
- if (this.objectCache[key][name]) {
920
- return this.objectCache[key][name];
921
- }
922
-
923
- var keys = name.split('.');
924
- var keyIndex = keys.length - 1;
925
- var property = component;
926
-
927
- for (var i = 0; i < keyIndex; i++) {
928
- property = property[keys[i]];
929
- }
930
-
931
- this.objectCache[key][name] = {
932
- property: property,
933
- key: keys[keyIndex]
934
- };
935
- return this.objectCache[key][name];
936
- };
937
-
938
- Animation.prototype.doAnim = function (_a) {
939
- var component = _a.component,
940
- name = _a.name,
941
- value = _a.value;
942
-
943
- var _b = this.getObjectCache(component, name),
944
- property = _b.property,
945
- key = _b.key;
946
-
947
- property[key] = value;
948
- };
949
-
950
- Animation.prototype.init = function () {
951
- var _this = this;
952
-
953
- this.checkFinishFunc = this.checkFinish.bind(this);
954
- var lastTween;
955
- this.timelines.forEach(function (timeline, i) {
956
- for (var j = 0; j < timeline.values.length - 1; j++) {
957
- var frame = timeline.values[j];
958
- var nextFrame = timeline.values[j + 1];
959
- var tween = new Tween({
960
- value: frame.value
961
- }, _this.tweenGroup).to({
962
- value: nextFrame.value
963
- }).duration(nextFrame.time - frame.time).easing(easingMap[frame.tween]).onUpdate(function (props) {
964
- _this.doAnim({
965
- component: timeline.component,
966
- name: timeline.name,
967
- value: props.value
968
- });
969
- });
970
-
971
- if (j === 0) {
972
- _this.tweens[i] = tween;
973
- } else {
974
- lastTween.chain(tween);
975
- }
976
-
977
- lastTween = tween;
978
- }
979
-
980
- lastTween && lastTween.onComplete(function () {
981
- return _this.checkFinishFunc();
982
- });
983
- });
984
- };
985
-
986
- Animation.prototype.play = function (iteration, currentTime) {
987
- if (iteration === void 0) {
988
- iteration = 1;
989
- }
990
-
991
- this.currentTime = currentTime;
992
- this.stoped = false;
993
- this.start();
994
- this.currIteration = 0;
995
- this.iteration = iteration;
996
- };
997
-
998
- Animation.prototype.start = function () {
999
- var _this = this;
1000
-
1001
- this.finishCount = 0;
1002
- this.tweens.length = 0;
1003
- this.init();
1004
- this.tweens.forEach(function (tween) {
1005
- return tween.start(_this.currentTime);
1006
- });
1007
- };
1008
-
1009
- Animation.prototype.pause = function () {
1010
- var _this = this;
1011
-
1012
- this.tweens.forEach(function (tween) {
1013
- return tween.pause(_this.currentTime);
1014
- });
1015
- };
1016
-
1017
- Animation.prototype.resume = function () {
1018
- var _this = this;
1019
-
1020
- this.tweens.forEach(function (tween) {
1021
- return tween.resume(_this.currentTime);
1022
- });
1023
- };
1024
-
1025
- Animation.prototype.stop = function () {
1026
- this.stoped = true;
1027
- this.tweens.forEach(function (tween) {
1028
- return tween.stop();
1029
- });
1030
- };
1031
-
1032
- Animation.prototype.destroy = function () {
1033
- this.stop();
1034
- this.tweens = null;
1035
- this.timelines = null;
1036
- this.objectCache = null;
1037
- this.callbacks.clear();
1038
- this.callbacks = null;
1039
- };
1040
-
1041
- return Animation;
1042
- }();
1043
-
1044
- var Animation$1 = Animation;
1045
-
1046
- var Transition = function (_super) {
1047
- __extends(Transition, _super);
1048
-
1049
- function Transition() {
1050
- var _this = _super !== null && _super.apply(this, arguments) || this;
1051
-
1052
- _this.animations = {};
1053
- _this.group = {};
1054
- _this.currentTime = 0;
1055
- _this.needPlay = [];
1056
- return _this;
1057
- }
1058
-
1059
- Transition.prototype.init = function (_a) {
1060
- var group = (_a === void 0 ? {
1061
- group: {}
1062
- } : _a).group;
1063
- this.group = group;
1064
- this.tweenGroup = new Group();
1065
- };
1066
-
1067
- Transition.prototype.awake = function () {
1068
- for (var name_1 in this.group) {
1069
- this.newAnimation(name_1);
1070
- }
1071
- };
1072
-
1073
- Transition.prototype.play = function (name, iteration) {
1074
- if (!name) {
1075
- name = Object.keys(this.group)[0];
1076
- }
1077
-
1078
- if (name && !this.animations[name] && this.group[name]) {
1079
- this.newAnimation(name);
1080
- }
1081
-
1082
- if (name && this.animations[name]) {
1083
- this.needPlay.push({
1084
- name: name,
1085
- iteration: iteration
1086
- });
1087
- }
1088
- };
1089
-
1090
- Transition.prototype.stop = function (name) {
1091
- var _a, _b;
1092
-
1093
- if (!name) {
1094
- for (var key in this.animations) {
1095
- (_a = this.animations[key]) === null || _a === void 0 ? void 0 : _a.stop();
1096
- }
1097
- } else {
1098
- (_b = this.animations[name]) === null || _b === void 0 ? void 0 : _b.stop();
1099
- }
1100
- };
1101
-
1102
- Transition.prototype.onPause = function () {
1103
- var _a;
1104
-
1105
- for (var key in this.animations) {
1106
- (_a = this.animations[key]) === null || _a === void 0 ? void 0 : _a.pause();
1107
- }
1108
- };
1109
-
1110
- Transition.prototype.onResume = function () {
1111
- var _a;
1112
-
1113
- for (var key in this.animations) {
1114
- (_a = this.animations[key]) === null || _a === void 0 ? void 0 : _a.resume();
1115
- }
1116
- };
1117
-
1118
- Transition.prototype.onDestroy = function () {
1119
- var _a;
1120
-
1121
- for (var key in this.animations) {
1122
- (_a = this.animations[key]) === null || _a === void 0 ? void 0 : _a.destroy();
1123
- }
1124
-
1125
- this.tweenGroup.removeAll();
1126
- this.tweenGroup = null;
1127
- this.group = null;
1128
- this.animations = null;
1129
- this.removeAllListeners();
1130
- };
1131
-
1132
- Transition.prototype.update = function (e) {
1133
- var e_1, _a;
1134
-
1135
- var _b;
1136
-
1137
- this.currentTime = e.time;
1138
-
1139
- for (var key in this.animations) {
1140
- this.animations[key].currentTime = e.time;
1141
- }
1142
-
1143
- this.tweenGroup.update(e.time);
1144
-
1145
- try {
1146
- for (var _c = __values(this.needPlay), _d = _c.next(); !_d.done; _d = _c.next()) {
1147
- var play = _d.value;
1148
- (_b = this.animations[play.name]) === null || _b === void 0 ? void 0 : _b.play(play.iteration, this.currentTime);
1149
- }
1150
- } catch (e_1_1) {
1151
- e_1 = {
1152
- error: e_1_1
1153
- };
1154
- } finally {
1155
- try {
1156
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
1157
- } finally {
1158
- if (e_1) throw e_1.error;
1159
- }
1160
- }
1161
-
1162
- this.needPlay.length = 0;
1163
- };
1164
-
1165
- Transition.prototype.newAnimation = function (name) {
1166
- var _this = this;
1167
-
1168
- var animation = new Animation$1(this.group[name], this.tweenGroup);
1169
- animation.on('finish', function () {
1170
- return _this.emit('finish', name);
1171
- });
1172
- this.animations[name] = animation;
1173
- };
1174
-
1175
- Transition.componentName = 'Transition';
1176
- return Transition;
1177
- }(eva_js.Component);
1178
-
1179
- var Transition$1 = Transition;
1180
-
1181
- var TransitionSystem = function (_super) {
1182
- __extends(TransitionSystem, _super);
1183
-
1184
- function TransitionSystem() {
1185
- var _this = _super !== null && _super.apply(this, arguments) || this;
1186
-
1187
- _this.name = 'transition';
1188
- return _this;
1189
- }
1190
-
1191
- TransitionSystem.systemName = 'transition';
1192
- return TransitionSystem;
1193
- }(eva_js.System);
1194
-
1195
- var TransitionSystem$1 = TransitionSystem;
1196
- exports.Transition = Transition$1;
1197
- exports.TransitionSystem = TransitionSystem$1;
1198
- Object.defineProperty(exports, '__esModule', {
1199
- value: true
1200
- });
1201
- return exports;
1202
- }({}, EVA);
1203
-
1204
- window.EVA.plugin.transition = window.EVA.plugin.transition || _EVA_IIFE_transition;
36
+ var easingMap = {
37
+ linear: tween_js.Easing.Linear.None,
38
+ 'ease-in': tween_js.Easing.Quadratic.In,
39
+ 'ease-out': tween_js.Easing.Quadratic.Out,
40
+ 'ease-in-out': tween_js.Easing.Quadratic.InOut,
41
+ 'bounce-in': tween_js.Easing.Bounce.In,
42
+ 'bounce-out': tween_js.Easing.Bounce.Out,
43
+ 'bounce-in-out': tween_js.Easing.Bounce.InOut,
44
+ none: function (p) { return ~~p; },
45
+ };
46
+ var Animation = (function () {
47
+ function Animation(timelines, tweenGroup) {
48
+ this.tweens = [];
49
+ this.timelines = [];
50
+ this.finishCount = 0;
51
+ this.callbacks = new Map();
52
+ this.objectCache = {};
53
+ this.currIteration = 0;
54
+ this.timelines = timelines;
55
+ this.tweenGroup = tweenGroup;
56
+ }
57
+ Animation.prototype.on = function (eventName, callback) {
58
+ if (!this.callbacks[eventName]) {
59
+ this.callbacks.set(eventName, []);
60
+ }
61
+ this.callbacks.get(eventName).push(callback);
62
+ };
63
+ Animation.prototype.emit = function (eventName) {
64
+ var callbacks = this.callbacks.get(eventName);
65
+ if (!callbacks || !callbacks.length)
66
+ return;
67
+ callbacks.forEach(function (fn) { return fn(); });
68
+ };
69
+ Animation.prototype.checkFinish = function () {
70
+ if (++this.finishCount == this.tweens.length) {
71
+ if (++this.currIteration == this.iteration) {
72
+ this.emit('finish');
73
+ }
74
+ else {
75
+ if (this.stoped)
76
+ return;
77
+ this.start();
78
+ }
79
+ }
80
+ };
81
+ Animation.prototype.getObjectCache = function (component, name) {
82
+ var key = "" + component.gameObject.id + component.name;
83
+ if (!this.objectCache[key]) {
84
+ this.objectCache[key] = {};
85
+ }
86
+ if (this.objectCache[key][name]) {
87
+ return this.objectCache[key][name];
88
+ }
89
+ var keys = name.split('.');
90
+ var keyIndex = keys.length - 1;
91
+ var property = component;
92
+ for (var i = 0; i < keyIndex; i++) {
93
+ property = property[keys[i]];
94
+ }
95
+ this.objectCache[key][name] = { property: property, key: keys[keyIndex] };
96
+ return this.objectCache[key][name];
97
+ };
98
+ Animation.prototype.doAnim = function (_a) {
99
+ var component = _a.component, name = _a.name, value = _a.value;
100
+ var _b = this.getObjectCache(component, name), property = _b.property, key = _b.key;
101
+ property[key] = value;
102
+ };
103
+ Animation.prototype.init = function () {
104
+ var _this = this;
105
+ this.checkFinishFunc = this.checkFinish.bind(this);
106
+ var lastTween;
107
+ this.timelines.forEach(function (timeline, i) {
108
+ for (var j = 0; j < timeline.values.length - 1; j++) {
109
+ var frame = timeline.values[j];
110
+ var nextFrame = timeline.values[j + 1];
111
+ var tween = new tween_js.Tween({ value: frame.value }, _this.tweenGroup)
112
+ .to({ value: nextFrame.value })
113
+ .duration(nextFrame.time - frame.time)
114
+ .easing(easingMap[frame.tween])
115
+ .onUpdate(function (props) {
116
+ _this.doAnim({
117
+ component: timeline.component,
118
+ name: timeline.name,
119
+ value: props.value,
120
+ });
121
+ });
122
+ if (j === 0) {
123
+ _this.tweens[i] = tween;
124
+ }
125
+ else {
126
+ lastTween.chain(tween);
127
+ }
128
+ lastTween = tween;
129
+ }
130
+ lastTween && lastTween.onComplete(function () { return _this.checkFinishFunc(); });
131
+ });
132
+ };
133
+ Animation.prototype.play = function (iteration) {
134
+ if (iteration === void 0) { iteration = 1; }
135
+ this.stoped = false;
136
+ this.start();
137
+ this.currIteration = 0;
138
+ this.iteration = iteration;
139
+ };
140
+ Animation.prototype.start = function () {
141
+ this.finishCount = 0;
142
+ this.tweens.length = 0;
143
+ this.init();
144
+ this.tweens.forEach(function (tween) { return tween.start(); });
145
+ };
146
+ Animation.prototype.pause = function () {
147
+ this.tweens.forEach(function (tween) { return tween.pause(); });
148
+ };
149
+ Animation.prototype.resume = function () {
150
+ this.tweens.forEach(function (tween) { return tween.resume(); });
151
+ };
152
+ Animation.prototype.stop = function () {
153
+ this.stoped = true;
154
+ this.tweens.forEach(function (tween) { return tween.stop(); });
155
+ };
156
+ Animation.prototype.destroy = function () {
157
+ this.stop();
158
+ this.tweens = null;
159
+ this.timelines = null;
160
+ this.objectCache = null;
161
+ this.callbacks.clear();
162
+ this.callbacks = null;
163
+ };
164
+ return Animation;
165
+ }());
166
+ var Animation$1 = Animation;
167
+
168
+ var Transition = (function (_super) {
169
+ __extends(Transition, _super);
170
+ function Transition() {
171
+ var _this = _super !== null && _super.apply(this, arguments) || this;
172
+ _this.animations = {};
173
+ _this.group = {};
174
+ return _this;
175
+ }
176
+ Transition.prototype.init = function (_a) {
177
+ var group = (_a === void 0 ? { group: {} } : _a).group;
178
+ this.group = group;
179
+ this.tweenGroup = new tween_js.Group();
180
+ };
181
+ Transition.prototype.awake = function () {
182
+ for (var name_1 in this.group) {
183
+ this.newAnimation(name_1);
184
+ }
185
+ };
186
+ Transition.prototype.play = function (name, iteration) {
187
+ if (!name) {
188
+ name = Object.keys(this.group)[0];
189
+ }
190
+ if (name && !this.animations[name] && this.group[name]) {
191
+ this.newAnimation(name);
192
+ }
193
+ if (name && this.animations[name]) {
194
+ this.animations[name].play(iteration);
195
+ }
196
+ };
197
+ Transition.prototype.stop = function (name) {
198
+ if (!name) {
199
+ for (var key in this.animations) {
200
+ this.animations[key].stop();
201
+ }
202
+ }
203
+ else {
204
+ this.animations[name].stop();
205
+ }
206
+ };
207
+ Transition.prototype.onPause = function () {
208
+ for (var key in this.animations) {
209
+ this.animations[key].pause();
210
+ }
211
+ };
212
+ Transition.prototype.onResume = function () {
213
+ for (var key in this.animations) {
214
+ this.animations[key].resume();
215
+ }
216
+ };
217
+ Transition.prototype.onDestroy = function () {
218
+ for (var key in this.animations) {
219
+ this.animations[key].destroy();
220
+ }
221
+ this.tweenGroup.removeAll();
222
+ this.tweenGroup = null;
223
+ this.group = null;
224
+ this.animations = null;
225
+ this.removeAllListeners();
226
+ };
227
+ Transition.prototype.update = function () {
228
+ this.tweenGroup.update();
229
+ };
230
+ Transition.prototype.newAnimation = function (name) {
231
+ var _this = this;
232
+ var animation = new Animation$1(this.group[name], this.tweenGroup);
233
+ animation.on('finish', function () { return _this.emit('finish', name); });
234
+ this.animations[name] = animation;
235
+ };
236
+ Transition.componentName = 'Transition';
237
+ return Transition;
238
+ }(eva_js.Component));
239
+ var Transition$1 = Transition;
240
+
241
+ var TransitionSystem = (function (_super) {
242
+ __extends(TransitionSystem, _super);
243
+ function TransitionSystem() {
244
+ var _this = _super !== null && _super.apply(this, arguments) || this;
245
+ _this.name = 'transition';
246
+ return _this;
247
+ }
248
+ TransitionSystem.systemName = 'transition';
249
+ return TransitionSystem;
250
+ }(eva_js.System));
251
+ var TransitionSystem$1 = TransitionSystem;
252
+
253
+ exports.Transition = Transition$1;
254
+ exports.TransitionSystem = TransitionSystem$1;
255
+
256
+ Object.defineProperty(exports, '__esModule', { value: true });
257
+
258
+ })));
259
+ //# sourceMappingURL=EVA.plugin.transition.js.map