@tweenjs/tween.js 18.3.2 → 18.6.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/tween.esm.js CHANGED
@@ -1,961 +1,792 @@
1
- /**
2
- * Tween.js - Licensed under the MIT license
3
- * https://github.com/tweenjs/tween.js
4
- * ----------------------------------------------
5
- *
6
- * See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors.
7
- * Thank you all, you're awesome!
8
- */
9
-
10
-
11
- var _Group = function () {
12
- this._tweens = {};
13
- this._tweensAddedDuringUpdate = {};
1
+ var NOW;
2
+ // Include a performance.now polyfill.
3
+ // In node.js, use process.hrtime.
4
+ // eslint-disable-next-line
5
+ // @ts-ignore
6
+ if (typeof self === 'undefined' && typeof process !== 'undefined' && process.hrtime) {
7
+ NOW = function () {
8
+ // eslint-disable-next-line
9
+ // @ts-ignore
10
+ var time = process.hrtime();
11
+ // Convert [seconds, nanoseconds] to milliseconds.
12
+ return time[0] * 1000 + time[1] / 1000000;
13
+ };
14
+ }
15
+ // In a browser, use self.performance.now if it is available.
16
+ else if (typeof self !== 'undefined' && self.performance !== undefined && self.performance.now !== undefined) {
17
+ // This must be bound, because directly assigning this function
18
+ // leads to an invocation exception in Chrome.
19
+ NOW = self.performance.now.bind(self.performance);
20
+ }
21
+ // Use Date.now if it is available.
22
+ else if (Date.now !== undefined) {
23
+ NOW = Date.now;
24
+ }
25
+ // Otherwise, use 'new Date().getTime()'.
26
+ else {
27
+ NOW = function () {
28
+ return new Date().getTime();
29
+ };
30
+ }
31
+ var NOW$1 = NOW;
32
+
33
+ /**
34
+ * Controlling groups of tweens
35
+ *
36
+ * Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components.
37
+ * In these cases, you may want to create your own smaller groups of tween
38
+ */
39
+ var Group = /** @class */ (function () {
40
+ function Group() {
41
+ this._tweens = {};
42
+ this._tweensAddedDuringUpdate = {};
43
+ }
44
+ Group.prototype.getAll = function () {
45
+ var _this = this;
46
+ return Object.keys(this._tweens).map(function (tweenId) {
47
+ return _this._tweens[tweenId];
48
+ });
49
+ };
50
+ Group.prototype.removeAll = function () {
51
+ this._tweens = {};
52
+ };
53
+ Group.prototype.add = function (tween) {
54
+ this._tweens[tween.getId()] = tween;
55
+ this._tweensAddedDuringUpdate[tween.getId()] = tween;
56
+ };
57
+ Group.prototype.remove = function (tween) {
58
+ delete this._tweens[tween.getId()];
59
+ delete this._tweensAddedDuringUpdate[tween.getId()];
60
+ };
61
+ Group.prototype.update = function (time, preserve) {
62
+ var tweenIds = Object.keys(this._tweens);
63
+ if (tweenIds.length === 0) {
64
+ return false;
65
+ }
66
+ time = time !== undefined ? time : NOW$1();
67
+ // Tweens are updated in "batches". If you add a new tween during an
68
+ // update, then the new tween will be updated in the next batch.
69
+ // If you remove a tween during an update, it may or may not be updated.
70
+ // However, if the removed tween was added during the current batch,
71
+ // then it will not be updated.
72
+ while (tweenIds.length > 0) {
73
+ this._tweensAddedDuringUpdate = {};
74
+ for (var i = 0; i < tweenIds.length; i++) {
75
+ var tween = this._tweens[tweenIds[i]];
76
+ if (tween && tween.update(time) === false && !preserve) {
77
+ delete this._tweens[tweenIds[i]];
78
+ }
79
+ }
80
+ tweenIds = Object.keys(this._tweensAddedDuringUpdate);
81
+ }
82
+ return true;
83
+ };
84
+ return Group;
85
+ }());
86
+
87
+ /**
88
+ * The Ease class provides a collection of easing functions for use with tween.js.
89
+ */
90
+ var Easing = {
91
+ Linear: {
92
+ None: function (amount) {
93
+ return amount;
94
+ },
95
+ },
96
+ Quadratic: {
97
+ In: function (amount) {
98
+ return amount * amount;
99
+ },
100
+ Out: function (amount) {
101
+ return amount * (2 - amount);
102
+ },
103
+ InOut: function (amount) {
104
+ if ((amount *= 2) < 1) {
105
+ return 0.5 * amount * amount;
106
+ }
107
+ return -0.5 * (--amount * (amount - 2) - 1);
108
+ },
109
+ },
110
+ Cubic: {
111
+ In: function (amount) {
112
+ return amount * amount * amount;
113
+ },
114
+ Out: function (amount) {
115
+ return --amount * amount * amount + 1;
116
+ },
117
+ InOut: function (amount) {
118
+ if ((amount *= 2) < 1) {
119
+ return 0.5 * amount * amount * amount;
120
+ }
121
+ return 0.5 * ((amount -= 2) * amount * amount + 2);
122
+ },
123
+ },
124
+ Quartic: {
125
+ In: function (amount) {
126
+ return amount * amount * amount * amount;
127
+ },
128
+ Out: function (amount) {
129
+ return 1 - --amount * amount * amount * amount;
130
+ },
131
+ InOut: function (amount) {
132
+ if ((amount *= 2) < 1) {
133
+ return 0.5 * amount * amount * amount * amount;
134
+ }
135
+ return -0.5 * ((amount -= 2) * amount * amount * amount - 2);
136
+ },
137
+ },
138
+ Quintic: {
139
+ In: function (amount) {
140
+ return amount * amount * amount * amount * amount;
141
+ },
142
+ Out: function (amount) {
143
+ return --amount * amount * amount * amount * amount + 1;
144
+ },
145
+ InOut: function (amount) {
146
+ if ((amount *= 2) < 1) {
147
+ return 0.5 * amount * amount * amount * amount * amount;
148
+ }
149
+ return 0.5 * ((amount -= 2) * amount * amount * amount * amount + 2);
150
+ },
151
+ },
152
+ Sinusoidal: {
153
+ In: function (amount) {
154
+ return 1 - Math.cos((amount * Math.PI) / 2);
155
+ },
156
+ Out: function (amount) {
157
+ return Math.sin((amount * Math.PI) / 2);
158
+ },
159
+ InOut: function (amount) {
160
+ return 0.5 * (1 - Math.cos(Math.PI * amount));
161
+ },
162
+ },
163
+ Exponential: {
164
+ In: function (amount) {
165
+ return amount === 0 ? 0 : Math.pow(1024, amount - 1);
166
+ },
167
+ Out: function (amount) {
168
+ return amount === 1 ? 1 : 1 - Math.pow(2, -10 * amount);
169
+ },
170
+ InOut: function (amount) {
171
+ if (amount === 0) {
172
+ return 0;
173
+ }
174
+ if (amount === 1) {
175
+ return 1;
176
+ }
177
+ if ((amount *= 2) < 1) {
178
+ return 0.5 * Math.pow(1024, amount - 1);
179
+ }
180
+ return 0.5 * (-Math.pow(2, -10 * (amount - 1)) + 2);
181
+ },
182
+ },
183
+ Circular: {
184
+ In: function (amount) {
185
+ return 1 - Math.sqrt(1 - amount * amount);
186
+ },
187
+ Out: function (amount) {
188
+ return Math.sqrt(1 - --amount * amount);
189
+ },
190
+ InOut: function (amount) {
191
+ if ((amount *= 2) < 1) {
192
+ return -0.5 * (Math.sqrt(1 - amount * amount) - 1);
193
+ }
194
+ return 0.5 * (Math.sqrt(1 - (amount -= 2) * amount) + 1);
195
+ },
196
+ },
197
+ Elastic: {
198
+ In: function (amount) {
199
+ if (amount === 0) {
200
+ return 0;
201
+ }
202
+ if (amount === 1) {
203
+ return 1;
204
+ }
205
+ return -Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI);
206
+ },
207
+ Out: function (amount) {
208
+ if (amount === 0) {
209
+ return 0;
210
+ }
211
+ if (amount === 1) {
212
+ return 1;
213
+ }
214
+ return Math.pow(2, -10 * amount) * Math.sin((amount - 0.1) * 5 * Math.PI) + 1;
215
+ },
216
+ InOut: function (amount) {
217
+ if (amount === 0) {
218
+ return 0;
219
+ }
220
+ if (amount === 1) {
221
+ return 1;
222
+ }
223
+ amount *= 2;
224
+ if (amount < 1) {
225
+ return -0.5 * Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI);
226
+ }
227
+ return 0.5 * Math.pow(2, -10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI) + 1;
228
+ },
229
+ },
230
+ Back: {
231
+ In: function (amount) {
232
+ var s = 1.70158;
233
+ return amount * amount * ((s + 1) * amount - s);
234
+ },
235
+ Out: function (amount) {
236
+ var s = 1.70158;
237
+ return --amount * amount * ((s + 1) * amount + s) + 1;
238
+ },
239
+ InOut: function (amount) {
240
+ var s = 1.70158 * 1.525;
241
+ if ((amount *= 2) < 1) {
242
+ return 0.5 * (amount * amount * ((s + 1) * amount - s));
243
+ }
244
+ return 0.5 * ((amount -= 2) * amount * ((s + 1) * amount + s) + 2);
245
+ },
246
+ },
247
+ Bounce: {
248
+ In: function (amount) {
249
+ return 1 - Easing.Bounce.Out(1 - amount);
250
+ },
251
+ Out: function (amount) {
252
+ if (amount < 1 / 2.75) {
253
+ return 7.5625 * amount * amount;
254
+ }
255
+ else if (amount < 2 / 2.75) {
256
+ return 7.5625 * (amount -= 1.5 / 2.75) * amount + 0.75;
257
+ }
258
+ else if (amount < 2.5 / 2.75) {
259
+ return 7.5625 * (amount -= 2.25 / 2.75) * amount + 0.9375;
260
+ }
261
+ else {
262
+ return 7.5625 * (amount -= 2.625 / 2.75) * amount + 0.984375;
263
+ }
264
+ },
265
+ InOut: function (amount) {
266
+ if (amount < 0.5) {
267
+ return Easing.Bounce.In(amount * 2) * 0.5;
268
+ }
269
+ return Easing.Bounce.Out(amount * 2 - 1) * 0.5 + 0.5;
270
+ },
271
+ },
14
272
  };
