@eva/plugin-transition 1.2.7-editor.5 → 1.2.7-editor.8

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/dist/miniprogram.js +0 -340
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-transition",
3
- "version": "1.2.7-editor.5",
3
+ "version": "1.2.7-editor.8",
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.2.7-editor.5",
21
+ "@eva/eva.js": "1.2.7-editor.8",
22
22
  "@tweenjs/tween.js": "^18.6.4",
23
23
  "sprite-timeline": "^1.10.2"
24
24
  }
@@ -1,340 +0,0 @@
1
- import { __extends, __values } from 'tslib';
2
- import { Easing, Tween, Group } from '@tweenjs/tween.js';
3
- import { Component, System } from '@eva/eva.js/dist/miniprogram';
4
- var easingMap = {
5
- linear: Easing.Linear.None,
6
- 'ease-in': Easing.Quadratic.In,
7
- 'ease-out': Easing.Quadratic.Out,
8
- 'ease-in-out': Easing.Quadratic.InOut,
9
- 'bounce-in': Easing.Bounce.In,
10
- 'bounce-out': Easing.Bounce.Out,
11
- 'bounce-in-out': Easing.Bounce.InOut,
12
- none: function none(p) {
13
- return ~~p;
14
- }
15
- };
16
-
17
- var Animation = function () {
18
- function Animation(timelines, tweenGroup) {
19
- this.tweens = [];
20
- this.timelines = [];
21
- this.finishCount = 0;
22
- this.callbacks = new Map();
23
- this.objectCache = {};
24
- this.currIteration = 0;
25
- this.timelines = timelines;
26
- this.tweenGroup = tweenGroup;
27
- }
28
-
29
- Animation.prototype.on = function (eventName, callback) {
30
- if (!this.callbacks[eventName]) {
31
- this.callbacks.set(eventName, []);
32
- }
33
-
34
- this.callbacks.get(eventName).push(callback);
35
- };
36
-
37
- Animation.prototype.emit = function (eventName) {
38
- var callbacks = this.callbacks.get(eventName);
39
- if (!callbacks || !callbacks.length) return;
40
- callbacks.forEach(function (fn) {
41
- return fn();
42
- });
43
- };
44
-
45
- Animation.prototype.checkFinish = function () {
46
- if (++this.finishCount == this.tweens.length) {
47
- if (++this.currIteration == this.iteration) {
48
- this.emit('finish');
49
- } else {
50
- if (this.stoped) return;
51
- this.start();
52
- }
53
- }
54
- };
55
-
56
- Animation.prototype.getObjectCache = function (component, name) {
57
- var key = "" + component.gameObject.id + component.name;
58
-
59
- if (!this.objectCache[key]) {
60
- this.objectCache[key] = {};
61
- }
62
-
63
- if (this.objectCache[key][name]) {
64
- return this.objectCache[key][name];
65
- }
66
-
67
- var keys = name.split('.');
68
- var keyIndex = keys.length - 1;
69
- var property = component;
70
-
71
- for (var i = 0; i < keyIndex; i++) {
72
- property = property[keys[i]];
73
- }
74
-
75
- this.objectCache[key][name] = {
76
- property: property,
77
- key: keys[keyIndex]
78
- };
79
- return this.objectCache[key][name];
80
- };
81
-
82
- Animation.prototype.doAnim = function (_a) {
83
- var component = _a.component,
84
- name = _a.name,
85
- value = _a.value;
86
-
87
- var _b = this.getObjectCache(component, name),
88
- property = _b.property,
89
- key = _b.key;
90
-
91
- property[key] = value;
92
- };
93
-
94
- Animation.prototype.init = function () {
95
- var _this = this;
96
-
97
- this.checkFinishFunc = this.checkFinish.bind(this);
98
- var lastTween;
99
- this.timelines.forEach(function (timeline, i) {
100
- for (var j = 0; j < timeline.values.length - 1; j++) {
101
- var frame = timeline.values[j];
102
- var nextFrame = timeline.values[j + 1];
103
- var tween = new Tween({
104
- value: frame.value
105
- }, _this.tweenGroup).to({
106
- value: nextFrame.value
107
- }).duration(nextFrame.time - frame.time).easing(easingMap[frame.tween]).onUpdate(function (props) {
108
- _this.doAnim({
109
- component: timeline.component,
110
- name: timeline.name,
111
- value: props.value
112
- });
113
- });
114
-
115
- if (j === 0) {
116
- _this.tweens[i] = tween;
117
- } else {
118
- lastTween.chain(tween);
119
- }
120
-
121
- lastTween = tween;
122
- }
123
-
124
- lastTween && lastTween.onComplete(function () {
125
- return _this.checkFinishFunc();
126
- });
127
- });
128
- };
129
-
130
- Animation.prototype.play = function (iteration, currentTime) {
131
- if (iteration === void 0) {
132
- iteration = 1;
133
- }
134
-
135
- this.currentTime = currentTime;
136
- this.stoped = false;
137
- this.start();
138
- this.currIteration = 0;
139
- this.iteration = iteration;
140
- };
141
-
142
- Animation.prototype.start = function () {
143
- var _this = this;
144
-
145
- this.finishCount = 0;
146
- this.tweens.length = 0;
147
- this.init();
148
- this.tweens.forEach(function (tween) {
149
- return tween.start(_this.currentTime);
150
- });
151
- };
152
-
153
- Animation.prototype.pause = function () {
154
- var _this = this;
155
-
156
- this.tweens.forEach(function (tween) {
157
- return tween.pause(_this.currentTime);
158
- });
159
- };
160
-
161
- Animation.prototype.resume = function () {
162
- var _this = this;
163
-
164
- this.tweens.forEach(function (tween) {
165
- return tween.resume(_this.currentTime);
166
- });
167
- };
168
-
169
- Animation.prototype.stop = function () {
170
- this.stoped = true;
171
- this.tweens.forEach(function (tween) {
172
- return tween.stop();
173
- });
174
- };
175
-
176
- Animation.prototype.destroy = function () {
177
- this.stop();
178
- this.tweens = null;
179
- this.timelines = null;
180
- this.objectCache = null;
181
- this.callbacks.clear();
182
- this.callbacks = null;
183
- };
184
-
185
- return Animation;
186
- }();
187
-
188
- var Animation$1 = Animation;
189
-
190
- var Transition = function (_super) {
191
- __extends(Transition, _super);
192
-
193
- function Transition() {
194
- var _this = _super !== null && _super.apply(this, arguments) || this;
195
-
196
- _this.animations = {};
197
- _this.group = {};
198
- _this.currentTime = 0;
199
- _this.needPlay = [];
200
- return _this;
201
- }
202
-
203
- Transition.prototype.init = function (_a) {
204
- var group = (_a === void 0 ? {
205
- group: {}
206
- } : _a).group;
207
- this.group = group;
208
- this.tweenGroup = new Group();
209
- };
210
-
211
- Transition.prototype.awake = function () {
212
- for (var name_1 in this.group) {
213
- this.newAnimation(name_1);
214
- }
215
- };
216
-
217
- Transition.prototype.play = function (name, iteration) {
218
- if (!name) {
219
- name = Object.keys(this.group)[0];
220
- }
221
-
222
- if (name && !this.animations[name] && this.group[name]) {
223
- this.newAnimation(name);
224
- }
225
-
226
- if (name && this.animations[name]) {
227
- this.needPlay.push({
228
- name: name,
229
- iteration: iteration
230
- });
231
- }
232
- };
233
-
234
- Transition.prototype.stop = function (name) {
235
- var _a, _b;
236
-
237
- if (!name) {
238
- for (var key in this.animations) {
239
- (_a = this.animations[key]) === null || _a === void 0 ? void 0 : _a.stop();
240
- }
241
- } else {
242
- (_b = this.animations[name]) === null || _b === void 0 ? void 0 : _b.stop();
243
- }
244
- };
245
-
246
- Transition.prototype.onPause = function () {
247
- var _a;
248
-
249
- for (var key in this.animations) {
250
- (_a = this.animations[key]) === null || _a === void 0 ? void 0 : _a.pause();
251
- }
252
- };
253
-
254
- Transition.prototype.onResume = function () {
255
- var _a;
256
-
257
- for (var key in this.animations) {
258
- (_a = this.animations[key]) === null || _a === void 0 ? void 0 : _a.resume();
259
- }
260
- };
261
-
262
- Transition.prototype.onDestroy = function () {
263
- var _a;
264
-
265
- for (var key in this.animations) {
266
- (_a = this.animations[key]) === null || _a === void 0 ? void 0 : _a.destroy();
267
- }
268
-
269
- this.tweenGroup.removeAll();
270
- this.tweenGroup = null;
271
- this.group = null;
272
- this.animations = null;
273
- this.removeAllListeners();
274
- };
275
-
276
- Transition.prototype.update = function (e) {
277
- var e_1, _a;
278
-
279
- var _b;
280
-
281
- this.currentTime = e.time;
282
-
283
- for (var key in this.animations) {
284
- this.animations[key].currentTime = e.time;
285
- }
286
-
287
- this.tweenGroup.update(e.time);
288
-
289
- try {
290
- for (var _c = __values(this.needPlay), _d = _c.next(); !_d.done; _d = _c.next()) {
291
- var play = _d.value;
292
- (_b = this.animations[play.name]) === null || _b === void 0 ? void 0 : _b.play(play.iteration, this.currentTime);
293
- }
294
- } catch (e_1_1) {
295
- e_1 = {
296
- error: e_1_1
297
- };
298
- } finally {
299
- try {
300
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
301
- } finally {
302
- if (e_1) throw e_1.error;
303
- }
304
- }
305
-
306
- this.needPlay.length = 0;
307
- };
308
-
309
- Transition.prototype.newAnimation = function (name) {
310
- var _this = this;
311
-
312
- var animation = new Animation$1(this.group[name], this.tweenGroup);
313
- animation.on('finish', function () {
314
- return _this.emit('finish', name);
315
- });
316
- this.animations[name] = animation;
317
- };
318
-
319
- Transition.componentName = 'Transition';
320
- return Transition;
321
- }(Component);
322
-
323
- var Transition$1 = Transition;
324
-
325
- var TransitionSystem = function (_super) {
326
- __extends(TransitionSystem, _super);
327
-
328
- function TransitionSystem() {
329
- var _this = _super !== null && _super.apply(this, arguments) || this;
330
-
331
- _this.name = 'transition';
332
- return _this;
333
- }
334
-
335
- TransitionSystem.systemName = 'transition';
336
- return TransitionSystem;
337
- }(System);
338
-
339
- var TransitionSystem$1 = TransitionSystem;
340
- export { Transition$1 as Transition, TransitionSystem$1 as TransitionSystem };