@eva/plugin-transition 1.1.1-fix.0 → 1.1.1-fix.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@tweenjs/tween.js"),n=require("@eva/eva.js"),i=function(t,n){return
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@tweenjs/tween.js"),n=require("@eva/eva.js"),i=function(t,n){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i])},i(t,n)};function e(t,n){function e(){this.constructor=t}i(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}var o={linear:t.Easing.Linear.None,"ease-in":t.Easing.Quadratic.In,"ease-out":t.Easing.Quadratic.Out,"ease-in-out":t.Easing.Quadratic.InOut,"bounce-in":t.Easing.Bounce.In,"bounce-out":t.Easing.Bounce.Out,"bounce-in-out":t.Easing.Bounce.InOut,none:function(t){return~~t}},s=function(){function n(t,n){this.tweens=[],this.timelines=[],this.finishCount=0,this.callbacks=new Map,this.objectCache={},this.currIteration=0,this.timelines=t,this.tweenGroup=n}return n.prototype.on=function(t,n){this.callbacks[t]||this.callbacks.set(t,[]),this.callbacks.get(t).push(n)},n.prototype.emit=function(t){var n=this.callbacks.get(t);n&&n.length&&n.forEach((function(t){return t()}))},n.prototype.checkFinish=function(){if(++this.finishCount==this.tweens.length)if(++this.currIteration==this.iteration)this.emit("finish");else{if(this.stoped)return;this.start()}},n.prototype.getObjectCache=function(t,n){var i=""+t.gameObject.id+t.name;if(this.objectCache[i]||(this.objectCache[i]={}),this.objectCache[i][n])return this.objectCache[i][n];for(var e=n.split("."),o=e.length-1,s=t,r=0;r<o;r++)s=s[e[r]];return this.objectCache[i][n]={property:s,key:e[o]},this.objectCache[i][n]},n.prototype.doAnim=function(t){var n=t.component,i=t.name,e=t.value,o=this.getObjectCache(n,i);o.property[o.key]=e},n.prototype.init=function(){var n,i=this;this.checkFinishFunc=this.checkFinish.bind(this),this.timelines.forEach((function(e,s){for(var r=0;r<e.values.length-1;r++){var a=e.values[r],u=e.values[r+1],h=new t.Tween({value:a.value},i.tweenGroup).to({value:u.value}).duration(u.time-a.time).easing(o[a.tween]).onUpdate((function(t){i.doAnim({component:e.component,name:e.name,value:t.value})}));0===r?i.tweens[s]=h:n.chain(h),n=h}n&&n.onComplete((function(){return i.checkFinishFunc()}))}))},n.prototype.play=function(t){void 0===t&&(t=1),this.stoped=!1,this.start(),this.currIteration=0,this.iteration=t},n.prototype.start=function(){this.finishCount=0,this.tweens.length=0,this.init(),this.tweens.forEach((function(t){return t.start()}))},n.prototype.pause=function(){this.tweens.forEach((function(t){return t.pause()}))},n.prototype.resume=function(){this.tweens.forEach((function(t){return t.resume()}))},n.prototype.stop=function(){this.stoped=!0,this.tweens.forEach((function(t){return t.stop()}))},n.prototype.destroy=function(){this.stop(),this.tweens=null,this.timelines=null,this.objectCache=null,this.callbacks.clear(),this.callbacks=null},n}(),r=function(n){function i(){var t=null!==n&&n.apply(this,arguments)||this;return t.animations={},t.group={},t}return e(i,n),i.prototype.init=function(n){var i=(void 0===n?{group:{}}:n).group;this.group=i,this.tweenGroup=new t.Group},i.prototype.awake=function(){for(var t in this.group)this.newAnimation(t)},i.prototype.play=function(t,n){t||(t=Object.keys(this.group)[0]),t&&!this.animations[t]&&this.group[t]&&this.newAnimation(t),t&&this.animations[t]&&this.animations[t].play(n)},i.prototype.stop=function(t){if(t)this.animations[t].stop();else for(var n in this.animations)this.animations[n].stop()},i.prototype.onPause=function(){for(var t in this.animations)this.animations[t].pause()},i.prototype.onResume=function(){for(var t in this.animations)this.animations[t].resume()},i.prototype.onDestroy=function(){for(var t in this.animations)this.animations[t].destroy();this.tweenGroup.removeAll(),this.tweenGroup=null,this.group=null,this.animations=null,this.removeAllListeners()},i.prototype.update=function(){this.tweenGroup.update()},i.prototype.newAnimation=function(t){var n=this,i=new s(this.group[t],this.tweenGroup);i.on("finish",(function(){return n.emit("finish",t)})),this.animations[t]=i},i.componentName="Transition",i}(n.Component),a=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.name="transition",n}return e(n,t),n.systemName="transition",n}(n.System);exports.Transition=r,exports.TransitionSystem=a;
|
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.1",
|
|
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.1",
|
|
22
22
|
"@tweenjs/tween.js": "^18.6.4",
|
|
23
23
|
"sprite-timeline": "^1.10.2"
|
|
24
24
|
}
|
|
@@ -1,1032 +0,0 @@
|
|
|
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';
|
|
6
|
-
|
|
7
|
-
/*! *****************************************************************************
|
|
8
|
-
Copyright (c) Microsoft Corporation.
|
|
9
|
-
|
|
10
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
-
purpose with or without fee is hereby granted.
|
|
12
|
-
|
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
-
***************************************************************************** */
|
|
21
|
-
/* global Reflect, Promise */
|
|
22
|
-
|
|
23
|
-
var extendStatics = function(d, b) {
|
|
24
|
-
extendStatics = Object.setPrototypeOf ||
|
|
25
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
26
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
27
|
-
return extendStatics(d, b);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
function __extends(d, b) {
|
|
31
|
-
extendStatics(d, b);
|
|
32
|
-
function __() { this.constructor = d; }
|
|
33
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
34
|
-
}
|
|
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
|
-
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,
|
|
818
|
-
none: function (p) { return ~~p; },
|
|
819
|
-
};
|
|
820
|
-
var Animation = (function () {
|
|
821
|
-
function Animation(timelines, tweenGroup) {
|
|
822
|
-
this.tweens = [];
|
|
823
|
-
this.timelines = [];
|
|
824
|
-
this.finishCount = 0;
|
|
825
|
-
this.callbacks = new Map();
|
|
826
|
-
this.objectCache = {};
|
|
827
|
-
this.currIteration = 0;
|
|
828
|
-
this.timelines = timelines;
|
|
829
|
-
this.tweenGroup = tweenGroup;
|
|
830
|
-
}
|
|
831
|
-
Animation.prototype.on = function (eventName, callback) {
|
|
832
|
-
if (!this.callbacks[eventName]) {
|
|
833
|
-
this.callbacks.set(eventName, []);
|
|
834
|
-
}
|
|
835
|
-
this.callbacks.get(eventName).push(callback);
|
|
836
|
-
};
|
|
837
|
-
Animation.prototype.emit = function (eventName) {
|
|
838
|
-
var callbacks = this.callbacks.get(eventName);
|
|
839
|
-
if (!callbacks || !callbacks.length)
|
|
840
|
-
return;
|
|
841
|
-
callbacks.forEach(function (fn) { return fn(); });
|
|
842
|
-
};
|
|
843
|
-
Animation.prototype.checkFinish = function () {
|
|
844
|
-
if (++this.finishCount == this.tweens.length) {
|
|
845
|
-
if (++this.currIteration == this.iteration) {
|
|
846
|
-
this.emit('finish');
|
|
847
|
-
}
|
|
848
|
-
else {
|
|
849
|
-
if (this.stoped)
|
|
850
|
-
return;
|
|
851
|
-
this.start();
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
};
|
|
855
|
-
Animation.prototype.getObjectCache = function (component, name) {
|
|
856
|
-
var key = "" + component.gameObject.id + component.name;
|
|
857
|
-
if (!this.objectCache[key]) {
|
|
858
|
-
this.objectCache[key] = {};
|
|
859
|
-
}
|
|
860
|
-
if (this.objectCache[key][name]) {
|
|
861
|
-
return this.objectCache[key][name];
|
|
862
|
-
}
|
|
863
|
-
var keys = name.split('.');
|
|
864
|
-
var keyIndex = keys.length - 1;
|
|
865
|
-
var property = component;
|
|
866
|
-
for (var i = 0; i < keyIndex; i++) {
|
|
867
|
-
property = property[keys[i]];
|
|
868
|
-
}
|
|
869
|
-
this.objectCache[key][name] = { property: property, key: keys[keyIndex] };
|
|
870
|
-
return this.objectCache[key][name];
|
|
871
|
-
};
|
|
872
|
-
Animation.prototype.doAnim = function (_a) {
|
|
873
|
-
var component = _a.component, name = _a.name, value = _a.value;
|
|
874
|
-
var _b = this.getObjectCache(component, name), property = _b.property, key = _b.key;
|
|
875
|
-
property[key] = value;
|
|
876
|
-
};
|
|
877
|
-
Animation.prototype.init = function () {
|
|
878
|
-
var _this = this;
|
|
879
|
-
this.checkFinishFunc = this.checkFinish.bind(this);
|
|
880
|
-
var lastTween;
|
|
881
|
-
this.timelines.forEach(function (timeline, i) {
|
|
882
|
-
for (var j = 0; j < timeline.values.length - 1; j++) {
|
|
883
|
-
var frame = timeline.values[j];
|
|
884
|
-
var nextFrame = timeline.values[j + 1];
|
|
885
|
-
var tween = new Tween({ value: frame.value }, _this.tweenGroup)
|
|
886
|
-
.to({ value: nextFrame.value })
|
|
887
|
-
.duration(nextFrame.time - frame.time)
|
|
888
|
-
.easing(easingMap[frame.tween])
|
|
889
|
-
.onUpdate(function (props) {
|
|
890
|
-
_this.doAnim({
|
|
891
|
-
component: timeline.component,
|
|
892
|
-
name: timeline.name,
|
|
893
|
-
value: props.value,
|
|
894
|
-
});
|
|
895
|
-
});
|
|
896
|
-
if (j === 0) {
|
|
897
|
-
_this.tweens[i] = tween;
|
|
898
|
-
}
|
|
899
|
-
else {
|
|
900
|
-
lastTween.chain(tween);
|
|
901
|
-
}
|
|
902
|
-
lastTween = tween;
|
|
903
|
-
}
|
|
904
|
-
lastTween && lastTween.onComplete(function () { return _this.checkFinishFunc(); });
|
|
905
|
-
});
|
|
906
|
-
};
|
|
907
|
-
Animation.prototype.play = function (iteration) {
|
|
908
|
-
if (iteration === void 0) { iteration = 1; }
|
|
909
|
-
this.stoped = false;
|
|
910
|
-
this.start();
|
|
911
|
-
this.currIteration = 0;
|
|
912
|
-
this.iteration = iteration;
|
|
913
|
-
};
|
|
914
|
-
Animation.prototype.start = function () {
|
|
915
|
-
this.finishCount = 0;
|
|
916
|
-
this.tweens.length = 0;
|
|
917
|
-
this.init();
|
|
918
|
-
this.tweens.forEach(function (tween) { return tween.start(); });
|
|
919
|
-
};
|
|
920
|
-
Animation.prototype.pause = function () {
|
|
921
|
-
this.tweens.forEach(function (tween) { return tween.pause(); });
|
|
922
|
-
};
|
|
923
|
-
Animation.prototype.resume = function () {
|
|
924
|
-
this.tweens.forEach(function (tween) { return tween.resume(); });
|
|
925
|
-
};
|
|
926
|
-
Animation.prototype.stop = function () {
|
|
927
|
-
this.stoped = true;
|
|
928
|
-
this.tweens.forEach(function (tween) { return tween.stop(); });
|
|
929
|
-
};
|
|
930
|
-
Animation.prototype.destroy = function () {
|
|
931
|
-
this.stop();
|
|
932
|
-
this.tweens = null;
|
|
933
|
-
this.timelines = null;
|
|
934
|
-
this.objectCache = null;
|
|
935
|
-
this.callbacks.clear();
|
|
936
|
-
this.callbacks = null;
|
|
937
|
-
};
|
|
938
|
-
return Animation;
|
|
939
|
-
}());
|
|
940
|
-
var Animation$1 = Animation;
|
|
941
|
-
|
|
942
|
-
var Transition = (function (_super) {
|
|
943
|
-
__extends(Transition, _super);
|
|
944
|
-
function Transition() {
|
|
945
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
946
|
-
_this.animations = {};
|
|
947
|
-
_this.group = {};
|
|
948
|
-
return _this;
|
|
949
|
-
}
|
|
950
|
-
Transition.prototype.init = function (_a) {
|
|
951
|
-
var group = (_a === void 0 ? { group: {} } : _a).group;
|
|
952
|
-
this.group = group;
|
|
953
|
-
this.tweenGroup = new Group();
|
|
954
|
-
};
|
|
955
|
-
Transition.prototype.awake = function () {
|
|
956
|
-
for (var name_1 in this.group) {
|
|
957
|
-
this.newAnimation(name_1);
|
|
958
|
-
}
|
|
959
|
-
};
|
|
960
|
-
Transition.prototype.play = function (name, iteration) {
|
|
961
|
-
if (!name) {
|
|
962
|
-
name = Object.keys(this.group)[0];
|
|
963
|
-
}
|
|
964
|
-
if (name && !this.animations[name] && this.group[name]) {
|
|
965
|
-
this.newAnimation(name);
|
|
966
|
-
}
|
|
967
|
-
if (name && this.animations[name]) {
|
|
968
|
-
this.animations[name].play(iteration);
|
|
969
|
-
}
|
|
970
|
-
};
|
|
971
|
-
Transition.prototype.stop = function (name) {
|
|
972
|
-
if (!name) {
|
|
973
|
-
for (var key in this.animations) {
|
|
974
|
-
this.animations[key].stop();
|
|
975
|
-
}
|
|
976
|
-
}
|
|
977
|
-
else {
|
|
978
|
-
this.animations[name].stop();
|
|
979
|
-
}
|
|
980
|
-
};
|
|
981
|
-
Transition.prototype.onPause = function () {
|
|
982
|
-
for (var key in this.animations) {
|
|
983
|
-
this.animations[key].pause();
|
|
984
|
-
}
|
|
985
|
-
};
|
|
986
|
-
Transition.prototype.onResume = function () {
|
|
987
|
-
for (var key in this.animations) {
|
|
988
|
-
this.animations[key].resume();
|
|
989
|
-
}
|
|
990
|
-
};
|
|
991
|
-
Transition.prototype.onDestroy = function () {
|
|
992
|
-
for (var key in this.animations) {
|
|
993
|
-
this.animations[key].destroy();
|
|
994
|
-
}
|
|
995
|
-
this.tweenGroup.removeAll();
|
|
996
|
-
this.tweenGroup = null;
|
|
997
|
-
this.group = null;
|
|
998
|
-
this.animations = null;
|
|
999
|
-
this.removeAllListeners();
|
|
1000
|
-
};
|
|
1001
|
-
Transition.prototype.update = function () {
|
|
1002
|
-
this.tweenGroup.update();
|
|
1003
|
-
};
|
|
1004
|
-
Transition.prototype.newAnimation = function (name) {
|
|
1005
|
-
var _this = this;
|
|
1006
|
-
var animation = new Animation$1(this.group[name], this.tweenGroup);
|
|
1007
|
-
animation.on('finish', function () { return _this.emit('finish', name); });
|
|
1008
|
-
this.animations[name] = animation;
|
|
1009
|
-
};
|
|
1010
|
-
Transition.componentName = 'Transition';
|
|
1011
|
-
return Transition;
|
|
1012
|
-
}(eva_js.Component));
|
|
1013
|
-
var Transition$1 = Transition;
|
|
1014
|
-
|
|
1015
|
-
var TransitionSystem = (function (_super) {
|
|
1016
|
-
__extends(TransitionSystem, _super);
|
|
1017
|
-
function TransitionSystem() {
|
|
1018
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
1019
|
-
_this.name = 'transition';
|
|
1020
|
-
return _this;
|
|
1021
|
-
}
|
|
1022
|
-
TransitionSystem.systemName = 'transition';
|
|
1023
|
-
return TransitionSystem;
|
|
1024
|
-
}(eva_js.System));
|
|
1025
|
-
var TransitionSystem$1 = TransitionSystem;
|
|
1026
|
-
|
|
1027
|
-
exports.Transition = Transition$1;
|
|
1028
|
-
exports.TransitionSystem = TransitionSystem$1;
|
|
1029
|
-
|
|
1030
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1031
|
-
|
|
1032
|
-
})));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var t,e;t=this,e=function(t,e){"use strict";var i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)};function n(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o,r={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 1-Math.cos(t*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1}},Back:{In:function(t){var e=1.70158;return t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:function(t){return 1-r.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*r.Bounce.In(2*t):.5*r.Bounce.Out(2*t-1)+.5}}},s="undefined"==typeof self&&"undefined"!=typeof process&&process.hrtime?function(){var t=process.hrtime();return 1e3*t[0]+t[1]/1e6}:"undefined"!=typeof self&&void 0!==self.performance&&void 0!==self.performance.now?self.performance.now.bind(self.performance):void 0!==Date.now?Date.now:function(){return(new Date).getTime()},a=function(){function t(){this._tweens={},this._tweensAddedDuringUpdate={}}return t.prototype.getAll=function(){var t=this;return Object.keys(this._tweens).map((function(e){return t._tweens[e]}))},t.prototype.removeAll=function(){this._tweens={}},t.prototype.add=function(t){this._tweens[t.getId()]=t,this._tweensAddedDuringUpdate[t.getId()]=t},t.prototype.remove=function(t){delete this._tweens[t.getId()],delete this._tweensAddedDuringUpdate[t.getId()]},t.prototype.update=function(t,e){void 0===t&&(t=s()),void 0===e&&(e=!1);var i=Object.keys(this._tweens);if(0===i.length)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var n=0;n<i.length;n++){var o=this._tweens[i[n]],r=!e;o&&!1===o.update(t,r)&&!e&&delete this._tweens[i[n]]}i=Object.keys(this._tweensAddedDuringUpdate)}return!0},t}(),u={Linear:function(t,e){var i=t.length-1,n=i*e,o=Math.floor(n),r=u.Utils.Linear;return e<0?r(t[0],t[1],n):e>1?r(t[i],t[i-1],i-n):r(t[o],t[o+1>i?i:o+1],n-o)},Bezier:function(t,e){for(var i=0,n=t.length-1,o=Math.pow,r=u.Utils.Bernstein,s=0;s<=n;s++)i+=o(1-e,n-s)*o(e,s)*t[s]*r(n,s);return i},CatmullRom:function(t,e){var i=t.length-1,n=i*e,o=Math.floor(n),r=u.Utils.CatmullRom;return t[0]===t[i]?(e<0&&(o=Math.floor(n=i*(1+e))),r(t[(o-1+i)%i],t[o],t[(o+1)%i],t[(o+2)%i],n-o)):e<0?t[0]-(r(t[0],t[0],t[1],t[1],-n)-t[0]):e>1?t[i]-(r(t[i],t[i],t[i-1],t[i-1],n-i)-t[i]):r(t[o?o-1:0],t[o],t[i<o+1?i:o+1],t[i<o+2?i:o+2],n-o)},Utils:{Linear:function(t,e,i){return(e-t)*i+t},Bernstein:function(t,e){var i=u.Utils.Factorial;return i(t)/i(e)/i(t-e)},Factorial:(o=[1],function(t){var e=1;if(o[t])return o[t];for(var i=t;i>1;i--)e*=i;return o[t]=e,e}),CatmullRom:function(t,e,i,n,o){var r=.5*(i-t),s=.5*(n-e),a=o*o;return(2*e-2*i+r+s)*(o*a)+(-3*e+3*i-2*r-s)*a+r*o+e}}},h=function(){function t(){}return t.nextId=function(){return t._nextId++},t._nextId=0,t}(),p=new a,c=function(){function t(t,e){void 0===e&&(e=p),this._object=t,this._group=e,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=r.Linear.None,this._interpolationFunction=u.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._id=h.nextId(),this._isChainStopped=!1,this._goToEnd=!1}return t.prototype.getId=function(){return this._id},t.prototype.isPlaying=function(){return this._isPlaying},t.prototype.isPaused=function(){return this._isPaused},t.prototype.to=function(t,e){return this._valuesEnd=Object.create(t),void 0!==e&&(this._duration=e),this},t.prototype.duration=function(t){return this._duration=t,this},t.prototype.start=function(t){if(this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed)for(var e in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(e),this._valuesStart[e]=this._valuesStartRepeat[e];return this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=void 0!==t?"string"==typeof t?s()+parseFloat(t):t:s(),this._startTime+=this._delayTime,this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat),this},t.prototype._setupProperties=function(t,e,i,n){for(var o in i){var r=t[o],s=Array.isArray(r),a=s?"array":typeof r,u=!s&&Array.isArray(i[o]);if("undefined"!==a&&"function"!==a){if(u){var h=i[o];if(0===h.length)continue;h=h.map(this._handleRelativeValue.bind(this,r)),i[o]=[r].concat(h)}if("object"!==a&&!s||!r||u)void 0===e[o]&&(e[o]=r),s||(e[o]*=1),n[o]=u?i[o].slice().reverse():e[o]||0;else{for(var p in e[o]=s?[]:{},r)e[o][p]=r[p];n[o]=s?[]:{},this._setupProperties(r,e[o],i[o],n[o])}}}},t.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},t.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},t.prototype.pause=function(t){return void 0===t&&(t=s()),this._isPaused||!this._isPlaying||(this._isPaused=!0,this._pauseStart=t,this._group&&this._group.remove(this)),this},t.prototype.resume=function(t){return void 0===t&&(t=s()),this._isPaused&&this._isPlaying?(this._isPaused=!1,this._startTime+=t-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this):this},t.prototype.stopChainedTweens=function(){for(var t=0,e=this._chainedTweens.length;t<e;t++)this._chainedTweens[t].stop();return this},t.prototype.group=function(t){return this._group=t,this},t.prototype.delay=function(t){return this._delayTime=t,this},t.prototype.repeat=function(t){return this._initialRepeat=t,this._repeat=t,this},t.prototype.repeatDelay=function(t){return this._repeatDelayTime=t,this},t.prototype.yoyo=function(t){return this._yoyo=t,this},t.prototype.easing=function(t){return this._easingFunction=t,this},t.prototype.interpolation=function(t){return this._interpolationFunction=t,this},t.prototype.chain=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this._chainedTweens=t,this},t.prototype.onStart=function(t){return this._onStartCallback=t,this},t.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},t.prototype.onRepeat=function(t){return this._onRepeatCallback=t,this},t.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},t.prototype.onStop=function(t){return this._onStopCallback=t,this},t.prototype.update=function(t,e){if(void 0===t&&(t=s()),void 0===e&&(e=!0),this._isPaused)return!0;var i,n,o=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(t>o)return!1;e&&this.start(t)}if(this._goToEnd=!1,t<this._startTime)return!0;!1===this._onStartCallbackFired&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),n=(t-this._startTime)/this._duration,n=0===this._duration||n>1?1:n;var r=this._easingFunction(n);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,r),this._onUpdateCallback&&this._onUpdateCallback(this._object,n),1===n){if(this._repeat>0){for(i in isFinite(this._repeat)&&this._repeat--,this._valuesStartRepeat)this._yoyo||"string"!=typeof this._valuesEnd[i]||(this._valuesStartRepeat[i]=this._valuesStartRepeat[i]+parseFloat(this._valuesEnd[i])),this._yoyo&&this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i];return this._yoyo&&(this._reversed=!this._reversed),void 0!==this._repeatDelayTime?this._startTime=t+this._repeatDelayTime:this._startTime=t+this._delayTime,this._onRepeatCallback&&this._onRepeatCallback(this._object),!0}this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var a=0,u=this._chainedTweens.length;a<u;a++)this._chainedTweens[a].start(this._startTime+this._duration);return this._isPlaying=!1,!1}return!0},t.prototype._updateProperties=function(t,e,i,n){for(var o in i)if(void 0!==e[o]){var r=e[o]||0,s=i[o],a=Array.isArray(t[o]),u=Array.isArray(s);!a&&u?t[o]=this._interpolationFunction(s,n):"object"==typeof s&&s?this._updateProperties(t[o],r,s,n):"number"==typeof(s=this._handleRelativeValue(r,s))&&(t[o]=r+(s-r)*n)}},t.prototype._handleRelativeValue=function(t,e){return"string"!=typeof e?e:"+"===e.charAt(0)||"-"===e.charAt(0)?t+parseFloat(e):parseFloat(e)},t.prototype._swapEndStartRepeatValues=function(t){var e=this._valuesStartRepeat[t],i=this._valuesEnd[t];this._valuesStartRepeat[t]="string"==typeof i?this._valuesStartRepeat[t]+parseFloat(i):this._valuesEnd[t],this._valuesEnd[t]=e},t}(),l=p;l.getAll.bind(l),l.removeAll.bind(l),l.add.bind(l),l.remove.bind(l),l.update.bind(l);var f={linear:r.Linear.None,"ease-in":r.Quadratic.In,"ease-out":r.Quadratic.Out,"ease-in-out":r.Quadratic.InOut,"bounce-in":r.Bounce.In,"bounce-out":r.Bounce.Out,"bounce-in-out":r.Bounce.InOut,none:function(t){return~~t}},_=function(){function t(t,e){this.tweens=[],this.timelines=[],this.finishCount=0,this.callbacks=new Map,this.objectCache={},this.currIteration=0,this.timelines=t,this.tweenGroup=e}return t.prototype.on=function(t,e){this.callbacks[t]||this.callbacks.set(t,[]),this.callbacks.get(t).push(e)},t.prototype.emit=function(t){var e=this.callbacks.get(t);e&&e.length&&e.forEach((function(t){return t()}))},t.prototype.checkFinish=function(){if(++this.finishCount==this.tweens.length)if(++this.currIteration==this.iteration)this.emit("finish");else{if(this.stoped)return;this.start()}},t.prototype.getObjectCache=function(t,e){var i=""+t.gameObject.id+t.name;if(this.objectCache[i]||(this.objectCache[i]={}),this.objectCache[i][e])return this.objectCache[i][e];for(var n=e.split("."),o=n.length-1,r=t,s=0;s<o;s++)r=r[n[s]];return this.objectCache[i][e]={property:r,key:n[o]},this.objectCache[i][e]},t.prototype.doAnim=function(t){var e=t.component,i=t.name,n=t.value,o=this.getObjectCache(e,i);o.property[o.key]=n},t.prototype.init=function(){var t,e=this;this.checkFinishFunc=this.checkFinish.bind(this),this.timelines.forEach((function(i,n){for(var o=0;o<i.values.length-1;o++){var r=i.values[o],s=i.values[o+1],a=new c({value:r.value},e.tweenGroup).to({value:s.value}).duration(s.time-r.time).easing(f[r.tween]).onUpdate((function(t){e.doAnim({component:i.component,name:i.name,value:t.value})}));0===o?e.tweens[n]=a:t.chain(a),t=a}t&&t.onComplete((function(){return e.checkFinishFunc()}))}))},t.prototype.play=function(t){void 0===t&&(t=1),this.stoped=!1,this.start(),this.currIteration=0,this.iteration=t},t.prototype.start=function(){this.finishCount=0,this.tweens.length=0,this.init(),this.tweens.forEach((function(t){return t.start()}))},t.prototype.pause=function(){this.tweens.forEach((function(t){return t.pause()}))},t.prototype.resume=function(){this.tweens.forEach((function(t){return t.resume()}))},t.prototype.stop=function(){this.stoped=!0,this.tweens.forEach((function(t){return t.stop()}))},t.prototype.destroy=function(){this.stop(),this.tweens=null,this.timelines=null,this.objectCache=null,this.callbacks.clear(),this.callbacks=null},t}(),d=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.animations={},e.group={},e}return n(e,t),e.prototype.init=function(t){var e=(void 0===t?{group:{}}:t).group;this.group=e,this.tweenGroup=new a},e.prototype.awake=function(){for(var t in this.group)this.newAnimation(t)},e.prototype.play=function(t,e){t||(t=Object.keys(this.group)[0]),t&&!this.animations[t]&&this.group[t]&&this.newAnimation(t),t&&this.animations[t]&&this.animations[t].play(e)},e.prototype.stop=function(t){if(t)this.animations[t].stop();else for(var e in this.animations)this.animations[e].stop()},e.prototype.onPause=function(){for(var t in this.animations)this.animations[t].pause()},e.prototype.onResume=function(){for(var t in this.animations)this.animations[t].resume()},e.prototype.onDestroy=function(){for(var t in this.animations)this.animations[t].destroy();this.tweenGroup.removeAll(),this.tweenGroup=null,this.group=null,this.animations=null,this.removeAllListeners()},e.prototype.update=function(){this.tweenGroup.update()},e.prototype.newAnimation=function(t){var e=this,i=new _(this.group[t],this.tweenGroup);i.on("finish",(function(){return e.emit("finish",t)})),this.animations[t]=i},e.componentName="Transition",e}(e.Component),y=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="transition",e}return n(e,t),e.systemName="transition",e}(e.System);t.Transition=d,t.TransitionSystem=y,Object.defineProperty(t,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@eva/eva.js")):"function"==typeof define&&define.amd?define(["exports","@eva/eva.js"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).EVA=t.EVA||{},t.EVA.plugin=t.EVA.plugin||{},t.EVA.plugin.transition={}),t.EVA);
|
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 };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Component } from '@eva/eva.js';
|
|
2
|
-
import { Group } from '@tweenjs/tween.js';
|
|
3
|
-
import { System } from '@eva/eva.js';
|
|
4
|
-
|
|
5
|
-
declare interface AnimationStruct {
|
|
6
|
-
name: string;
|
|
7
|
-
component: Component;
|
|
8
|
-
values: {
|
|
9
|
-
time: number;
|
|
10
|
-
value: number;
|
|
11
|
-
tween?: string;
|
|
12
|
-
}[];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export declare class Transition extends Component<TransitionParams> {
|
|
16
|
-
static componentName: string;
|
|
17
|
-
private animations;
|
|
18
|
-
tweenGroup: Group;
|
|
19
|
-
group: Record<string, AnimationStruct[]>;
|
|
20
|
-
init({ group }?: {
|
|
21
|
-
group: {};
|
|
22
|
-
}): void;
|
|
23
|
-
awake(): void;
|
|
24
|
-
play(name: string, iteration: number): void;
|
|
25
|
-
stop(name: any): void;
|
|
26
|
-
onPause(): void;
|
|
27
|
-
onResume(): void;
|
|
28
|
-
onDestroy(): void;
|
|
29
|
-
update(): void;
|
|
30
|
-
newAnimation(name: any): void;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
declare interface TransitionParams {
|
|
34
|
-
group: Record<string, AnimationStruct[]>;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export declare class TransitionSystem extends System {
|
|
38
|
-
static systemName: string;
|
|
39
|
-
readonly name = "transition";
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export { }
|