15
273
 
16
- _Group.prototype = {
17
- getAll: function () {
18
-
19
- return Object.keys(this._tweens).map(function (tweenId) {
20
- return this._tweens[tweenId];
21
- }.bind(this));
22
-
23
- },
24
-
25
- removeAll: function () {
26
-
27
- this._tweens = {};
28
-
29
- },
30
-
31
- add: function (tween) {
32
-
33
- this._tweens[tween.getId()] = tween;
34
- this._tweensAddedDuringUpdate[tween.getId()] = tween;
35
-
36
- },
37
-
38
- remove: function (tween) {
39
-
40
- delete this._tweens[tween.getId()];
41
- delete this._tweensAddedDuringUpdate[tween.getId()];
42
-
43
- },
44
-
45
- update: function (time, preserve) {
46
-
47
- var tweenIds = Object.keys(this._tweens);
48
-
49
- if (tweenIds.length === 0) {
50
- return false;
51
- }
52
-
53
- time = time !== undefined ? time : TWEEN.now();
54
-
55
- // Tweens are updated in "batches". If you add a new tween during an
56
- // update, then the new tween will be updated in the next batch.
57
- // If you remove a tween during an update, it may or may not be updated.
58
- // However, if the removed tween was added during the current batch,
59
- // then it will not be updated.
60
- while (tweenIds.length > 0) {
61
- this._tweensAddedDuringUpdate = {};
62
-
63
- for (var i = 0; i < tweenIds.length; i++) {
64
-
65
- var tween = this._tweens[tweenIds[i]];
66
-
67
- if (tween && tween.update(time) === false) {
68
- tween._isPlaying = false;
69
-
70
- if (!preserve) {
71
- delete this._tweens[tweenIds[i]];
72
- }
73
- }
74
- }
75
-
76
- tweenIds = Object.keys(this._tweensAddedDuringUpdate);
77
- }
78
-
79
- return true;
80
-
81
- }
82
- };
83
-
84
- var TWEEN = new _Group();
85
-
86
- TWEEN.Group = _Group;
87
- TWEEN._nextId = 0;
88
- TWEEN.nextId = function () {
89
- return TWEEN._nextId++;
90
- };
91
-
92
-
93
- // Include a performance.now polyfill.
94
- // In node.js, use process.hrtime.
95
- if (typeof (self) === 'undefined' && typeof (process) !== 'undefined' && process.hrtime) {
96
- TWEEN.now = function () {
97
- var time = process.hrtime();
98
-
99
- // Convert [seconds, nanoseconds] to milliseconds.
100
- return time[0] * 1000 + time[1] / 1000000;
101
- };
102
- }
103
- // In a browser, use self.performance.now if it is available.
104
- else if (typeof (self) !== 'undefined' &&
105
- self.performance !== undefined &&
106
- self.performance.now !== undefined) {
107
- // This must be bound, because directly assigning this function
108
- // leads to an invocation exception in Chrome.
109
- TWEEN.now = self.performance.now.bind(self.performance);
110
- }
111
- // Use Date.now if it is available.
112
- else if (Date.now !== undefined) {
113
- TWEEN.now = Date.now;
114
- }
115
- // Otherwise, use 'new Date().getTime()'.
116
- else {
117
- TWEEN.now = function () {
118
- return new Date().getTime();
119
- };
120
- }
121
-
122
-
123
- TWEEN.Tween = function (object, group) {
124
- this._isPaused = false;
125
- this._pauseStart = null;
126
- this._object = object;
127
- this._valuesStart = {};
128
- this._valuesEnd = {};
129
- this._valuesStartRepeat = {};
130
- this._duration = 1000;
131
- this._repeat = 0;
132
- this._repeatDelayTime = undefined;
133
- this._yoyo = false;
134
- this._isPlaying = false;
135
- this._reversed = false;
136
- this._delayTime = 0;
137
- this._startTime = null;
138
- this._easingFunction = TWEEN.Easing.Linear.None;
139
- this._interpolationFunction = TWEEN.Interpolation.Linear;
140
- this._chainedTweens = [];
141
- this._onStartCallback = null;
142
- this._onStartCallbackFired = false;
143
- this._onUpdateCallback = null;
144
- this._onRepeatCallback = null;
145
- this._onCompleteCallback = null;
146
- this._onStopCallback = null;
147
- this._group = group || TWEEN;
148
- this._id = TWEEN.nextId();
149
-
274
+ /**
275
+ *
276
+ */
277
+ var Interpolation = {
278
+ Linear: function (v, k) {
279
+ var m = v.length - 1;
280
+ var f = m * k;
281
+ var i = Math.floor(f);
282
+ var fn = Interpolation.Utils.Linear;
283
+ if (k < 0) {
284
+ return fn(v[0], v[1], f);
285
+ }
286
+ if (k > 1) {
287
+ return fn(v[m], v[m - 1], m - f);
288
+ }
289
+ return fn(v[i], v[i + 1 > m ? m : i + 1], f - i);
290
+ },
291
+ Bezier: function (v, k) {
292
+ var b = 0;
293
+ var n = v.length - 1;
294
+ var pw = Math.pow;
295
+ var bn = Interpolation.Utils.Bernstein;
296
+ for (var i = 0; i <= n; i++) {
297
+ b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i);
298
+ }
299
+ return b;
300
+ },
301
+ CatmullRom: function (v, k) {
302
+ var m = v.length - 1;
303
+ var f = m * k;
304
+ var i = Math.floor(f);
305
+ var fn = Interpolation.Utils.CatmullRom;
306
+ if (v[0] === v[m]) {
307
+ if (k < 0) {
308
+ i = Math.floor((f = m * (1 + k)));
309
+ }
310
+ return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i);
311
+ }
312
+ else {
313
+ if (k < 0) {
314
+ return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]);
315
+ }
316
+ if (k > 1) {
317
+ return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]);
318
+ }
319
+ 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);
320
+ }
321
+ },
322
+ Utils: {
323
+ Linear: function (p0, p1, t) {
324
+ return (p1 - p0) * t + p0;
325
+ },
326
+ Bernstein: function (n, i) {
327
+ var fc = Interpolation.Utils.Factorial;
328
+ return fc(n) / fc(i) / fc(n - i);
329
+ },
330
+ Factorial: (function () {
331
+ var a = [1];
332
+ return function (n) {
333
+ var s = 1;
334
+ if (a[n]) {
335
+ return a[n];
336
+ }
337
+ for (var i = n; i > 1; i--) {
338
+ s *= i;
339
+ }
340
+ a[n] = s;
341
+ return s;
342
+ };
343
+ })(),
344
+ CatmullRom: function (p0, p1, p2, p3, t) {
345
+ var v0 = (p2 - p0) * 0.5;
346
+ var v1 = (p3 - p1) * 0.5;
347
+ var t2 = t * t;
348
+ var t3 = t * t2;
349
+ return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;
350
+ },
351
+ },
150
352
  };
