@eva/plugin-transition 1.1.1-fix.0 → 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.
- package/dist/EVA.plugin.transition.js +14 -787
- package/dist/EVA.plugin.transition.js.map +1 -0
- package/dist/plugin-transition.cjs.js +1 -0
- package/dist/plugin-transition.cjs.js.map +1 -0
- package/dist/plugin-transition.esm.js +1 -0
- package/dist/plugin-transition.esm.js.map +1 -0
- package/package.json +2 -2
- package/dist/miniprogram.js +0 -222
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@eva/eva.js')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@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.EVA));
|
|
5
|
-
}(this, (function (exports, eva_js) { 'use strict';
|
|
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
6
|
|
|
7
7
|
/*! *****************************************************************************
|
|
8
8
|
Copyright (c) Microsoft Corporation.
|
|
@@ -33,788 +33,14 @@
|
|
|
33
33
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
/**
|
|
37
|
-
* The Ease class provides a collection of easing functions for use with tween.js.
|
|
38
|
-
*/
|
|
39
|
-
var Easing = {
|
|
40
|
-
Linear: {
|
|
41
|
-
None: function (amount) {
|
|
42
|
-
return amount;
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
Quadratic: {
|
|
46
|
-
In: function (amount) {
|
|
47
|
-
return amount * amount;
|
|
48
|
-
},
|
|
49
|
-
Out: function (amount) {
|
|
50
|
-
return amount * (2 - amount);
|
|
51
|
-
},
|
|
52
|
-
InOut: function (amount) {
|
|
53
|
-
if ((amount *= 2) < 1) {
|
|
54
|
-
return 0.5 * amount * amount;
|
|
55
|
-
}
|
|
56
|
-
return -0.5 * (--amount * (amount - 2) - 1);
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
Cubic: {
|
|
60
|
-
In: function (amount) {
|
|
61
|
-
return amount * amount * amount;
|
|
62
|
-
},
|
|
63
|
-
Out: function (amount) {
|
|
64
|
-
return --amount * amount * amount + 1;
|
|
65
|
-
},
|
|
66
|
-
InOut: function (amount) {
|
|
67
|
-
if ((amount *= 2) < 1) {
|
|
68
|
-
return 0.5 * amount * amount * amount;
|
|
69
|
-
}
|
|
70
|
-
return 0.5 * ((amount -= 2) * amount * amount + 2);
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
Quartic: {
|
|
74
|
-
In: function (amount) {
|
|
75
|
-
return amount * amount * amount * amount;
|
|
76
|
-
},
|
|
77
|
-
Out: function (amount) {
|
|
78
|
-
return 1 - --amount * amount * amount * amount;
|
|
79
|
-
},
|
|
80
|
-
InOut: function (amount) {
|
|
81
|
-
if ((amount *= 2) < 1) {
|
|
82
|
-
return 0.5 * amount * amount * amount * amount;
|
|
83
|
-
}
|
|
84
|
-
return -0.5 * ((amount -= 2) * amount * amount * amount - 2);
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
Quintic: {
|
|
88
|
-
In: function (amount) {
|
|
89
|
-
return amount * amount * amount * amount * amount;
|
|
90
|
-
},
|
|
91
|
-
Out: function (amount) {
|
|
92
|
-
return --amount * amount * amount * amount * amount + 1;
|
|
93
|
-
},
|
|
94
|
-
InOut: function (amount) {
|
|
95
|
-
if ((amount *= 2) < 1) {
|
|
96
|
-
return 0.5 * amount * amount * amount * amount * amount;
|
|
97
|
-
}
|
|
98
|
-
return 0.5 * ((amount -= 2) * amount * amount * amount * amount + 2);
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
Sinusoidal: {
|
|
102
|
-
In: function (amount) {
|
|
103
|
-
return 1 - Math.cos((amount * Math.PI) / 2);
|
|
104
|
-
},
|
|
105
|
-
Out: function (amount) {
|
|
106
|
-
return Math.sin((amount * Math.PI) / 2);
|
|
107
|
-
},
|
|
108
|
-
InOut: function (amount) {
|
|
109
|
-
return 0.5 * (1 - Math.cos(Math.PI * amount));
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
Exponential: {
|
|
113
|
-
In: function (amount) {
|
|
114
|
-
return amount === 0 ? 0 : Math.pow(1024, amount - 1);
|
|
115
|
-
},
|
|
116
|
-
Out: function (amount) {
|
|
117
|
-
return amount === 1 ? 1 : 1 - Math.pow(2, -10 * amount);
|
|
118
|
-
},
|
|
119
|
-
InOut: function (amount) {
|
|
120
|
-
if (amount === 0) {
|
|
121
|
-
return 0;
|
|
122
|
-
}
|
|
123
|
-
if (amount === 1) {
|
|
124
|
-
return 1;
|
|
125
|
-
}
|
|
126
|
-
if ((amount *= 2) < 1) {
|
|
127
|
-
return 0.5 * Math.pow(1024, amount - 1);
|
|
128
|
-
}
|
|
129
|
-
return 0.5 * (-Math.pow(2, -10 * (amount - 1)) + 2);
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
Circular: {
|
|
133
|
-
In: function (amount) {
|
|
134
|
-
return 1 - Math.sqrt(1 - amount * amount);
|
|
135
|
-
},
|
|
136
|
-
Out: function (amount) {
|
|
137
|
-
return Math.sqrt(1 - --amount * amount);
|
|
138
|
-
},
|
|
139
|
-
InOut: function (amount) {
|
|
140
|
-
if ((amount *= 2) < 1) {
|
|
141
|
-
return -0.5 * (Math.sqrt(1 - amount * amount) - 1);
|
|
142
|
-
}
|
|
143
|
-
return 0.5 * (Math.sqrt(1 - (amount -= 2) * amount) + 1);
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
Elastic: {
|
|
147
|
-
In: function (amount) {
|
|
148
|
-
if (amount === 0) {
|
|
149
|
-
return 0;
|
|
150
|
-
}
|
|
151
|
-
if (amount === 1) {
|
|
152
|
-
return 1;
|
|
153
|
-
}
|
|
154
|
-
return -Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI);
|
|
155
|
-
},
|
|
156
|
-
Out: function (amount) {
|
|
157
|
-
if (amount === 0) {
|
|
158
|
-
return 0;
|
|
159
|
-
}
|
|
160
|
-
if (amount === 1) {
|
|
161
|
-
return 1;
|
|
162
|
-
}
|
|
163
|
-
return Math.pow(2, -10 * amount) * Math.sin((amount - 0.1) * 5 * Math.PI) + 1;
|
|
164
|
-
},
|
|
165
|
-
InOut: function (amount) {
|
|
166
|
-
if (amount === 0) {
|
|
167
|
-
return 0;
|
|
168
|
-
}
|
|
169
|
-
if (amount === 1) {
|
|
170
|
-
return 1;
|
|
171
|
-
}
|
|
172
|
-
amount *= 2;
|
|
173
|
-
if (amount < 1) {
|
|
174
|
-
return -0.5 * Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI);
|
|
175
|
-
}
|
|
176
|
-
return 0.5 * Math.pow(2, -10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI) + 1;
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
Back: {
|
|
180
|
-
In: function (amount) {
|
|
181
|
-
var s = 1.70158;
|
|
182
|
-
return amount * amount * ((s + 1) * amount - s);
|
|
183
|
-
},
|
|
184
|
-
Out: function (amount) {
|
|
185
|
-
var s = 1.70158;
|
|
186
|
-
return --amount * amount * ((s + 1) * amount + s) + 1;
|
|
187
|
-
},
|
|
188
|
-
InOut: function (amount) {
|
|
189
|
-
var s = 1.70158 * 1.525;
|
|
190
|
-
if ((amount *= 2) < 1) {
|
|
191
|
-
return 0.5 * (amount * amount * ((s + 1) * amount - s));
|
|
192
|
-
}
|
|
193
|
-
return 0.5 * ((amount -= 2) * amount * ((s + 1) * amount + s) + 2);
|
|
194
|
-
},
|
|
195
|
-
},
|
|
196
|
-
Bounce: {
|
|
197
|
-
In: function (amount) {
|
|
198
|
-
return 1 - Easing.Bounce.Out(1 - amount);
|
|
199
|
-
},
|
|
200
|
-
Out: function (amount) {
|
|
201
|
-
if (amount < 1 / 2.75) {
|
|
202
|
-
return 7.5625 * amount * amount;
|
|
203
|
-
}
|
|
204
|
-
else if (amount < 2 / 2.75) {
|
|
205
|
-
return 7.5625 * (amount -= 1.5 / 2.75) * amount + 0.75;
|
|
206
|
-
}
|
|
207
|
-
else if (amount < 2.5 / 2.75) {
|
|
208
|
-
return 7.5625 * (amount -= 2.25 / 2.75) * amount + 0.9375;
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
return 7.5625 * (amount -= 2.625 / 2.75) * amount + 0.984375;
|
|
212
|
-
}
|
|
213
|
-
},
|
|
214
|
-
InOut: function (amount) {
|
|
215
|
-
if (amount < 0.5) {
|
|
216
|
-
return Easing.Bounce.In(amount * 2) * 0.5;
|
|
217
|
-
}
|
|
218
|
-
return Easing.Bounce.Out(amount * 2 - 1) * 0.5 + 0.5;
|
|
219
|
-
},
|
|
220
|
-
},
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
var now;
|
|
224
|
-
// Include a performance.now polyfill.
|
|
225
|
-
// In node.js, use process.hrtime.
|
|
226
|
-
// eslint-disable-next-line
|
|
227
|
-
// @ts-ignore
|
|
228
|
-
if (typeof self === 'undefined' && typeof process !== 'undefined' && process.hrtime) {
|
|
229
|
-
now = function () {
|
|
230
|
-
// eslint-disable-next-line
|
|
231
|
-
// @ts-ignore
|
|
232
|
-
var time = process.hrtime();
|
|
233
|
-
// Convert [seconds, nanoseconds] to milliseconds.
|
|
234
|
-
return time[0] * 1000 + time[1] / 1000000;
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
// In a browser, use self.performance.now if it is available.
|
|
238
|
-
else if (typeof self !== 'undefined' && self.performance !== undefined && self.performance.now !== undefined) {
|
|
239
|
-
// This must be bound, because directly assigning this function
|
|
240
|
-
// leads to an invocation exception in Chrome.
|
|
241
|
-
now = self.performance.now.bind(self.performance);
|
|
242
|
-
}
|
|
243
|
-
// Use Date.now if it is available.
|
|
244
|
-
else if (Date.now !== undefined) {
|
|
245
|
-
now = Date.now;
|
|
246
|
-
}
|
|
247
|
-
// Otherwise, use 'new Date().getTime()'.
|
|
248
|
-
else {
|
|
249
|
-
now = function () {
|
|
250
|
-
return new Date().getTime();
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
var now$1 = now;
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Controlling groups of tweens
|
|
257
|
-
*
|
|
258
|
-
* Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components.
|
|
259
|
-
* In these cases, you may want to create your own smaller groups of tween
|
|
260
|
-
*/
|
|
261
|
-
var Group = /** @class */ (function () {
|
|
262
|
-
function Group() {
|
|
263
|
-
this._tweens = {};
|
|
264
|
-
this._tweensAddedDuringUpdate = {};
|
|
265
|
-
}
|
|
266
|
-
Group.prototype.getAll = function () {
|
|
267
|
-
var _this = this;
|
|
268
|
-
return Object.keys(this._tweens).map(function (tweenId) {
|
|
269
|
-
return _this._tweens[tweenId];
|
|
270
|
-
});
|
|
271
|
-
};
|
|
272
|
-
Group.prototype.removeAll = function () {
|
|
273
|
-
this._tweens = {};
|
|
274
|
-
};
|
|
275
|
-
Group.prototype.add = function (tween) {
|
|
276
|
-
this._tweens[tween.getId()] = tween;
|
|
277
|
-
this._tweensAddedDuringUpdate[tween.getId()] = tween;
|
|
278
|
-
};
|
|
279
|
-
Group.prototype.remove = function (tween) {
|
|
280
|
-
delete this._tweens[tween.getId()];
|
|
281
|
-
delete this._tweensAddedDuringUpdate[tween.getId()];
|
|
282
|
-
};
|
|
283
|
-
Group.prototype.update = function (time, preserve) {
|
|
284
|
-
if (time === void 0) { time = now$1(); }
|
|
285
|
-
if (preserve === void 0) { preserve = false; }
|
|
286
|
-
var tweenIds = Object.keys(this._tweens);
|
|
287
|
-
if (tweenIds.length === 0) {
|
|
288
|
-
return false;
|
|
289
|
-
}
|
|
290
|
-
// Tweens are updated in "batches". If you add a new tween during an
|
|
291
|
-
// update, then the new tween will be updated in the next batch.
|
|
292
|
-
// If you remove a tween during an update, it may or may not be updated.
|
|
293
|
-
// However, if the removed tween was added during the current batch,
|
|
294
|
-
// then it will not be updated.
|
|
295
|
-
while (tweenIds.length > 0) {
|
|
296
|
-
this._tweensAddedDuringUpdate = {};
|
|
297
|
-
for (var i = 0; i < tweenIds.length; i++) {
|
|
298
|
-
var tween = this._tweens[tweenIds[i]];
|
|
299
|
-
var autoStart = !preserve;
|
|
300
|
-
if (tween && tween.update(time, autoStart) === false && !preserve) {
|
|
301
|
-
delete this._tweens[tweenIds[i]];
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
tweenIds = Object.keys(this._tweensAddedDuringUpdate);
|
|
305
|
-
}
|
|
306
|
-
return true;
|
|
307
|
-
};
|
|
308
|
-
return Group;
|
|
309
|
-
}());
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
*
|
|
313
|
-
*/
|
|
314
|
-
var Interpolation = {
|
|
315
|
-
Linear: function (v, k) {
|
|
316
|
-
var m = v.length - 1;
|
|
317
|
-
var f = m * k;
|
|
318
|
-
var i = Math.floor(f);
|
|
319
|
-
var fn = Interpolation.Utils.Linear;
|
|
320
|
-
if (k < 0) {
|
|
321
|
-
return fn(v[0], v[1], f);
|
|
322
|
-
}
|
|
323
|
-
if (k > 1) {
|
|
324
|
-
return fn(v[m], v[m - 1], m - f);
|
|
325
|
-
}
|
|
326
|
-
return fn(v[i], v[i + 1 > m ? m : i + 1], f - i);
|
|
327
|
-
},
|
|
328
|
-
Bezier: function (v, k) {
|
|
329
|
-
var b = 0;
|
|
330
|
-
var n = v.length - 1;
|
|
331
|
-
var pw = Math.pow;
|
|
332
|
-
var bn = Interpolation.Utils.Bernstein;
|
|
333
|
-
for (var i = 0; i <= n; i++) {
|
|
334
|
-
b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i);
|
|
335
|
-
}
|
|
336
|
-
return b;
|
|
337
|
-
},
|
|
338
|
-
CatmullRom: function (v, k) {
|
|
339
|
-
var m = v.length - 1;
|
|
340
|
-
var f = m * k;
|
|
341
|
-
var i = Math.floor(f);
|
|
342
|
-
var fn = Interpolation.Utils.CatmullRom;
|
|
343
|
-
if (v[0] === v[m]) {
|
|
344
|
-
if (k < 0) {
|
|
345
|
-
i = Math.floor((f = m * (1 + k)));
|
|
346
|
-
}
|
|
347
|
-
return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i);
|
|
348
|
-
}
|
|
349
|
-
else {
|
|
350
|
-
if (k < 0) {
|
|
351
|
-
return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]);
|
|
352
|
-
}
|
|
353
|
-
if (k > 1) {
|
|
354
|
-
return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]);
|
|
355
|
-
}
|
|
356
|
-
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);
|
|
357
|
-
}
|
|
358
|
-
},
|
|
359
|
-
Utils: {
|
|
360
|
-
Linear: function (p0, p1, t) {
|
|
361
|
-
return (p1 - p0) * t + p0;
|
|
362
|
-
},
|
|
363
|
-
Bernstein: function (n, i) {
|
|
364
|
-
var fc = Interpolation.Utils.Factorial;
|
|
365
|
-
return fc(n) / fc(i) / fc(n - i);
|
|
366
|
-
},
|
|
367
|
-
Factorial: (function () {
|
|
368
|
-
var a = [1];
|
|
369
|
-
return function (n) {
|
|
370
|
-
var s = 1;
|
|
371
|
-
if (a[n]) {
|
|
372
|
-
return a[n];
|
|
373
|
-
}
|
|
374
|
-
for (var i = n; i > 1; i--) {
|
|
375
|
-
s *= i;
|
|
376
|
-
}
|
|
377
|
-
a[n] = s;
|
|
378
|
-
return s;
|
|
379
|
-
};
|
|
380
|
-
})(),
|
|
381
|
-
CatmullRom: function (p0, p1, p2, p3, t) {
|
|
382
|
-
var v0 = (p2 - p0) * 0.5;
|
|
383
|
-
var v1 = (p3 - p1) * 0.5;
|
|
384
|
-
var t2 = t * t;
|
|
385
|
-
var t3 = t * t2;
|
|
386
|
-
return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;
|
|
387
|
-
},
|
|
388
|
-
},
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
/**
|
|
392
|
-
* Utils
|
|
393
|
-
*/
|
|
394
|
-
var Sequence = /** @class */ (function () {
|
|
395
|
-
function Sequence() {
|
|
396
|
-
}
|
|
397
|
-
Sequence.nextId = function () {
|
|
398
|
-
return Sequence._nextId++;
|
|
399
|
-
};
|
|
400
|
-
Sequence._nextId = 0;
|
|
401
|
-
return Sequence;
|
|
402
|
-
}());
|
|
403
|
-
|
|
404
|
-
var mainGroup = new Group();
|
|
405
|
-
|
|
406
|
-
/**
|
|
407
|
-
* Tween.js - Licensed under the MIT license
|
|
408
|
-
* https://github.com/tweenjs/tween.js
|
|
409
|
-
* ----------------------------------------------
|
|
410
|
-
*
|
|
411
|
-
* See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors.
|
|
412
|
-
* Thank you all, you're awesome!
|
|
413
|
-
*/
|
|
414
|
-
var Tween = /** @class */ (function () {
|
|
415
|
-
function Tween(_object, _group) {
|
|
416
|
-
if (_group === void 0) { _group = mainGroup; }
|
|
417
|
-
this._object = _object;
|
|
418
|
-
this._group = _group;
|
|
419
|
-
this._isPaused = false;
|
|
420
|
-
this._pauseStart = 0;
|
|
421
|
-
this._valuesStart = {};
|
|
422
|
-
this._valuesEnd = {};
|
|
423
|
-
this._valuesStartRepeat = {};
|
|
424
|
-
this._duration = 1000;
|
|
425
|
-
this._initialRepeat = 0;
|
|
426
|
-
this._repeat = 0;
|
|
427
|
-
this._yoyo = false;
|
|
428
|
-
this._isPlaying = false;
|
|
429
|
-
this._reversed = false;
|
|
430
|
-
this._delayTime = 0;
|
|
431
|
-
this._startTime = 0;
|
|
432
|
-
this._easingFunction = Easing.Linear.None;
|
|
433
|
-
this._interpolationFunction = Interpolation.Linear;
|
|
434
|
-
this._chainedTweens = [];
|
|
435
|
-
this._onStartCallbackFired = false;
|
|
436
|
-
this._id = Sequence.nextId();
|
|
437
|
-
this._isChainStopped = false;
|
|
438
|
-
this._goToEnd = false;
|
|
439
|
-
}
|
|
440
|
-
Tween.prototype.getId = function () {
|
|
441
|
-
return this._id;
|
|
442
|
-
};
|
|
443
|
-
Tween.prototype.isPlaying = function () {
|
|
444
|
-
return this._isPlaying;
|
|
445
|
-
};
|
|
446
|
-
Tween.prototype.isPaused = function () {
|
|
447
|
-
return this._isPaused;
|
|
448
|
-
};
|
|
449
|
-
Tween.prototype.to = function (properties, duration) {
|
|
450
|
-
// TODO? restore this, then update the 07_dynamic_to example to set fox
|
|
451
|
-
// tween's to on each update. That way the behavior is opt-in (there's
|
|
452
|
-
// currently no opt-out).
|
|
453
|
-
// for (const prop in properties) this._valuesEnd[prop] = properties[prop]
|
|
454
|
-
this._valuesEnd = Object.create(properties);
|
|
455
|
-
if (duration !== undefined) {
|
|
456
|
-
this._duration = duration;
|
|
457
|
-
}
|
|
458
|
-
return this;
|
|
459
|
-
};
|
|
460
|
-
Tween.prototype.duration = function (d) {
|
|
461
|
-
this._duration = d;
|
|
462
|
-
return this;
|
|
463
|
-
};
|
|
464
|
-
Tween.prototype.start = function (time) {
|
|
465
|
-
if (this._isPlaying) {
|
|
466
|
-
return this;
|
|
467
|
-
}
|
|
468
|
-
// eslint-disable-next-line
|
|
469
|
-
this._group && this._group.add(this);
|
|
470
|
-
this._repeat = this._initialRepeat;
|
|
471
|
-
if (this._reversed) {
|
|
472
|
-
// If we were reversed (f.e. using the yoyo feature) then we need to
|
|
473
|
-
// flip the tween direction back to forward.
|
|
474
|
-
this._reversed = false;
|
|
475
|
-
for (var property in this._valuesStartRepeat) {
|
|
476
|
-
this._swapEndStartRepeatValues(property);
|
|
477
|
-
this._valuesStart[property] = this._valuesStartRepeat[property];
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
this._isPlaying = true;
|
|
481
|
-
this._isPaused = false;
|
|
482
|
-
this._onStartCallbackFired = false;
|
|
483
|
-
this._isChainStopped = false;
|
|
484
|
-
this._startTime = time !== undefined ? (typeof time === 'string' ? now$1() + parseFloat(time) : time) : now$1();
|
|
485
|
-
this._startTime += this._delayTime;
|
|
486
|
-
this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat);
|
|
487
|
-
return this;
|
|
488
|
-
};
|
|
489
|
-
Tween.prototype._setupProperties = function (_object, _valuesStart, _valuesEnd, _valuesStartRepeat) {
|
|
490
|
-
for (var property in _valuesEnd) {
|
|
491
|
-
var startValue = _object[property];
|
|
492
|
-
var startValueIsArray = Array.isArray(startValue);
|
|
493
|
-
var propType = startValueIsArray ? 'array' : typeof startValue;
|
|
494
|
-
var isInterpolationList = !startValueIsArray && Array.isArray(_valuesEnd[property]);
|
|
495
|
-
// If `to()` specifies a property that doesn't exist in the source object,
|
|
496
|
-
// we should not set that property in the object
|
|
497
|
-
if (propType === 'undefined' || propType === 'function') {
|
|
498
|
-
continue;
|
|
499
|
-
}
|
|
500
|
-
// Check if an Array was provided as property value
|
|
501
|
-
if (isInterpolationList) {
|
|
502
|
-
var endValues = _valuesEnd[property];
|
|
503
|
-
if (endValues.length === 0) {
|
|
504
|
-
continue;
|
|
505
|
-
}
|
|
506
|
-
// handle an array of relative values
|
|
507
|
-
endValues = endValues.map(this._handleRelativeValue.bind(this, startValue));
|
|
508
|
-
// Create a local copy of the Array with the start value at the front
|
|
509
|
-
_valuesEnd[property] = [startValue].concat(endValues);
|
|
510
|
-
}
|
|
511
|
-
// handle the deepness of the values
|
|
512
|
-
if ((propType === 'object' || startValueIsArray) && startValue && !isInterpolationList) {
|
|
513
|
-
_valuesStart[property] = startValueIsArray ? [] : {};
|
|
514
|
-
// eslint-disable-next-line
|
|
515
|
-
for (var prop in startValue) {
|
|
516
|
-
// eslint-disable-next-line
|
|
517
|
-
// @ts-ignore FIXME?
|
|
518
|
-
_valuesStart[property][prop] = startValue[prop];
|
|
519
|
-
}
|
|
520
|
-
_valuesStartRepeat[property] = startValueIsArray ? [] : {}; // TODO? repeat nested values? And yoyo? And array values?
|
|
521
|
-
// eslint-disable-next-line
|
|
522
|
-
// @ts-ignore FIXME?
|
|
523
|
-
this._setupProperties(startValue, _valuesStart[property], _valuesEnd[property], _valuesStartRepeat[property]);
|
|
524
|
-
}
|
|
525
|
-
else {
|
|
526
|
-
// Save the starting value, but only once.
|
|
527
|
-
if (typeof _valuesStart[property] === 'undefined') {
|
|
528
|
-
_valuesStart[property] = startValue;
|
|
529
|
-
}
|
|
530
|
-
if (!startValueIsArray) {
|
|
531
|
-
// eslint-disable-next-line
|
|
532
|
-
// @ts-ignore FIXME?
|
|
533
|
-
_valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings
|
|
534
|
-
}
|
|
535
|
-
if (isInterpolationList) {
|
|
536
|
-
// eslint-disable-next-line
|
|
537
|
-
// @ts-ignore FIXME?
|
|
538
|
-
_valuesStartRepeat[property] = _valuesEnd[property].slice().reverse();
|
|
539
|
-
}
|
|
540
|
-
else {
|
|
541
|
-
_valuesStartRepeat[property] = _valuesStart[property] || 0;
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
};
|
|
546
|
-
Tween.prototype.stop = function () {
|
|
547
|
-
if (!this._isChainStopped) {
|
|
548
|
-
this._isChainStopped = true;
|
|
549
|
-
this.stopChainedTweens();
|
|
550
|
-
}
|
|
551
|
-
if (!this._isPlaying) {
|
|
552
|
-
return this;
|
|
553
|
-
}
|
|
554
|
-
// eslint-disable-next-line
|
|
555
|
-
this._group && this._group.remove(this);
|
|
556
|
-
this._isPlaying = false;
|
|
557
|
-
this._isPaused = false;
|
|
558
|
-
if (this._onStopCallback) {
|
|
559
|
-
this._onStopCallback(this._object);
|
|
560
|
-
}
|
|
561
|
-
return this;
|
|
562
|
-
};
|
|
563
|
-
Tween.prototype.end = function () {
|
|
564
|
-
this._goToEnd = true;
|
|
565
|
-
this.update(Infinity);
|
|
566
|
-
return this;
|
|
567
|
-
};
|
|
568
|
-
Tween.prototype.pause = function (time) {
|
|
569
|
-
if (time === void 0) { time = now$1(); }
|
|
570
|
-
if (this._isPaused || !this._isPlaying) {
|
|
571
|
-
return this;
|
|
572
|
-
}
|
|
573
|
-
this._isPaused = true;
|
|
574
|
-
this._pauseStart = time;
|
|
575
|
-
// eslint-disable-next-line
|
|
576
|
-
this._group && this._group.remove(this);
|
|
577
|
-
return this;
|
|
578
|
-
};
|
|
579
|
-
Tween.prototype.resume = function (time) {
|
|
580
|
-
if (time === void 0) { time = now$1(); }
|
|
581
|
-
if (!this._isPaused || !this._isPlaying) {
|
|
582
|
-
return this;
|
|
583
|
-
}
|
|
584
|
-
this._isPaused = false;
|
|
585
|
-
this._startTime += time - this._pauseStart;
|
|
586
|
-
this._pauseStart = 0;
|
|
587
|
-
// eslint-disable-next-line
|
|
588
|
-
this._group && this._group.add(this);
|
|
589
|
-
return this;
|
|
590
|
-
};
|
|
591
|
-
Tween.prototype.stopChainedTweens = function () {
|
|
592
|
-
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
|
|
593
|
-
this._chainedTweens[i].stop();
|
|
594
|
-
}
|
|
595
|
-
return this;
|
|
596
|
-
};
|
|
597
|
-
Tween.prototype.group = function (group) {
|
|
598
|
-
this._group = group;
|
|
599
|
-
return this;
|
|
600
|
-
};
|
|
601
|
-
Tween.prototype.delay = function (amount) {
|
|
602
|
-
this._delayTime = amount;
|
|
603
|
-
return this;
|
|
604
|
-
};
|
|
605
|
-
Tween.prototype.repeat = function (times) {
|
|
606
|
-
this._initialRepeat = times;
|
|
607
|
-
this._repeat = times;
|
|
608
|
-
return this;
|
|
609
|
-
};
|
|
610
|
-
Tween.prototype.repeatDelay = function (amount) {
|
|
611
|
-
this._repeatDelayTime = amount;
|
|
612
|
-
return this;
|
|
613
|
-
};
|
|
614
|
-
Tween.prototype.yoyo = function (yoyo) {
|
|
615
|
-
this._yoyo = yoyo;
|
|
616
|
-
return this;
|
|
617
|
-
};
|
|
618
|
-
Tween.prototype.easing = function (easingFunction) {
|
|
619
|
-
this._easingFunction = easingFunction;
|
|
620
|
-
return this;
|
|
621
|
-
};
|
|
622
|
-
Tween.prototype.interpolation = function (interpolationFunction) {
|
|
623
|
-
this._interpolationFunction = interpolationFunction;
|
|
624
|
-
return this;
|
|
625
|
-
};
|
|
626
|
-
Tween.prototype.chain = function () {
|
|
627
|
-
var tweens = [];
|
|
628
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
629
|
-
tweens[_i] = arguments[_i];
|
|
630
|
-
}
|
|
631
|
-
this._chainedTweens = tweens;
|
|
632
|
-
return this;
|
|
633
|
-
};
|
|
634
|
-
Tween.prototype.onStart = function (callback) {
|
|
635
|
-
this._onStartCallback = callback;
|
|
636
|
-
return this;
|
|
637
|
-
};
|
|
638
|
-
Tween.prototype.onUpdate = function (callback) {
|
|
639
|
-
this._onUpdateCallback = callback;
|
|
640
|
-
return this;
|
|
641
|
-
};
|
|
642
|
-
Tween.prototype.onRepeat = function (callback) {
|
|
643
|
-
this._onRepeatCallback = callback;
|
|
644
|
-
return this;
|
|
645
|
-
};
|
|
646
|
-
Tween.prototype.onComplete = function (callback) {
|
|
647
|
-
this._onCompleteCallback = callback;
|
|
648
|
-
return this;
|
|
649
|
-
};
|
|
650
|
-
Tween.prototype.onStop = function (callback) {
|
|
651
|
-
this._onStopCallback = callback;
|
|
652
|
-
return this;
|
|
653
|
-
};
|
|
654
|
-
/**
|
|
655
|
-
* @returns true if the tween is still playing after the update, false
|
|
656
|
-
* otherwise (calling update on a paused tween still returns true because
|
|
657
|
-
* it is still playing, just paused).
|
|
658
|
-
*/
|
|
659
|
-
Tween.prototype.update = function (time, autoStart) {
|
|
660
|
-
if (time === void 0) { time = now$1(); }
|
|
661
|
-
if (autoStart === void 0) { autoStart = true; }
|
|
662
|
-
if (this._isPaused)
|
|
663
|
-
return true;
|
|
664
|
-
var property;
|
|
665
|
-
var elapsed;
|
|
666
|
-
var endTime = this._startTime + this._duration;
|
|
667
|
-
if (!this._goToEnd && !this._isPlaying) {
|
|
668
|
-
if (time > endTime)
|
|
669
|
-
return false;
|
|
670
|
-
if (autoStart)
|
|
671
|
-
this.start(time);
|
|
672
|
-
}
|
|
673
|
-
this._goToEnd = false;
|
|
674
|
-
if (time < this._startTime) {
|
|
675
|
-
return true;
|
|
676
|
-
}
|
|
677
|
-
if (this._onStartCallbackFired === false) {
|
|
678
|
-
if (this._onStartCallback) {
|
|
679
|
-
this._onStartCallback(this._object);
|
|
680
|
-
}
|
|
681
|
-
this._onStartCallbackFired = true;
|
|
682
|
-
}
|
|
683
|
-
elapsed = (time - this._startTime) / this._duration;
|
|
684
|
-
elapsed = this._duration === 0 || elapsed > 1 ? 1 : elapsed;
|
|
685
|
-
var value = this._easingFunction(elapsed);
|
|
686
|
-
// properties transformations
|
|
687
|
-
this._updateProperties(this._object, this._valuesStart, this._valuesEnd, value);
|
|
688
|
-
if (this._onUpdateCallback) {
|
|
689
|
-
this._onUpdateCallback(this._object, elapsed);
|
|
690
|
-
}
|
|
691
|
-
if (elapsed === 1) {
|
|
692
|
-
if (this._repeat > 0) {
|
|
693
|
-
if (isFinite(this._repeat)) {
|
|
694
|
-
this._repeat--;
|
|
695
|
-
}
|
|
696
|
-
// Reassign starting values, restart by making startTime = now
|
|
697
|
-
for (property in this._valuesStartRepeat) {
|
|
698
|
-
if (!this._yoyo && typeof this._valuesEnd[property] === 'string') {
|
|
699
|
-
this._valuesStartRepeat[property] =
|
|
700
|
-
// eslint-disable-next-line
|
|
701
|
-
// @ts-ignore FIXME?
|
|
702
|
-
this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]);
|
|
703
|
-
}
|
|
704
|
-
if (this._yoyo) {
|
|
705
|
-
this._swapEndStartRepeatValues(property);
|
|
706
|
-
}
|
|
707
|
-
this._valuesStart[property] = this._valuesStartRepeat[property];
|
|
708
|
-
}
|
|
709
|
-
if (this._yoyo) {
|
|
710
|
-
this._reversed = !this._reversed;
|
|
711
|
-
}
|
|
712
|
-
if (this._repeatDelayTime !== undefined) {
|
|
713
|
-
this._startTime = time + this._repeatDelayTime;
|
|
714
|
-
}
|
|
715
|
-
else {
|
|
716
|
-
this._startTime = time + this._delayTime;
|
|
717
|
-
}
|
|
718
|
-
if (this._onRepeatCallback) {
|
|
719
|
-
this._onRepeatCallback(this._object);
|
|
720
|
-
}
|
|
721
|
-
return true;
|
|
722
|
-
}
|
|
723
|
-
else {
|
|
724
|
-
if (this._onCompleteCallback) {
|
|
725
|
-
this._onCompleteCallback(this._object);
|
|
726
|
-
}
|
|
727
|
-
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
|
|
728
|
-
// Make the chained tweens start exactly at the time they should,
|
|
729
|
-
// even if the `update()` method was called way past the duration of the tween
|
|
730
|
-
this._chainedTweens[i].start(this._startTime + this._duration);
|
|
731
|
-
}
|
|
732
|
-
this._isPlaying = false;
|
|
733
|
-
return false;
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
return true;
|
|
737
|
-
};
|
|
738
|
-
Tween.prototype._updateProperties = function (_object, _valuesStart, _valuesEnd, value) {
|
|
739
|
-
for (var property in _valuesEnd) {
|
|
740
|
-
// Don't update properties that do not exist in the source object
|
|
741
|
-
if (_valuesStart[property] === undefined) {
|
|
742
|
-
continue;
|
|
743
|
-
}
|
|
744
|
-
var start = _valuesStart[property] || 0;
|
|
745
|
-
var end = _valuesEnd[property];
|
|
746
|
-
var startIsArray = Array.isArray(_object[property]);
|
|
747
|
-
var endIsArray = Array.isArray(end);
|
|
748
|
-
var isInterpolationList = !startIsArray && endIsArray;
|
|
749
|
-
if (isInterpolationList) {
|
|
750
|
-
_object[property] = this._interpolationFunction(end, value);
|
|
751
|
-
}
|
|
752
|
-
else if (typeof end === 'object' && end) {
|
|
753
|
-
// eslint-disable-next-line
|
|
754
|
-
// @ts-ignore FIXME?
|
|
755
|
-
this._updateProperties(_object[property], start, end, value);
|
|
756
|
-
}
|
|
757
|
-
else {
|
|
758
|
-
// Parses relative end values with start as base (e.g.: +10, -3)
|
|
759
|
-
end = this._handleRelativeValue(start, end);
|
|
760
|
-
// Protect against non numeric properties.
|
|
761
|
-
if (typeof end === 'number') {
|
|
762
|
-
// eslint-disable-next-line
|
|
763
|
-
// @ts-ignore FIXME?
|
|
764
|
-
_object[property] = start + (end - start) * value;
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
};
|
|
769
|
-
Tween.prototype._handleRelativeValue = function (start, end) {
|
|
770
|
-
if (typeof end !== 'string') {
|
|
771
|
-
return end;
|
|
772
|
-
}
|
|
773
|
-
if (end.charAt(0) === '+' || end.charAt(0) === '-') {
|
|
774
|
-
return start + parseFloat(end);
|
|
775
|
-
}
|
|
776
|
-
else {
|
|
777
|
-
return parseFloat(end);
|
|
778
|
-
}
|
|
779
|
-
};
|
|
780
|
-
Tween.prototype._swapEndStartRepeatValues = function (property) {
|
|
781
|
-
var tmp = this._valuesStartRepeat[property];
|
|
782
|
-
var endValue = this._valuesEnd[property];
|
|
783
|
-
if (typeof endValue === 'string') {
|
|
784
|
-
this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(endValue);
|
|
785
|
-
}
|
|
786
|
-
else {
|
|
787
|
-
this._valuesStartRepeat[property] = this._valuesEnd[property];
|
|
788
|
-
}
|
|
789
|
-
this._valuesEnd[property] = tmp;
|
|
790
|
-
};
|
|
791
|
-
return Tween;
|
|
792
|
-
}());
|
|
793
|
-
/**
|
|
794
|
-
* Controlling groups of tweens
|
|
795
|
-
*
|
|
796
|
-
* Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components.
|
|
797
|
-
* In these cases, you may want to create your own smaller groups of tweens.
|
|
798
|
-
*/
|
|
799
|
-
var TWEEN = mainGroup;
|
|
800
|
-
// This is the best way to export things in a way that's compatible with both ES
|
|
801
|
-
// Modules and CommonJS, without build hacks, and so as not to break the
|
|
802
|
-
// existing API.
|
|
803
|
-
// https://github.com/rollup/rollup/issues/1961#issuecomment-423037881
|
|
804
|
-
TWEEN.getAll.bind(TWEEN);
|
|
805
|
-
TWEEN.removeAll.bind(TWEEN);
|
|
806
|
-
TWEEN.add.bind(TWEEN);
|
|
807
|
-
TWEEN.remove.bind(TWEEN);
|
|
808
|
-
TWEEN.update.bind(TWEEN);
|
|
809
|
-
|
|
810
36
|
var easingMap = {
|
|
811
|
-
linear: Easing.Linear.None,
|
|
812
|
-
'ease-in': Easing.Quadratic.In,
|
|
813
|
-
'ease-out': Easing.Quadratic.Out,
|
|
814
|
-
'ease-in-out': Easing.Quadratic.InOut,
|
|
815
|
-
'bounce-in': Easing.Bounce.In,
|
|
816
|
-
'bounce-out': Easing.Bounce.Out,
|
|
817
|
-
'bounce-in-out': Easing.Bounce.InOut,
|
|
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,
|
|
818
44
|
none: function (p) { return ~~p; },
|
|
819
45
|
};
|
|
820
46
|
var Animation = (function () {
|
|
@@ -882,7 +108,7 @@
|
|
|
882
108
|
for (var j = 0; j < timeline.values.length - 1; j++) {
|
|
883
109
|
var frame = timeline.values[j];
|
|
884
110
|
var nextFrame = timeline.values[j + 1];
|
|
885
|
-
var tween = new Tween({ value: frame.value }, _this.tweenGroup)
|
|
111
|
+
var tween = new tween_js.Tween({ value: frame.value }, _this.tweenGroup)
|
|
886
112
|
.to({ value: nextFrame.value })
|
|
887
113
|
.duration(nextFrame.time - frame.time)
|
|
888
114
|
.easing(easingMap[frame.tween])
|
|
@@ -950,7 +176,7 @@
|
|
|
950
176
|
Transition.prototype.init = function (_a) {
|
|
951
177
|
var group = (_a === void 0 ? { group: {} } : _a).group;
|
|
952
178
|
this.group = group;
|
|
953
|
-
this.tweenGroup = new Group();
|
|
179
|
+
this.tweenGroup = new tween_js.Group();
|
|
954
180
|
};
|
|
955
181
|
Transition.prototype.awake = function () {
|
|
956
182
|
for (var name_1 in this.group) {
|
|
@@ -1030,3 +256,4 @@
|
|
|
1030
256
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1031
257
|
|
|
1032
258
|
})));
|
|
259
|
+
//# sourceMappingURL=EVA.plugin.transition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EVA.plugin.transition.js","sources":["../../../node_modules/tslib/tslib.es6.js","../lib/animation.ts","../lib/component.ts","../lib/system.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __createBinding(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n","import { Tween, Easing } from '@tweenjs/tween.js';\nimport type { Group } from '@tweenjs/tween.js';\n\ninterface CacheItem {\n property: Record<string, any>;\n key: string;\n}\n\ntype Cache = Record<string, CacheItem>;\n\nconst easingMap = {\n linear: Easing.Linear.None,\n 'ease-in': Easing.Quadratic.In,\n 'ease-out': Easing.Quadratic.Out,\n 'ease-in-out': Easing.Quadratic.InOut,\n 'bounce-in': Easing.Bounce.In,\n 'bounce-out': Easing.Bounce.Out,\n 'bounce-in-out': Easing.Bounce.InOut,\n none: p => ~~p,\n};\n\nexport default class Animation {\n private tweens = [];\n private timelines = [];\n private finishCount = 0;\n private callbacks = new Map();\n readonly tweenGroup: Group;\n\n stoped: boolean;\n objectCache: Record<string, Cache> = {};\n currIteration: number = 0;\n iteration: number;\n checkFinishFunc: Function;\n\n constructor(timelines, tweenGroup: Group) {\n this.timelines = timelines;\n this.tweenGroup = tweenGroup;\n }\n\n on(eventName, callback) {\n if (!this.callbacks[eventName]) {\n this.callbacks.set(eventName, []);\n }\n this.callbacks.get(eventName).push(callback);\n }\n\n emit(eventName) {\n const callbacks = this.callbacks.get(eventName);\n if (!callbacks || !callbacks.length) return;\n callbacks.forEach(fn => fn());\n }\n\n checkFinish() {\n if (++this.finishCount == this.tweens.length) {\n if (++this.currIteration == this.iteration) {\n this.emit('finish');\n } else {\n if (this.stoped) return;\n this.start();\n }\n }\n }\n\n getObjectCache(component, name): CacheItem {\n const key = `${component.gameObject.id}${component.name}`;\n if (!this.objectCache[key]) {\n this.objectCache[key] = {};\n }\n if (this.objectCache[key][name]) {\n return this.objectCache[key][name];\n }\n const keys = name.split('.');\n const keyIndex = keys.length - 1;\n let property = component;\n for (let i = 0; i < keyIndex; i++) {\n property = property[keys[i]];\n }\n this.objectCache[key][name] = { property, key: keys[keyIndex] };\n return this.objectCache[key][name];\n }\n\n doAnim({ component, name, value }) {\n const { property, key } = this.getObjectCache(component, name);\n property[key] = value;\n }\n\n init() {\n this.checkFinishFunc = this.checkFinish.bind(this);\n\n let lastTween;\n this.timelines.forEach((timeline, i) => {\n for (let j = 0; j < timeline.values.length - 1; j++) {\n const frame = timeline.values[j];\n const nextFrame = timeline.values[j + 1];\n\n const tween = new Tween({ value: frame.value }, this.tweenGroup)\n .to({ value: nextFrame.value })\n .duration(nextFrame.time - frame.time)\n .easing(easingMap[frame.tween])\n .onUpdate(props => {\n this.doAnim({\n component: timeline.component,\n name: timeline.name,\n value: props.value,\n });\n });\n\n if (j === 0) {\n this.tweens[i] = tween;\n } else {\n lastTween.chain(tween);\n }\n\n lastTween = tween;\n }\n lastTween && lastTween.onComplete(() => this.checkFinishFunc());\n });\n }\n\n play(iteration = 1) {\n this.stoped = false;\n this.start();\n this.currIteration = 0;\n this.iteration = iteration;\n }\n\n start() {\n this.finishCount = 0;\n this.tweens.length = 0;\n this.init();\n this.tweens.forEach((tween: Tween<any>) => tween.start());\n }\n\n pause() {\n this.tweens.forEach((tween: Tween<any>) => tween.pause());\n }\n\n resume() {\n this.tweens.forEach((tween: Tween<any>) => tween.resume());\n }\n\n stop() {\n this.stoped = true;\n this.tweens.forEach((tween: Tween<any>) => tween.stop());\n }\n\n destroy() {\n this.stop();\n this.tweens = null;\n this.timelines = null;\n this.objectCache = null;\n this.callbacks.clear();\n this.callbacks = null;\n }\n}\n","import Animation from './animation';\nimport { Component } from '@eva/eva.js';\nimport { Group } from '@tweenjs/tween.js';\n\ninterface AnimationStruct {\n name: string;\n component: Component;\n values: {\n time: number;\n value: number;\n tween?: string;\n }[];\n}\ninterface TransitionParams {\n group: Record<string, AnimationStruct[]>;\n}\nexport default class Transition extends Component<TransitionParams> {\n static componentName: string = 'Transition';\n\n private animations: Record<string, Animation> = {};\n\n tweenGroup: Group;\n group: Record<string, AnimationStruct[]> = {};\n\n init({ group } = { group: {} }) {\n this.group = group;\n this.tweenGroup = new Group();\n }\n\n awake() {\n for (const name in this.group) {\n this.newAnimation(name);\n }\n }\n\n play(name: string, iteration: number) {\n if (!name) {\n name = Object.keys(this.group)[0];\n }\n if (name && !this.animations[name] && this.group[name]) {\n this.newAnimation(name);\n }\n if (name && this.animations[name]) {\n this.animations[name].play(iteration);\n }\n }\n\n stop(name) {\n if (!name) {\n for (const key in this.animations) {\n this.animations[key].stop();\n }\n } else {\n this.animations[name].stop();\n }\n }\n\n onPause() {\n for (const key in this.animations) {\n this.animations[key].pause();\n }\n }\n\n onResume() {\n for (const key in this.animations) {\n this.animations[key].resume();\n }\n }\n\n onDestroy() {\n for (const key in this.animations) {\n this.animations[key].destroy();\n }\n this.tweenGroup.removeAll();\n this.tweenGroup = null;\n this.group = null;\n this.animations = null;\n this.removeAllListeners();\n }\n\n update() {\n this.tweenGroup.update();\n }\n\n newAnimation(name) {\n const animation = new Animation(this.group[name], this.tweenGroup);\n animation.on('finish', () => this.emit('finish', name));\n this.animations[name] = animation;\n }\n}\n","import { System } from '@eva/eva.js';\n\nexport default class TransitionSystem extends System {\n static systemName = 'transition';\n readonly name = 'transition';\n}\n"],"names":["Easing","Tween","Group","Animation","Component","System"],"mappings":";;;;;;IAAA;IACA;AACA;IACA;IACA;AACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;AACA;IACA,IAAI,aAAa,GAAG,SAAS,CAAC,EAAE,CAAC,EAAE;IACnC,IAAI,aAAa,GAAG,MAAM,CAAC,cAAc;IACzC,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,YAAY,KAAK,IAAI,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,CAAC;IACpF,QAAQ,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACnF,IAAI,OAAO,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/B,CAAC,CAAC;AACF;IACO,SAAS,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE;IAChC,IAAI,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACxB,IAAI,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,EAAE;IAC3C,IAAI,CAAC,CAAC,SAAS,GAAG,CAAC,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IACzF;;ICjBA,IAAM,SAAS,GAAG;QAChB,MAAM,EAAEA,eAAM,CAAC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Aa,IAAI;YAAjB,iBAIC;YAHC,IAAM,SAAS,GAAG,IAAIC,WAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;YACnE,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAM,OAAA,KAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAA,CAAC,CAAC;YACxD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;SACnC;QAvEM,wBAAa,GAAW,YAAY,CAAC;QAwE9C,iBAAC;KAAA,CAzEuCC,gBAAS,GAyEhD;uBAzEoB,UAAU;;ICd/B;QAA8C,oCAAM;QAApD;YAAA,qEAGC;YADU,UAAI,GAAG,YAAY,CAAC;;SAC9B;QAFQ,2BAAU,GAAG,YAAY,CAAC;QAEnC,uBAAC;KAAA,CAH6CC,aAAM,GAGnD;6BAHoB,gBAAgB;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-transition.cjs.js","sources":["../lib/animation.ts","../lib/component.ts","../lib/system.ts"],"sourcesContent":["import { Tween, Easing } from '@tweenjs/tween.js';\nimport type { Group } from '@tweenjs/tween.js';\n\ninterface CacheItem {\n property: Record<string, any>;\n key: string;\n}\n\ntype Cache = Record<string, CacheItem>;\n\nconst easingMap = {\n linear: Easing.Linear.None,\n 'ease-in': Easing.Quadratic.In,\n 'ease-out': Easing.Quadratic.Out,\n 'ease-in-out': Easing.Quadratic.InOut,\n 'bounce-in': Easing.Bounce.In,\n 'bounce-out': Easing.Bounce.Out,\n 'bounce-in-out': Easing.Bounce.InOut,\n none: p => ~~p,\n};\n\nexport default class Animation {\n private tweens = [];\n private timelines = [];\n private finishCount = 0;\n private callbacks = new Map();\n readonly tweenGroup: Group;\n\n stoped: boolean;\n objectCache: Record<string, Cache> = {};\n currIteration: number = 0;\n iteration: number;\n checkFinishFunc: Function;\n\n constructor(timelines, tweenGroup: Group) {\n this.timelines = timelines;\n this.tweenGroup = tweenGroup;\n }\n\n on(eventName, callback) {\n if (!this.callbacks[eventName]) {\n this.callbacks.set(eventName, []);\n }\n this.callbacks.get(eventName).push(callback);\n }\n\n emit(eventName) {\n const callbacks = this.callbacks.get(eventName);\n if (!callbacks || !callbacks.length) return;\n callbacks.forEach(fn => fn());\n }\n\n checkFinish() {\n if (++this.finishCount == this.tweens.length) {\n if (++this.currIteration == this.iteration) {\n this.emit('finish');\n } else {\n if (this.stoped) return;\n this.start();\n }\n }\n }\n\n getObjectCache(component, name): CacheItem {\n const key = `${component.gameObject.id}${component.name}`;\n if (!this.objectCache[key]) {\n this.objectCache[key] = {};\n }\n if (this.objectCache[key][name]) {\n return this.objectCache[key][name];\n }\n const keys = name.split('.');\n const keyIndex = keys.length - 1;\n let property = component;\n for (let i = 0; i < keyIndex; i++) {\n property = property[keys[i]];\n }\n this.objectCache[key][name] = { property, key: keys[keyIndex] };\n return this.objectCache[key][name];\n }\n\n doAnim({ component, name, value }) {\n const { property, key } = this.getObjectCache(component, name);\n property[key] = value;\n }\n\n init() {\n this.checkFinishFunc = this.checkFinish.bind(this);\n\n let lastTween;\n this.timelines.forEach((timeline, i) => {\n for (let j = 0; j < timeline.values.length - 1; j++) {\n const frame = timeline.values[j];\n const nextFrame = timeline.values[j + 1];\n\n const tween = new Tween({ value: frame.value }, this.tweenGroup)\n .to({ value: nextFrame.value })\n .duration(nextFrame.time - frame.time)\n .easing(easingMap[frame.tween])\n .onUpdate(props => {\n this.doAnim({\n component: timeline.component,\n name: timeline.name,\n value: props.value,\n });\n });\n\n if (j === 0) {\n this.tweens[i] = tween;\n } else {\n lastTween.chain(tween);\n }\n\n lastTween = tween;\n }\n lastTween && lastTween.onComplete(() => this.checkFinishFunc());\n });\n }\n\n play(iteration = 1) {\n this.stoped = false;\n this.start();\n this.currIteration = 0;\n this.iteration = iteration;\n }\n\n start() {\n this.finishCount = 0;\n this.tweens.length = 0;\n this.init();\n this.tweens.forEach((tween: Tween<any>) => tween.start());\n }\n\n pause() {\n this.tweens.forEach((tween: Tween<any>) => tween.pause());\n }\n\n resume() {\n this.tweens.forEach((tween: Tween<any>) => tween.resume());\n }\n\n stop() {\n this.stoped = true;\n this.tweens.forEach((tween: Tween<any>) => tween.stop());\n }\n\n destroy() {\n this.stop();\n this.tweens = null;\n this.timelines = null;\n this.objectCache = null;\n this.callbacks.clear();\n this.callbacks = null;\n }\n}\n","import Animation from './animation';\nimport { Component } from '@eva/eva.js';\nimport { Group } from '@tweenjs/tween.js';\n\ninterface AnimationStruct {\n name: string;\n component: Component;\n values: {\n time: number;\n value: number;\n tween?: string;\n }[];\n}\ninterface TransitionParams {\n group: Record<string, AnimationStruct[]>;\n}\nexport default class Transition extends Component<TransitionParams> {\n static componentName: string = 'Transition';\n\n private animations: Record<string, Animation> = {};\n\n tweenGroup: Group;\n group: Record<string, AnimationStruct[]> = {};\n\n init({ group } = { group: {} }) {\n this.group = group;\n this.tweenGroup = new Group();\n }\n\n awake() {\n for (const name in this.group) {\n this.newAnimation(name);\n }\n }\n\n play(name: string, iteration: number) {\n if (!name) {\n name = Object.keys(this.group)[0];\n }\n if (name && !this.animations[name] && this.group[name]) {\n this.newAnimation(name);\n }\n if (name && this.animations[name]) {\n this.animations[name].play(iteration);\n }\n }\n\n stop(name) {\n if (!name) {\n for (const key in this.animations) {\n this.animations[key].stop();\n }\n } else {\n this.animations[name].stop();\n }\n }\n\n onPause() {\n for (const key in this.animations) {\n this.animations[key].pause();\n }\n }\n\n onResume() {\n for (const key in this.animations) {\n this.animations[key].resume();\n }\n }\n\n onDestroy() {\n for (const key in this.animations) {\n this.animations[key].destroy();\n }\n this.tweenGroup.removeAll();\n this.tweenGroup = null;\n this.group = null;\n this.animations = null;\n this.removeAllListeners();\n }\n\n update() {\n this.tweenGroup.update();\n }\n\n newAnimation(name) {\n const animation = new Animation(this.group[name], this.tweenGroup);\n animation.on('finish', () => this.emit('finish', name));\n this.animations[name] = animation;\n }\n}\n","import { System } from '@eva/eva.js';\n\nexport default class TransitionSystem extends System {\n static systemName = 'transition';\n readonly name = 'transition';\n}\n"],"names":["Easing","Tween","Group","Animation","Component","System"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,IAAM,SAAS,GAAG;IAChB,MAAM,EAAEA,eAAM,CAAC,MAAM,CAAC,IAAI;IAC1B,SAAS,EAAEA,eAAM,CAAC,SAAS,CAAC,EAAE;IAC9B,UAAU,EAAEA,eAAM,CAAC,SAAS,CAAC,GAAG;IAChC,aAAa,EAAEA,eAAM,CAAC,SAAS,CAAC,KAAK;IACrC,WAAW,EAAEA,eAAM,CAAC,MAAM,CAAC,EAAE;IAC7B,YAAY,EAAEA,eAAM,CAAC,MAAM,CAAC,GAAG;IAC/B,eAAe,EAAEA,eAAM,CAAC,MAAM,CAAC,KAAK;IACpC,IAAI,EAAE,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,GAAA;CACf,CAAC;AAEF;IAaE,mBAAY,SAAS,EAAE,UAAiB;QAZhC,WAAM,GAAG,EAAE,CAAC;QACZ,cAAS,GAAG,EAAE,CAAC;QACf,gBAAW,GAAG,CAAC,CAAC;QAChB,cAAS,GAAG,IAAI,GAAG,EAAE,CAAC;QAI9B,gBAAW,GAA0B,EAAE,CAAC;QACxC,kBAAa,GAAW,CAAC,CAAC;QAKxB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;KAC9B;IAED,sBAAE,GAAF,UAAG,SAAS,EAAE,QAAQ;QACpB,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE;YAC9B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;SACnC;QACD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;KAC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AAG,IAAI,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,kBAAkB,EAAE,CAAC;KAC3B;IAED,2BAAM,GAAN;QACE,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;KAC1B;IAED,iCAAY,GAAZ,UAAa,IAAI;QAAjB,iBAIC;QAHC,IAAM,SAAS,GAAG,IAAIC,WAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACnE,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAM,OAAA,KAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAA,CAAC,CAAC;QACxD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;KACnC;IAvEM,wBAAa,GAAW,YAAY,CAAC;IAwE9C,iBAAC;CAAA,CAzEuCC,gBAAS,GAyEhD;mBAzEoB,UAAU;;ACd/B;IAA8C,oCAAM;IAApD;QAAA,qEAGC;QADU,UAAI,GAAG,YAAY,CAAC;;KAC9B;IAFQ,2BAAU,GAAG,YAAY,CAAC;IAEnC,uBAAC;CAAA,CAH6CC,aAAM,GAGnD;yBAHoB,gBAAgB;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-transition.esm.js","sources":["../lib/animation.ts","../lib/component.ts","../lib/system.ts"],"sourcesContent":["import { Tween, Easing } from '@tweenjs/tween.js';\nimport type { Group } from '@tweenjs/tween.js';\n\ninterface CacheItem {\n property: Record<string, any>;\n key: string;\n}\n\ntype Cache = Record<string, CacheItem>;\n\nconst easingMap = {\n linear: Easing.Linear.None,\n 'ease-in': Easing.Quadratic.In,\n 'ease-out': Easing.Quadratic.Out,\n 'ease-in-out': Easing.Quadratic.InOut,\n 'bounce-in': Easing.Bounce.In,\n 'bounce-out': Easing.Bounce.Out,\n 'bounce-in-out': Easing.Bounce.InOut,\n none: p => ~~p,\n};\n\nexport default class Animation {\n private tweens = [];\n private timelines = [];\n private finishCount = 0;\n private callbacks = new Map();\n readonly tweenGroup: Group;\n\n stoped: boolean;\n objectCache: Record<string, Cache> = {};\n currIteration: number = 0;\n iteration: number;\n checkFinishFunc: Function;\n\n constructor(timelines, tweenGroup: Group) {\n this.timelines = timelines;\n this.tweenGroup = tweenGroup;\n }\n\n on(eventName, callback) {\n if (!this.callbacks[eventName]) {\n this.callbacks.set(eventName, []);\n }\n this.callbacks.get(eventName).push(callback);\n }\n\n emit(eventName) {\n const callbacks = this.callbacks.get(eventName);\n if (!callbacks || !callbacks.length) return;\n callbacks.forEach(fn => fn());\n }\n\n checkFinish() {\n if (++this.finishCount == this.tweens.length) {\n if (++this.currIteration == this.iteration) {\n this.emit('finish');\n } else {\n if (this.stoped) return;\n this.start();\n }\n }\n }\n\n getObjectCache(component, name): CacheItem {\n const key = `${component.gameObject.id}${component.name}`;\n if (!this.objectCache[key]) {\n this.objectCache[key] = {};\n }\n if (this.objectCache[key][name]) {\n return this.objectCache[key][name];\n }\n const keys = name.split('.');\n const keyIndex = keys.length - 1;\n let property = component;\n for (let i = 0; i < keyIndex; i++) {\n property = property[keys[i]];\n }\n this.objectCache[key][name] = { property, key: keys[keyIndex] };\n return this.objectCache[key][name];\n }\n\n doAnim({ component, name, value }) {\n const { property, key } = this.getObjectCache(component, name);\n property[key] = value;\n }\n\n init() {\n this.checkFinishFunc = this.checkFinish.bind(this);\n\n let lastTween;\n this.timelines.forEach((timeline, i) => {\n for (let j = 0; j < timeline.values.length - 1; j++) {\n const frame = timeline.values[j];\n const nextFrame = timeline.values[j + 1];\n\n const tween = new Tween({ value: frame.value }, this.tweenGroup)\n .to({ value: nextFrame.value })\n .duration(nextFrame.time - frame.time)\n .easing(easingMap[frame.tween])\n .onUpdate(props => {\n this.doAnim({\n component: timeline.component,\n name: timeline.name,\n value: props.value,\n });\n });\n\n if (j === 0) {\n this.tweens[i] = tween;\n } else {\n lastTween.chain(tween);\n }\n\n lastTween = tween;\n }\n lastTween && lastTween.onComplete(() => this.checkFinishFunc());\n });\n }\n\n play(iteration = 1) {\n this.stoped = false;\n this.start();\n this.currIteration = 0;\n this.iteration = iteration;\n }\n\n start() {\n this.finishCount = 0;\n this.tweens.length = 0;\n this.init();\n this.tweens.forEach((tween: Tween<any>) => tween.start());\n }\n\n pause() {\n this.tweens.forEach((tween: Tween<any>) => tween.pause());\n }\n\n resume() {\n this.tweens.forEach((tween: Tween<any>) => tween.resume());\n }\n\n stop() {\n this.stoped = true;\n this.tweens.forEach((tween: Tween<any>) => tween.stop());\n }\n\n destroy() {\n this.stop();\n this.tweens = null;\n this.timelines = null;\n this.objectCache = null;\n this.callbacks.clear();\n this.callbacks = null;\n }\n}\n","import Animation from './animation';\nimport { Component } from '@eva/eva.js';\nimport { Group } from '@tweenjs/tween.js';\n\ninterface AnimationStruct {\n name: string;\n component: Component;\n values: {\n time: number;\n value: number;\n tween?: string;\n }[];\n}\ninterface TransitionParams {\n group: Record<string, AnimationStruct[]>;\n}\nexport default class Transition extends Component<TransitionParams> {\n static componentName: string = 'Transition';\n\n private animations: Record<string, Animation> = {};\n\n tweenGroup: Group;\n group: Record<string, AnimationStruct[]> = {};\n\n init({ group } = { group: {} }) {\n this.group = group;\n this.tweenGroup = new Group();\n }\n\n awake() {\n for (const name in this.group) {\n this.newAnimation(name);\n }\n }\n\n play(name: string, iteration: number) {\n if (!name) {\n name = Object.keys(this.group)[0];\n }\n if (name && !this.animations[name] && this.group[name]) {\n this.newAnimation(name);\n }\n if (name && this.animations[name]) {\n this.animations[name].play(iteration);\n }\n }\n\n stop(name) {\n if (!name) {\n for (const key in this.animations) {\n this.animations[key].stop();\n }\n } else {\n this.animations[name].stop();\n }\n }\n\n onPause() {\n for (const key in this.animations) {\n this.animations[key].pause();\n }\n }\n\n onResume() {\n for (const key in this.animations) {\n this.animations[key].resume();\n }\n }\n\n onDestroy() {\n for (const key in this.animations) {\n this.animations[key].destroy();\n }\n this.tweenGroup.removeAll();\n this.tweenGroup = null;\n this.group = null;\n this.animations = null;\n this.removeAllListeners();\n }\n\n update() {\n this.tweenGroup.update();\n }\n\n newAnimation(name) {\n const animation = new Animation(this.group[name], this.tweenGroup);\n animation.on('finish', () => this.emit('finish', name));\n this.animations[name] = animation;\n }\n}\n","import { System } from '@eva/eva.js';\n\nexport default class TransitionSystem extends System {\n static systemName = 'transition';\n readonly name = 'transition';\n}\n"],"names":["Animation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,IAAM,SAAS,GAAG;IAChB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI;IAC1B,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE;IAC9B,UAAU,EAAE,MAAM,CAAC,SAAS,CAAC,GAAG;IAChC,aAAa,EAAE,MAAM,CAAC,SAAS,CAAC,KAAK;IACrC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE;IAC7B,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG;IAC/B,eAAe,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK;IACpC,IAAI,EAAE,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,GAAA;CACf,CAAC;AAEF;IAaE,mBAAY,SAAS,EAAE,UAAiB;QAZhC,WAAM,GAAG,EAAE,CAAC;QACZ,cAAS,GAAG,EAAE,CAAC;QACf,gBAAW,GAAG,CAAC,CAAC;QAChB,cAAS,GAAG,IAAI,GAAG,EAAE,CAAC;QAI9B,gBAAW,GAA0B,EAAE,CAAC;QACxC,kBAAa,GAAW,CAAC,CAAC;QAKxB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;KAC9B;IAED,sBAAE,GAAF,UAAG,SAAS,EAAE,QAAQ;QACpB,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE;YAC9B,IAAI,CA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AG,CAAC,CAAC,OAAO,EAAE,CAAC;SAChC;QACD,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,kBAAkB,EAAE,CAAC;KAC3B;IAED,2BAAM,GAAN;QACE,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;KAC1B;IAED,iCAAY,GAAZ,UAAa,IAAI;QAAjB,iBAIC;QAHC,IAAM,SAAS,GAAG,IAAIA,WAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACnE,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAM,OAAA,KAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAA,CAAC,CAAC;QACxD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;KACnC;IAvEM,wBAAa,GAAW,YAAY,CAAC;IAwE9C,iBAAC;CAAA,CAzEuC,SAAS,GAyEhD;mBAzEoB,UAAU;;ACd/B;IAA8C,oCAAM;IAApD;QAAA,qEAGC;QADU,UAAI,GAAG,YAAY,CAAC;;KAC9B;IAFQ,2BAAU,GAAG,YAAY,CAAC;IAEnC,uBAAC;CAAA,CAH6C,MAAM,GAGnD;yBAHoB,gBAAgB;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-transition",
|
|
3
|
-
"version": "1.1.1-fix.
|
|
3
|
+
"version": "1.1.1-fix.3",
|
|
4
4
|
"description": "@eva/plugin-transition",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-transition.esm.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"homepage": "https://eva.js.org",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@eva/eva.js": "1.1.1-fix.
|
|
21
|
+
"@eva/eva.js": "1.1.1-fix.3",
|
|
22
22
|
"@tweenjs/tween.js": "^18.6.4",
|
|
23
23
|
"sprite-timeline": "^1.10.2"
|
|
24
24
|
}
|
package/dist/miniprogram.js
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
import { __extends } from 'tslib';
|
|
2
|
-
import { Easing, Tween, Group } from '@tweenjs/tween.js';
|
|
3
|
-
import { Component, System } from '@eva/eva.js/dist/miniprogram';
|
|
4
|
-
|
|
5
|
-
var easingMap = {
|
|
6
|
-
linear: Easing.Linear.None,
|
|
7
|
-
'ease-in': Easing.Quadratic.In,
|
|
8
|
-
'ease-out': Easing.Quadratic.Out,
|
|
9
|
-
'ease-in-out': Easing.Quadratic.InOut,
|
|
10
|
-
'bounce-in': Easing.Bounce.In,
|
|
11
|
-
'bounce-out': Easing.Bounce.Out,
|
|
12
|
-
'bounce-in-out': Easing.Bounce.InOut,
|
|
13
|
-
none: function (p) { return ~~p; },
|
|
14
|
-
};
|
|
15
|
-
var Animation = (function () {
|
|
16
|
-
function Animation(timelines, tweenGroup) {
|
|
17
|
-
this.tweens = [];
|
|
18
|
-
this.timelines = [];
|
|
19
|
-
this.finishCount = 0;
|
|
20
|
-
this.callbacks = new Map();
|
|
21
|
-
this.objectCache = {};
|
|
22
|
-
this.currIteration = 0;
|
|
23
|
-
this.timelines = timelines;
|
|
24
|
-
this.tweenGroup = tweenGroup;
|
|
25
|
-
}
|
|
26
|
-
Animation.prototype.on = function (eventName, callback) {
|
|
27
|
-
if (!this.callbacks[eventName]) {
|
|
28
|
-
this.callbacks.set(eventName, []);
|
|
29
|
-
}
|
|
30
|
-
this.callbacks.get(eventName).push(callback);
|
|
31
|
-
};
|
|
32
|
-
Animation.prototype.emit = function (eventName) {
|
|
33
|
-
var callbacks = this.callbacks.get(eventName);
|
|
34
|
-
if (!callbacks || !callbacks.length)
|
|
35
|
-
return;
|
|
36
|
-
callbacks.forEach(function (fn) { return fn(); });
|
|
37
|
-
};
|
|
38
|
-
Animation.prototype.checkFinish = function () {
|
|
39
|
-
if (++this.finishCount == this.tweens.length) {
|
|
40
|
-
if (++this.currIteration == this.iteration) {
|
|
41
|
-
this.emit('finish');
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
if (this.stoped)
|
|
45
|
-
return;
|
|
46
|
-
this.start();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
Animation.prototype.getObjectCache = function (component, name) {
|
|
51
|
-
var key = "" + component.gameObject.id + component.name;
|
|
52
|
-
if (!this.objectCache[key]) {
|
|
53
|
-
this.objectCache[key] = {};
|
|
54
|
-
}
|
|
55
|
-
if (this.objectCache[key][name]) {
|
|
56
|
-
return this.objectCache[key][name];
|
|
57
|
-
}
|
|
58
|
-
var keys = name.split('.');
|
|
59
|
-
var keyIndex = keys.length - 1;
|
|
60
|
-
var property = component;
|
|
61
|
-
for (var i = 0; i < keyIndex; i++) {
|
|
62
|
-
property = property[keys[i]];
|
|
63
|
-
}
|
|
64
|
-
this.objectCache[key][name] = { property: property, key: keys[keyIndex] };
|
|
65
|
-
return this.objectCache[key][name];
|
|
66
|
-
};
|
|
67
|
-
Animation.prototype.doAnim = function (_a) {
|
|
68
|
-
var component = _a.component, name = _a.name, value = _a.value;
|
|
69
|
-
var _b = this.getObjectCache(component, name), property = _b.property, key = _b.key;
|
|
70
|
-
property[key] = value;
|
|
71
|
-
};
|
|
72
|
-
Animation.prototype.init = function () {
|
|
73
|
-
var _this = this;
|
|
74
|
-
this.checkFinishFunc = this.checkFinish.bind(this);
|
|
75
|
-
var lastTween;
|
|
76
|
-
this.timelines.forEach(function (timeline, i) {
|
|
77
|
-
for (var j = 0; j < timeline.values.length - 1; j++) {
|
|
78
|
-
var frame = timeline.values[j];
|
|
79
|
-
var nextFrame = timeline.values[j + 1];
|
|
80
|
-
var tween = new Tween({ value: frame.value }, _this.tweenGroup)
|
|
81
|
-
.to({ value: nextFrame.value })
|
|
82
|
-
.duration(nextFrame.time - frame.time)
|
|
83
|
-
.easing(easingMap[frame.tween])
|
|
84
|
-
.onUpdate(function (props) {
|
|
85
|
-
_this.doAnim({
|
|
86
|
-
component: timeline.component,
|
|
87
|
-
name: timeline.name,
|
|
88
|
-
value: props.value,
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
if (j === 0) {
|
|
92
|
-
_this.tweens[i] = tween;
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
lastTween.chain(tween);
|
|
96
|
-
}
|
|
97
|
-
lastTween = tween;
|
|
98
|
-
}
|
|
99
|
-
lastTween && lastTween.onComplete(function () { return _this.checkFinishFunc(); });
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
Animation.prototype.play = function (iteration) {
|
|
103
|
-
if (iteration === void 0) { iteration = 1; }
|
|
104
|
-
this.stoped = false;
|
|
105
|
-
this.start();
|
|
106
|
-
this.currIteration = 0;
|
|
107
|
-
this.iteration = iteration;
|
|
108
|
-
};
|
|
109
|
-
Animation.prototype.start = function () {
|
|
110
|
-
this.finishCount = 0;
|
|
111
|
-
this.tweens.length = 0;
|
|
112
|
-
this.init();
|
|
113
|
-
this.tweens.forEach(function (tween) { return tween.start(); });
|
|
114
|
-
};
|
|
115
|
-
Animation.prototype.pause = function () {
|
|
116
|
-
this.tweens.forEach(function (tween) { return tween.pause(); });
|
|
117
|
-
};
|
|
118
|
-
Animation.prototype.resume = function () {
|
|
119
|
-
this.tweens.forEach(function (tween) { return tween.resume(); });
|
|
120
|
-
};
|
|
121
|
-
Animation.prototype.stop = function () {
|
|
122
|
-
this.stoped = true;
|
|
123
|
-
this.tweens.forEach(function (tween) { return tween.stop(); });
|
|
124
|
-
};
|
|
125
|
-
Animation.prototype.destroy = function () {
|
|
126
|
-
this.stop();
|
|
127
|
-
this.tweens = null;
|
|
128
|
-
this.timelines = null;
|
|
129
|
-
this.objectCache = null;
|
|
130
|
-
this.callbacks.clear();
|
|
131
|
-
this.callbacks = null;
|
|
132
|
-
};
|
|
133
|
-
return Animation;
|
|
134
|
-
}());
|
|
135
|
-
var Animation$1 = Animation;
|
|
136
|
-
|
|
137
|
-
var Transition = (function (_super) {
|
|
138
|
-
__extends(Transition, _super);
|
|
139
|
-
function Transition() {
|
|
140
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
141
|
-
_this.animations = {};
|
|
142
|
-
_this.group = {};
|
|
143
|
-
return _this;
|
|
144
|
-
}
|
|
145
|
-
Transition.prototype.init = function (_a) {
|
|
146
|
-
var group = (_a === void 0 ? { group: {} } : _a).group;
|
|
147
|
-
this.group = group;
|
|
148
|
-
this.tweenGroup = new Group();
|
|
149
|
-
};
|
|
150
|
-
Transition.prototype.awake = function () {
|
|
151
|
-
for (var name_1 in this.group) {
|
|
152
|
-
this.newAnimation(name_1);
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
Transition.prototype.play = function (name, iteration) {
|
|
156
|
-
if (!name) {
|
|
157
|
-
name = Object.keys(this.group)[0];
|
|
158
|
-
}
|
|
159
|
-
if (name && !this.animations[name] && this.group[name]) {
|
|
160
|
-
this.newAnimation(name);
|
|
161
|
-
}
|
|
162
|
-
if (name && this.animations[name]) {
|
|
163
|
-
this.animations[name].play(iteration);
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
Transition.prototype.stop = function (name) {
|
|
167
|
-
if (!name) {
|
|
168
|
-
for (var key in this.animations) {
|
|
169
|
-
this.animations[key].stop();
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
this.animations[name].stop();
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
Transition.prototype.onPause = function () {
|
|
177
|
-
for (var key in this.animations) {
|
|
178
|
-
this.animations[key].pause();
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
Transition.prototype.onResume = function () {
|
|
182
|
-
for (var key in this.animations) {
|
|
183
|
-
this.animations[key].resume();
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
Transition.prototype.onDestroy = function () {
|
|
187
|
-
for (var key in this.animations) {
|
|
188
|
-
this.animations[key].destroy();
|
|
189
|
-
}
|
|
190
|
-
this.tweenGroup.removeAll();
|
|
191
|
-
this.tweenGroup = null;
|
|
192
|
-
this.group = null;
|
|
193
|
-
this.animations = null;
|
|
194
|
-
this.removeAllListeners();
|
|
195
|
-
};
|
|
196
|
-
Transition.prototype.update = function () {
|
|
197
|
-
this.tweenGroup.update();
|
|
198
|
-
};
|
|
199
|
-
Transition.prototype.newAnimation = function (name) {
|
|
200
|
-
var _this = this;
|
|
201
|
-
var animation = new Animation$1(this.group[name], this.tweenGroup);
|
|
202
|
-
animation.on('finish', function () { return _this.emit('finish', name); });
|
|
203
|
-
this.animations[name] = animation;
|
|
204
|
-
};
|
|
205
|
-
Transition.componentName = 'Transition';
|
|
206
|
-
return Transition;
|
|
207
|
-
}(Component));
|
|
208
|
-
var Transition$1 = Transition;
|
|
209
|
-
|
|
210
|
-
var TransitionSystem = (function (_super) {
|
|
211
|
-
__extends(TransitionSystem, _super);
|
|
212
|
-
function TransitionSystem() {
|
|
213
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
214
|
-
_this.name = 'transition';
|
|
215
|
-
return _this;
|
|
216
|
-
}
|
|
217
|
-
TransitionSystem.systemName = 'transition';
|
|
218
|
-
return TransitionSystem;
|
|
219
|
-
}(System));
|
|
220
|
-
var TransitionSystem$1 = TransitionSystem;
|
|
221
|
-
|
|
222
|
-
export { Transition$1 as Transition, TransitionSystem$1 as TransitionSystem };
|