@eva/plugin-transition 1.2.7-fix.4 → 1.2.7-fix.6

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