151
353
 
152
- TWEEN.Tween.prototype = {
153
- getId: function () {
154
- return this._id;
155
- },
156
-
157
- isPlaying: function () {
158
- return this._isPlaying;
159
- },
160
-
161
- isPaused: function () {
162
- return this._isPaused;
163
- },
164
-
165
- to: function (properties, duration) {
166
-
167
- this._valuesEnd = Object.create(properties);
168
-
169
- if (duration !== undefined) {
170
- this._duration = duration;
171
- }
172
-
173
- return this;
174
-
175
- },
176
-
177
- duration: function duration(d) {
178
- this._duration = d;
179
- return this;
180
- },
181
-
182
- start: function (time) {
183
-
184
- this._group.add(this);
185
-
186
- this._isPlaying = true;
187
-
188
- this._isPaused = false;
189
-
190
- this._onStartCallbackFired = false;
191
-
192
- this._startTime = time !== undefined ? typeof time === 'string' ? TWEEN.now() + parseFloat(time) : time : TWEEN.now();
193
- this._startTime += this._delayTime;
194
-
195
- for (var property in this._valuesEnd) {
196
-
197
- // Check if an Array was provided as property value
198
- if (this._valuesEnd[property] instanceof Array) {
199
-
200
- if (this._valuesEnd[property].length === 0) {
201
- continue;
202
- }
203
-
204
- // Create a local copy of the Array with the start value at the front
205
- this._valuesEnd[property] = [this._object[property]].concat(this._valuesEnd[property]);
206
-
207
- }
208
-
209
- // If `to()` specifies a property that doesn't exist in the source object,
210
- // we should not set that property in the object
211
- if (this._object[property] === undefined) {
212
- continue;
213
- }
214
-
215
- // Save the starting value, but only once.
216
- if (typeof(this._valuesStart[property]) === 'undefined') {
217
- this._valuesStart[property] = this._object[property];
218
- }
219
-
220
- if ((this._valuesStart[property] instanceof Array) === false) {
221
- this._valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings
222
- }
223
-
224
- this._valuesStartRepeat[property] = this._valuesStart[property] || 0;
225
-
226
- }
227
-
228
- return this;
229
-
230
- },
231
-
232
- stop: function () {
233
-
234
- if (!this._isPlaying) {
235
- return this;
236
- }
237
-
238
- this._group.remove(this);
239
-
240
- this._isPlaying = false;
241
-
242
- this._isPaused = false;
243
-
244
- if (this._onStopCallback !== null) {
245
- this._onStopCallback(this._object);
246
- }
247
-
248
- this.stopChainedTweens();
249
- return this;
250
-
251
- },
252
-
253
- end: function () {
254
-
255
- this.update(Infinity);
256
- return this;
257
-
258
- },
259
-
260
- pause: function(time) {
261
-
262
- if (this._isPaused || !this._isPlaying) {
263
- return this;
264
- }
265
-
266
- this._isPaused = true;
267
-
268
- this._pauseStart = time === undefined ? TWEEN.now() : time;
269
-
270
- this._group.remove(this);
271
-
272
- return this;
273
-
274
- },
275
-
276
- resume: function(time) {
277
-
278
- if (!this._isPaused || !this._isPlaying) {
279
- return this;
280
- }
281
-
282
- this._isPaused = false;
283
-
284
- this._startTime += (time === undefined ? TWEEN.now() : time)
285
- - this._pauseStart;
286
-
287
- this._pauseStart = 0;
288
-
289
- this._group.add(this);
290
-
291
- return this;
292
-
293
- },
294
-
295
- stopChainedTweens: function () {
296
-
297
- for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
298
- this._chainedTweens[i].stop();
299
- }
300
-
301
- },
302
-
303
- group: function (group) {
304
- this._group = group;
305
- return this;
306
- },
307
-
308
- delay: function (amount) {
309
-
310
- this._delayTime = amount;
311
- return this;
312
-
313
- },
314
-
315
- repeat: function (times) {
316
-
317
- this._repeat = times;
318
- return this;
319
-
320
- },
321
-
322
- repeatDelay: function (amount) {
323
-
324
- this._repeatDelayTime = amount;
325
- return this;
326
-
327
- },
328
-
329
- yoyo: function (yoyo) {
330
-
331
- this._yoyo = yoyo;
332
- return this;
333
-
334
- },
335
-
336
- easing: function (easingFunction) {
337
-
338
- this._easingFunction = easingFunction;
339
- return this;
340
-
341
- },
342
-
343
- interpolation: function (interpolationFunction) {
344
-
345
- this._interpolationFunction = interpolationFunction;
346
- return this;
347
-
348
- },
349
-
350
- chain: function () {
351
-
352
- this._chainedTweens = arguments;
353
- return this;
354
-
355
- },
356
-
357
- onStart: function (callback) {
358
-
359
- this._onStartCallback = callback;
360
- return this;
361
-
362
- },
363
-
364
- onUpdate: function (callback) {
365
-
366
- this._onUpdateCallback = callback;
367
- return this;
368
-
369
- },
370
-
371
- onRepeat: function onRepeat(callback) {
372
-
373
- this._onRepeatCallback = callback;
374
- return this;
375
-
376
- },
377
-
378
- onComplete: function (callback) {
379
-
380
- this._onCompleteCallback = callback;
381
- return this;
382
-
383
- },
384
-
385
- onStop: function (callback) {
386
-
387
- this._onStopCallback = callback;
388
- return this;
389
-
390
- },
391
-
392
- update: function (time) {
393
-
394
- var property;
395
- var elapsed;
396
- var value;
397
-
398
- if (time < this._startTime) {
399
- return true;
400
- }
401
-
402
- if (this._onStartCallbackFired === false) {
403
-
404
- if (this._onStartCallback !== null) {
405
- this._onStartCallback(this._object);
406
- }
407
-
408
- this._onStartCallbackFired = true;
409
- }
410
-
411
- elapsed = (time - this._startTime) / this._duration;
412
- elapsed = (this._duration === 0 || elapsed > 1) ? 1 : elapsed;
413
-
414
- value = this._easingFunction(elapsed);
415
-
416
- for (property in this._valuesEnd) {
417
-
418
- // Don't update properties that do not exist in the source object
419
- if (this._valuesStart[property] === undefined) {
420
- continue;
421
- }
422
-
423
- var start = this._valuesStart[property] || 0;
424
- var end = this._valuesEnd[property];
425
-
426
- if (end instanceof Array) {
427
-
428
- this._object[property] = this._interpolationFunction(end, value);
429
-
430
- } else {
431
-
432
- // Parses relative end values with start as base (e.g.: +10, -3)
433
- if (typeof (end) === 'string') {
434
-
435
- if (end.charAt(0) === '+' || end.charAt(0) === '-') {
436
- end = start + parseFloat(end);
437
- } else {
438
- end = parseFloat(end);
439
- }
440
- }
441
-
442
- // Protect against non numeric properties.
443
- if (typeof (end) === 'number') {
444
- this._object[property] = start + (end - start) * value;
445
- }
446
-
447
- }
448
-
449
- }
450
-
451
- if (this._onUpdateCallback !== null) {
452
- this._onUpdateCallback(this._object, elapsed);
453
- }
454
-
455
- if (elapsed === 1) {
456
-
457
- if (this._repeat > 0) {
458
-
459
- if (isFinite(this._repeat)) {
460
- this._repeat--;
461
- }
462
-
463
- // Reassign starting values, restart by making startTime = now
464
- for (property in this._valuesStartRepeat) {
465
-
466
- if (typeof (this._valuesEnd[property]) === 'string') {
467
- this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]);
468
- }
469
-
470
- if (this._yoyo) {
471
- var tmp = this._valuesStartRepeat[property];
472
-
473
- this._valuesStartRepeat[property] = this._valuesEnd[property];
474
- this._valuesEnd[property] = tmp;
475
- }
476
-
477
- this._valuesStart[property] = this._valuesStartRepeat[property];
478
-
479
- }
480
-
481
- if (this._yoyo) {
482
- this._reversed = !this._reversed;
483
- }
484
-
485
- if (this._repeatDelayTime !== undefined) {
486
- this._startTime = time + this._repeatDelayTime;
487
- } else {
488
- this._startTime = time + this._delayTime;
489
- }
490
-
491
- if (this._onRepeatCallback !== null) {
492
- this._onRepeatCallback(this._object);
493
- }
494
-
495
- return true;
496
-
497
- } else {
498
-
499
- if (this._onCompleteCallback !== null) {
500
-
501
- this._onCompleteCallback(this._object);
502
- }
503
-
504
- for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
505
- // Make the chained tweens start exactly at the time they should,
506
- // even if the `update()` method was called way past the duration of the tween
507
- this._chainedTweens[i].start(this._startTime + this._duration);
508
- }
509
-
510
- return false;
511
-
512
- }
513
-
514
- }
515
-
516
- return true;
517
-
518
- }
519
- };
520
-
521
-
522
- TWEEN.Easing = {
523
-
524
- Linear: {
525
-
526
- None: function (k) {
527
-
528
- return k;
529
-
530
- }
531
-
532
- },
533
-
534
- Quadratic: {
535
-
536
- In: function (k) {
537
-
538
- return k * k;
539
-
540
- },
541
-
542
- Out: function (k) {
543
-
544
- return k * (2 - k);
545
-
546
- },
547
-
548
- InOut: function (k) {
549
-
550
- if ((k *= 2) < 1) {
551
- return 0.5 * k * k;
552
- }
553
-
554
- return - 0.5 * (--k * (k - 2) - 1);
555
-
556
- }
557
-
558
- },
559
-
560
- Cubic: {
561
-
562
- In: function (k) {
563
-
564
- return k * k * k;
565
-
566
- },
567
-
568
- Out: function (k) {
569
-
570
- return --k * k * k + 1;
571
-
572
- },
573
-
574
- InOut: function (k) {
575
-
576
- if ((k *= 2) < 1) {
577
- return 0.5 * k * k * k;
578
- }
579
-
580
- return 0.5 * ((k -= 2) * k * k + 2);
581
-
582
- }
583
-
584
- },
585
-
586
- Quartic: {
587
-
588
- In: function (k) {
589
-
590
- return k * k * k * k;
591
-
592
- },
593
-
594
- Out: function (k) {
595
-
596
- return 1 - (--k * k * k * k);
597
-
598
- },
599
-
600
- InOut: function (k) {
601
-
602
- if ((k *= 2) < 1) {
603
- return 0.5 * k * k * k * k;
604
- }
605
-
606
- return - 0.5 * ((k -= 2) * k * k * k - 2);
607
-
608
- }
609
-
610
- },
611
-
612
- Quintic: {
613
-
614
- In: function (k) {
615
-
616
- return k * k * k * k * k;
617
-
618
- },
619
-
620
- Out: function (k) {
621
-
622
- return --k * k * k * k * k + 1;
623
-
624
- },
625
-
626
- InOut: function (k) {
627
-
628
- if ((k *= 2) < 1) {
629
- return 0.5 * k * k * k * k * k;
630
- }
631
-
632
- return 0.5 * ((k -= 2) * k * k * k * k + 2);
633
-
634
- }
635
-
636
- },
637
-
638
- Sinusoidal: {
639
-
640
- In: function (k) {
641
-
642
- return 1 - Math.cos(k * Math.PI / 2);
643
-
644
- },
645
-
646
- Out: function (k) {
647
-
648
- return Math.sin(k * Math.PI / 2);
649
-
650
- },
651
-
652
- InOut: function (k) {
653
-
654
- return 0.5 * (1 - Math.cos(Math.PI * k));
655
-
656
- }
657
-
658
- },
659
-
660
- Exponential: {
661
-
662
- In: function (k) {
663
-
664
- return k === 0 ? 0 : Math.pow(1024, k - 1);
665
-
666
- },
667
-
668
- Out: function (k) {
669
-
670
- return k === 1 ? 1 : 1 - Math.pow(2, - 10 * k);
671
-
672
- },
673
-
674
- InOut: function (k) {
675
-
676
- if (k === 0) {
677
- return 0;
678
- }
679
-
680
- if (k === 1) {
681
- return 1;
682
- }
683
-
684
- if ((k *= 2) < 1) {
685
- return 0.5 * Math.pow(1024, k - 1);
686
- }
687
-
688
- return 0.5 * (- Math.pow(2, - 10 * (k - 1)) + 2);
689
-
690
- }
691
-
692
- },
693
-
694
- Circular: {
695
-
696
- In: function (k) {
697
-
698
- return 1 - Math.sqrt(1 - k * k);
699
-
700
- },
701
-
702
- Out: function (k) {
703
-
704
- return Math.sqrt(1 - (--k * k));
705
-
706
- },
707
-
708
- InOut: function (k) {
709
-
710
- if ((k *= 2) < 1) {
711
- return - 0.5 * (Math.sqrt(1 - k * k) - 1);
712
- }
713
-
714
- return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1);
715
-
716
- }
717
-
718
- },
719
-
720
- Elastic: {
721
-
722
- In: function (k) {
723
-
724
- if (k === 0) {
725
- return 0;
726
- }
727
-
728
- if (k === 1) {
729
- return 1;
730
- }
731
-
732
- return -Math.pow(2, 10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI);
733
-
734
- },
735
-
736
- Out: function (k) {
737
-
738
- if (k === 0) {
739
- return 0;
740
- }
741
-
742
- if (k === 1) {
743
- return 1;
744
- }
745
-
746
- return Math.pow(2, -10 * k) * Math.sin((k - 0.1) * 5 * Math.PI) + 1;
747
-
748
- },
749
-
750
- InOut: function (k) {
751
-
752
- if (k === 0) {
753
- return 0;
754
- }
755
-
756
- if (k === 1) {
757
- return 1;
758
- }
759
-
760
- k *= 2;
761
-
762
- if (k < 1) {
763
- return -0.5 * Math.pow(2, 10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI);
764
- }
765
-
766
- return 0.5 * Math.pow(2, -10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI) + 1;
767
-
768
- }
769
-
770
- },
771
-
772
- Back: {
773
-
774
- In: function (k) {
775
-
776
- var s = 1.70158;
777
-
778
- return k * k * ((s + 1) * k - s);
779
-
780
- },
781
-
782
- Out: function (k) {
783
-
784
- var s = 1.70158;
785
-
786
- return --k * k * ((s + 1) * k + s) + 1;
787
-
788
- },
789
-
790
- InOut: function (k) {
791
-
792
- var s = 1.70158 * 1.525;
793
-
794
- if ((k *= 2) < 1) {
795
- return 0.5 * (k * k * ((s + 1) * k - s));
796
- }
797
-
798
- return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
799
-
800
- }
801
-
802
- },
803
-
804
- Bounce: {
805
-
806
- In: function (k) {
807
-
808
- return 1 - TWEEN.Easing.Bounce.Out(1 - k);
809
-
810
- },
811
-
812
- Out: function (k) {
813
-
814
- if (k < (1 / 2.75)) {
815
- return 7.5625 * k * k;
816
- } else if (k < (2 / 2.75)) {
817
- return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75;
818
- } else if (k < (2.5 / 2.75)) {
819
- return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375;
820
- } else {
821
- return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375;
822
- }
823
-
824
- },
825
-
826
- InOut: function (k) {
827
-
828
- if (k < 0.5) {
829
- return TWEEN.Easing.Bounce.In(k * 2) * 0.5;
830
- }
831
-
832
- return TWEEN.Easing.Bounce.Out(k * 2 - 1) * 0.5 + 0.5;
833
-
834
- }
835
-
836
- }
837
-
838
- };
839
-
840
- TWEEN.Interpolation = {
841
-
842
- Linear: function (v, k) {
843
-
844
- var m = v.length - 1;
845
- var f = m * k;
846
- var i = Math.floor(f);
847
- var fn = TWEEN.Interpolation.Utils.Linear;
848
-
849
- if (k < 0) {
850
- return fn(v[0], v[1], f);
851
- }
852
-
853
- if (k > 1) {
854
- return fn(v[m], v[m - 1], m - f);
855
- }
856
-
857
- return fn(v[i], v[i + 1 > m ? m : i + 1], f - i);
858
-
859
- },
860
-
861
- Bezier: function (v, k) {
862
-
863
- var b = 0;
864
- var n = v.length - 1;
865
- var pw = Math.pow;
866
- var bn = TWEEN.Interpolation.Utils.Bernstein;
867
-
868
- for (var i = 0; i <= n; i++) {
869
- b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i);
870
- }
871
-
872
- return b;
873
-
874
- },
875
-
876
- CatmullRom: function (v, k) {
877
-
878
- var m = v.length - 1;
879
- var f = m * k;
880
- var i = Math.floor(f);
881
- var fn = TWEEN.Interpolation.Utils.CatmullRom;
882
-
883
- if (v[0] === v[m]) {
884
-
885
- if (k < 0) {
886
- i = Math.floor(f = m * (1 + k));
887
- }
888
-
889
- return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i);
890
-
891
- } else {
892
-
893
- if (k < 0) {
894
- return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]);
895
- }
896
-
897
- if (k > 1) {
898
- return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]);
899
- }
900
-
901
- 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);
902
-
903
- }
904
-
905
- },
906
-
907
- Utils: {
908
-
909
- Linear: function (p0, p1, t) {
910
-
911
- return (p1 - p0) * t + p0;
912
-
913
- },
914
-
915
- Bernstein: function (n, i) {
916
-
917
- var fc = TWEEN.Interpolation.Utils.Factorial;
918
-
919
- return fc(n) / fc(i) / fc(n - i);
920
-
921
- },
922
-
923
- Factorial: (function () {
924
-
925
- var a = [1];
926
-
927
- return function (n) {
928
-
929
- var s = 1;
930
-
931
- if (a[n]) {
932
- return a[n];
933
- }
934
-
935
- for (var i = n; i > 1; i--) {
936
- s *= i;
937
- }
938
-
939
- a[n] = s;
940
- return s;
941
-
942
- };
943
-
944
- })(),
945
-
946
- CatmullRom: function (p0, p1, p2, p3, t) {
947
-
948
- var v0 = (p2 - p0) * 0.5;
949
- var v1 = (p3 - p1) * 0.5;
950
- var t2 = t * t;
951
- var t3 = t * t2;
952
-
953
- return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (- 3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;
954
-
955
- }
956
-
957
- }
958
-
959
- };
354
+ /**
355
+ * Utils
356
+ */
357
+ var Sequence = /** @class */ (function () {
358
+ function Sequence() {
359
+ }
360
+ Sequence.nextId = function () {
361
+ return Sequence._nextId++;
362
+ };
363
+ Sequence._nextId = 0;
364
+ return Sequence;
365
+ }());
366
+
367
+ /**
368
+ * Tween.js - Licensed under the MIT license
369
+ * https://github.com/tweenjs/tween.js
370
+ * ----------------------------------------------
371
+ *
372
+ * See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors.
373
+ * Thank you all, you're awesome!
374
+ */
375
+ var Tween = /** @class */ (function () {
376
+ function Tween(_object, _group) {
377
+ if (_group === void 0) { _group = TWEEN; }
378
+ this._object = _object;
379
+ this._group = _group;
380
+ this._isPaused = false;
381
+ this._pauseStart = 0;
382
+ this._valuesStart = {};
383
+ this._valuesEnd = {};
384
+ this._valuesStartRepeat = {};
385
+ this._duration = 1000;
386
+ this._initialRepeat = 0;
387
+ this._repeat = 0;
388
+ this._yoyo = false;
389
+ this._isPlaying = false;
390
+ this._reversed = false;
391
+ this._delayTime = 0;
392
+ this._startTime = 0;
393
+ this._easingFunction = TWEEN.Easing.Linear.None;
394
+ this._interpolationFunction = TWEEN.Interpolation.Linear;
395
+ this._chainedTweens = [];
396
+ this._onStartCallbackFired = false;
397
+ this._id = TWEEN.nextId();
398
+ this._isChainStopped = false;
399
+ }
400
+ Tween.prototype.getId = function () {
401
+ return this._id;
402
+ };
403
+ Tween.prototype.isPlaying = function () {
404
+ return this._isPlaying;
405
+ };
406
+ Tween.prototype.isPaused = function () {
407
+ return this._isPaused;
408
+ };
409
+ Tween.prototype.to = function (properties, duration) {
410
+ for (var prop in properties) {
411
+ this._valuesEnd[prop] = properties[prop];
412
+ }
413
+ if (duration !== undefined) {
414
+ this._duration = duration;
415
+ }
416
+ return this;
417
+ };
418
+ Tween.prototype.duration = function (d) {
419
+ this._duration = d;
420
+ return this;
421
+ };
422
+ Tween.prototype.start = function (time) {
423
+ if (this._isPlaying) {
424
+ return this;
425
+ }
426
+ // eslint-disable-next-line
427
+ // @ts-ignore FIXME?
428
+ this._group.add(this);
429
+ this._repeat = this._initialRepeat;
430
+ if (this._reversed) {
431
+ // If we were reversed (f.e. using the yoyo feature) then we need to
432
+ // flip the tween direction back to forward.
433
+ this._reversed = false;
434
+ for (var property in this._valuesStartRepeat) {
435
+ this._swapEndStartRepeatValues(property);
436
+ this._valuesStart[property] = this._valuesStartRepeat[property];
437
+ }
438
+ }
439
+ this._isPlaying = true;
440
+ this._isPaused = false;
441
+ this._onStartCallbackFired = false;
442
+ this._isChainStopped = false;
443
+ this._startTime =
444
+ time !== undefined ? (typeof time === 'string' ? TWEEN.now() + parseFloat(time) : time) : TWEEN.now();
445
+ this._startTime += this._delayTime;
446
+ this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat);
447
+ return this;
448
+ };
449
+ Tween.prototype._setupProperties = function (_object, _valuesStart, _valuesEnd, _valuesStartRepeat) {
450
+ for (var property in _valuesEnd) {
451
+ var startValue = _object[property];
452
+ var startValueIsArray = Array.isArray(startValue);
453
+ var propType = startValueIsArray ? 'array' : typeof startValue;
454
+ var isInterpolationList = !startValueIsArray && Array.isArray(_valuesEnd[property]);
455
+ // If `to()` specifies a property that doesn't exist in the source object,
456
+ // we should not set that property in the object
457
+ if (propType === 'undefined' || propType === 'function') {
458
+ continue;
459
+ }
460
+ // Check if an Array was provided as property value
461
+ if (isInterpolationList) {
462
+ var endValues = _valuesEnd[property];
463
+ if (endValues.length === 0) {
464
+ continue;
465
+ }
466
+ // handle an array of relative values
467
+ endValues = endValues.map(this._handleRelativeValue.bind(this, startValue));
468
+ // Create a local copy of the Array with the start value at the front
469
+ _valuesEnd[property] = [startValue].concat(endValues);
470
+ }
471
+ // handle the deepness of the values
472
+ if ((propType === 'object' || startValueIsArray) && startValue && !isInterpolationList) {
473
+ _valuesStart[property] = startValueIsArray ? [] : {};
474
+ // eslint-disable-next-line
475
+ for (var prop in startValue) {
476
+ // eslint-disable-next-line
477
+ // @ts-ignore FIXME?
478
+ _valuesStart[property][prop] = startValue[prop];
479
+ }
480
+ _valuesStartRepeat[property] = startValueIsArray ? [] : {}; // TODO? repeat nested values? And yoyo? And array values?
481
+ // eslint-disable-next-line
482
+ // @ts-ignore FIXME?
483
+ this._setupProperties(startValue, _valuesStart[property], _valuesEnd[property], _valuesStartRepeat[property]);
484
+ }
485
+ else {
486
+ // Save the starting value, but only once.
487
+ if (typeof _valuesStart[property] === 'undefined') {
488
+ _valuesStart[property] = startValue;
489
+ }
490
+ if (!startValueIsArray) {
491
+ // eslint-disable-next-line
492
+ // @ts-ignore FIXME?
493
+ _valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings
494
+ }
495
+ if (isInterpolationList) {
496
+ // eslint-disable-next-line
497
+ // @ts-ignore FIXME?
498
+ _valuesStartRepeat[property] = _valuesEnd[property].slice().reverse();
499
+ }
500
+ else {
501
+ _valuesStartRepeat[property] = _valuesStart[property] || 0;
502
+ }
503
+ }
504
+ }
505
+ };
506
+ Tween.prototype.stop = function () {
507
+ if (!this._isChainStopped) {
508
+ this._isChainStopped = true;
509
+ this.stopChainedTweens();
510
+ }
511
+ if (!this._isPlaying) {
512
+ return this;
513
+ }
514
+ // eslint-disable-next-line
515
+ // @ts-ignore FIXME?
516
+ this._group.remove(this);
517
+ this._isPlaying = false;
518
+ this._isPaused = false;
519
+ if (this._onStopCallback) {
520
+ this._onStopCallback(this._object);
521
+ }
522
+ return this;
523
+ };
524
+ Tween.prototype.end = function () {
525
+ this.update(Infinity);
526
+ return this;
527
+ };
528
+ Tween.prototype.pause = function (time) {
529
+ if (this._isPaused || !this._isPlaying) {
530
+ return this;
531
+ }
532
+ this._isPaused = true;
533
+ this._pauseStart = time === undefined ? TWEEN.now() : time;
534
+ // eslint-disable-next-line
535
+ // @ts-ignore FIXME?
536
+ this._group.remove(this);
537
+ return this;
538
+ };
539
+ Tween.prototype.resume = function (time) {
540
+ if (!this._isPaused || !this._isPlaying) {
541
+ return this;
542
+ }
543
+ this._isPaused = false;
544
+ this._startTime += (time === undefined ? TWEEN.now() : time) - this._pauseStart;
545
+ this._pauseStart = 0;
546
+ // eslint-disable-next-line
547
+ // @ts-ignore FIXME?
548
+ this._group.add(this);
549
+ return this;
550
+ };
551
+ Tween.prototype.stopChainedTweens = function () {
552
+ for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
553
+ this._chainedTweens[i].stop();
554
+ }
555
+ return this;
556
+ };
557
+ Tween.prototype.group = function (group) {
558
+ this._group = group;
559
+ return this;
560
+ };
561
+ Tween.prototype.delay = function (amount) {
562
+ this._delayTime = amount;
563
+ return this;
564
+ };
565
+ Tween.prototype.repeat = function (times) {
566
+ this._initialRepeat = times;
567
+ this._repeat = times;
568
+ return this;
569
+ };
570
+ Tween.prototype.repeatDelay = function (amount) {
571
+ this._repeatDelayTime = amount;
572
+ return this;
573
+ };
574
+ Tween.prototype.yoyo = function (yoyo) {
575
+ this._yoyo = yoyo;
576
+ return this;
577
+ };
578
+ Tween.prototype.easing = function (easingFunction) {
579
+ this._easingFunction = easingFunction;
580
+ return this;
581
+ };
582
+ Tween.prototype.interpolation = function (interpolationFunction) {
583
+ this._interpolationFunction = interpolationFunction;
584
+ return this;
585
+ };
586
+ Tween.prototype.chain = function () {
587
+ var tweens = [];
588
+ for (var _i = 0; _i < arguments.length; _i++) {
589
+ tweens[_i] = arguments[_i];
590
+ }
591
+ this._chainedTweens = tweens;
592
+ return this;
593
+ };
594
+ Tween.prototype.onStart = function (callback) {
595
+ this._onStartCallback = callback;
596
+ return this;
597
+ };
598
+ Tween.prototype.onUpdate = function (callback) {
599
+ this._onUpdateCallback = callback;
600
+ return this;
601
+ };
602
+ Tween.prototype.onRepeat = function (callback) {
603
+ this._onRepeatCallback = callback;
604
+ return this;
605
+ };
606
+ Tween.prototype.onComplete = function (callback) {
607
+ this._onCompleteCallback = callback;
608
+ return this;
609
+ };
610
+ Tween.prototype.onStop = function (callback) {
611
+ this._onStopCallback = callback;
612
+ return this;
613
+ };
614
+ Tween.prototype.update = function (time) {
615
+ var property;
616
+ var elapsed;
617
+ var endTime = this._startTime + this._duration;
618
+ if (time > endTime && !this._isPlaying) {
619
+ return false;
620
+ }
621
+ // If the tween was already finished,
622
+ if (!this.isPlaying) {
623
+ this.start(time);
624
+ }
625
+ if (time < this._startTime) {
626
+ return true;
627
+ }
628
+ if (this._onStartCallbackFired === false) {
629
+ if (this._onStartCallback) {
630
+ this._onStartCallback(this._object);
631
+ }
632
+ this._onStartCallbackFired = true;
633
+ }
634
+ elapsed = (time - this._startTime) / this._duration;
635
+ elapsed = this._duration === 0 || elapsed > 1 ? 1 : elapsed;
636
+ var value = this._easingFunction(elapsed);
637
+ // properties transformations
638
+ this._updateProperties(this._object, this._valuesStart, this._valuesEnd, value);
639
+ if (this._onUpdateCallback) {
640
+ this._onUpdateCallback(this._object, elapsed);
641
+ }
642
+ if (elapsed === 1) {
643
+ if (this._repeat > 0) {
644
+ if (isFinite(this._repeat)) {
645
+ this._repeat--;
646
+ }
647
+ // Reassign starting values, restart by making startTime = now
648
+ for (property in this._valuesStartRepeat) {
649
+ if (!this._yoyo && typeof this._valuesEnd[property] === 'string') {
650
+ this._valuesStartRepeat[property] =
651
+ // eslint-disable-next-line
652
+ // @ts-ignore FIXME?
653
+ this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]);
654
+ }
655
+ if (this._yoyo) {
656
+ this._swapEndStartRepeatValues(property);
657
+ }
658
+ this._valuesStart[property] = this._valuesStartRepeat[property];
659
+ }
660
+ if (this._yoyo) {
661
+ this._reversed = !this._reversed;
662
+ }
663
+ if (this._repeatDelayTime !== undefined) {
664
+ this._startTime = time + this._repeatDelayTime;
665
+ }
666
+ else {
667
+ this._startTime = time + this._delayTime;
668
+ }
669
+ if (this._onRepeatCallback) {
670
+ this._onRepeatCallback(this._object);
671
+ }
672
+ return true;
673
+ }
674
+ else {
675
+ if (this._onCompleteCallback) {
676
+ this._onCompleteCallback(this._object);
677
+ }
678
+ for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
679
+ // Make the chained tweens start exactly at the time they should,
680
+ // even if the `update()` method was called way past the duration of the tween
681
+ this._chainedTweens[i].start(this._startTime + this._duration);
682
+ }
683
+ this._isPlaying = false;
684
+ return false;
685
+ }
686
+ }
687
+ return true;
688
+ };
689
+ Tween.prototype._updateProperties = function (_object, _valuesStart, _valuesEnd, value) {
690
+ for (var property in _valuesEnd) {
691
+ // Don't update properties that do not exist in the source object
692
+ if (_valuesStart[property] === undefined) {
693
+ continue;
694
+ }
695
+ var start = _valuesStart[property] || 0;
696
+ var end = _valuesEnd[property];
697
+ var startIsArray = Array.isArray(_object[property]);
698
+ var endIsArray = Array.isArray(end);
699
+ var isInterpolationList = !startIsArray && endIsArray;
700
+ if (isInterpolationList) {
701
+ _object[property] = this._interpolationFunction(end, value);
702
+ }
703
+ else if (typeof end === 'object' && end) {
704
+ // eslint-disable-next-line
705
+ // @ts-ignore FIXME?
706
+ this._updateProperties(_object[property], start, end, value);
707
+ }
708
+ else {
709
+ // Parses relative end values with start as base (e.g.: +10, -3)
710
+ end = this._handleRelativeValue(start, end);
711
+ // Protect against non numeric properties.
712
+ if (typeof end === 'number') {
713
+ // eslint-disable-next-line
714
+ // @ts-ignore FIXME?
715
+ _object[property] = start + (end - start) * value;
716
+ }
717
+ }
718
+ }
719
+ };
720
+ Tween.prototype._handleRelativeValue = function (start, end) {
721
+ if (typeof end !== 'string') {
722
+ return end;
723
+ }
724
+ if (end.charAt(0) === '+' || end.charAt(0) === '-') {
725
+ return start + parseFloat(end);
726
+ }
727
+ else {
728
+ return parseFloat(end);
729
+ }
730
+ };
731
+ Tween.prototype._swapEndStartRepeatValues = function (property) {
732
+ var tmp = this._valuesStartRepeat[property];
733
+ if (typeof this._valuesEnd[property] === 'string') {
734
+ // eslint-disable-next-line
735
+ // @ts-ignore FIXME?
736
+ this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]);
737
+ }
738
+ else {
739
+ this._valuesStartRepeat[property] = this._valuesEnd[property];
740
+ }
741
+ this._valuesEnd[property] = tmp;
742
+ };
743
+ return Tween;
744
+ }());
745
+
746
+ var VERSION = '18.6.0';
747
+
748
+ /**
749
+ * Tween.js - Licensed under the MIT license
750
+ * https://github.com/tweenjs/tween.js
751
+ * ----------------------------------------------
752
+ *
753
+ * See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors.
754
+ * Thank you all, you're awesome!
755
+ */
756
+ var __extends = (this && this.__extends) || (function () {
757
+ var extendStatics = function (d, b) {
758
+ extendStatics = Object.setPrototypeOf ||
759
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
760
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
761
+ return extendStatics(d, b);
762
+ };
763
+ return function (d, b) {
764
+ extendStatics(d, b);
765
+ function __() { this.constructor = d; }
766
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
767
+ };
768
+ })();
769
+ /**
770
+ * Controlling groups of tweens
771
+ *
772
+ * Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components.
773
+ * In these cases, you may want to create your own smaller groups of tween
774
+ */
775
+ var Main = /** @class */ (function (_super) {
776
+ __extends(Main, _super);
777
+ function Main() {
778
+ var _this = _super !== null && _super.apply(this, arguments) || this;
779
+ _this.version = VERSION;
780
+ _this.now = NOW$1;
781
+ _this.Group = Group;
782
+ _this.Easing = Easing;
783
+ _this.Interpolation = Interpolation;
784
+ _this.nextId = Sequence.nextId;
785
+ _this.Tween = Tween;
786
+ return _this;
787
+ }
788
+ return Main;
789
+ }(Group));
790
+ var TWEEN = new Main();
960
791
 
961
792
  export default TWEEN;