@eva/plugin-renderer-lottie 2.0.1-beta.7 → 2.0.1-beta.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.
- package/dist/EVA.plugin.renderer.lottie.js +29 -10
- package/dist/EVA.plugin.renderer.lottie.min.js +1 -1
- package/dist/plugin-renderer-lottie.cjs.js +35 -11
- package/dist/plugin-renderer-lottie.cjs.prod.js +1 -1
- package/dist/plugin-renderer-lottie.d.ts +2 -0
- package/dist/plugin-renderer-lottie.esm.js +35 -11
- package/package.json +3 -3
|
@@ -22,6 +22,7 @@ declare interface IExpandOpts {
|
|
|
22
22
|
[key: string]: any;
|
|
23
23
|
};
|
|
24
24
|
}>;
|
|
25
|
+
direction?: 1 | -1;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
declare interface IOptions {
|
|
@@ -35,6 +36,7 @@ export declare class Lottie extends Component {
|
|
|
35
36
|
slot: {
|
|
36
37
|
[key: string]: string;
|
|
37
38
|
};
|
|
39
|
+
_replaceData: Record<string, string> | null;
|
|
38
40
|
static componentName: string;
|
|
39
41
|
anim: any;
|
|
40
42
|
options: ExtendOptions;
|
|
@@ -10667,7 +10667,7 @@ class TextElement extends Text {
|
|
|
10667
10667
|
this.style.lineHeight = this._values.lineHeight;
|
|
10668
10668
|
|
|
10669
10669
|
this.anchor.x = 0.5;
|
|
10670
|
-
this.anchor.y =
|
|
10670
|
+
this.anchor.y = 0.8;
|
|
10671
10671
|
}
|
|
10672
10672
|
|
|
10673
10673
|
/**
|
|
@@ -12496,10 +12496,11 @@ class AnimationGroup extends Eventer {
|
|
|
12496
12496
|
*/
|
|
12497
12497
|
update(snippetCache, firstFrame = false) {
|
|
12498
12498
|
if (!this.living || !this.isDisplayLoaded || (this.isPaused && !firstFrame)) return;
|
|
12499
|
-
|
|
12500
|
-
const
|
|
12501
|
-
|
|
12502
|
-
|
|
12499
|
+
let isEnd = this._updateTime(snippetCache);
|
|
12500
|
+
const correctedFrameNum = this.direction === 1 ? this.beginFrame + this.frameNum : this.frameNum;
|
|
12501
|
+
if (this.direction === -1 && correctedFrameNum <= this.beginFrame) {
|
|
12502
|
+
isEnd = true;
|
|
12503
|
+
}
|
|
12503
12504
|
this.root.updateFrame(correctedFrameNum);
|
|
12504
12505
|
|
|
12505
12506
|
const np = correctedFrameNum >> 0;
|
|
@@ -12601,6 +12602,7 @@ class AnimationGroup extends Eventer {
|
|
|
12601
12602
|
* @param {boolean} [options.alternate=false] alternate direction every round
|
|
12602
12603
|
* @param {number} [options.wait=0] need wait how much millisecond to start
|
|
12603
12604
|
* @param {number} [options.delay=0] need delay how much millisecond to begin, effect every loop round
|
|
12605
|
+
* @param {number} [options.direction=1] need direction
|
|
12604
12606
|
* @return {this}
|
|
12605
12607
|
*/
|
|
12606
12608
|
playSegment(name, options = {}) {
|
|
@@ -12624,6 +12626,11 @@ class AnimationGroup extends Eventer {
|
|
|
12624
12626
|
if (Tools.isBoolean(options.alternate)) this.alternate = options.alternate;
|
|
12625
12627
|
if (Tools.isNumber(options.wait)) this.wait = options.wait;
|
|
12626
12628
|
if (Tools.isNumber(options.delay)) this.delay = options.delay;
|
|
12629
|
+
if (Tools.isNumber(options.direction)) {
|
|
12630
|
+
this.direction = options.direction;
|
|
12631
|
+
} else {
|
|
12632
|
+
this.direction = 1;
|
|
12633
|
+
}
|
|
12627
12634
|
|
|
12628
12635
|
this.replay();
|
|
12629
12636
|
return this;
|
|
@@ -12729,9 +12736,15 @@ class AnimationGroup extends Eventer {
|
|
|
12729
12736
|
this._repeatsCut = this.repeats;
|
|
12730
12737
|
this._delayCut = this.delay;
|
|
12731
12738
|
this.living = true;
|
|
12732
|
-
|
|
12739
|
+
// 根据播放方向设置初始帧位置
|
|
12740
|
+
if (this.direction === -1) {
|
|
12741
|
+
// 倒着播放从duration开始
|
|
12742
|
+
this.frameNum = this.duration;
|
|
12743
|
+
} else {
|
|
12744
|
+
// 正常播放从0开始
|
|
12745
|
+
this.frameNum = 0;
|
|
12746
|
+
}
|
|
12733
12747
|
this.duration = Math.floor(this.endFrame - this.beginFrame);
|
|
12734
|
-
this.direction = 1;
|
|
12735
12748
|
return this;
|
|
12736
12749
|
}
|
|
12737
12750
|
|
|
@@ -13117,16 +13130,17 @@ let LottieSystem = class LottieSystem extends Renderer {
|
|
|
13117
13130
|
});
|
|
13118
13131
|
}
|
|
13119
13132
|
add(changed) {
|
|
13133
|
+
var _a, _b;
|
|
13120
13134
|
return __awaiter(this, void 0, void 0, function* () {
|
|
13121
13135
|
this.manager = new AnimationManager(this.app);
|
|
13122
13136
|
const component = changed.component;
|
|
13123
13137
|
const container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
|
|
13124
13138
|
if (!container)
|
|
13125
13139
|
return;
|
|
13126
|
-
const
|
|
13140
|
+
const _c = component.options, { resource: rn } = _c, otherOpts = __rest(_c, ["resource"]);
|
|
13127
13141
|
const res = yield resource.getResource(rn);
|
|
13128
13142
|
const data = res.data;
|
|
13129
|
-
const url = res.src.json.url;
|
|
13143
|
+
const url = ((_b = (_a = res.src) === null || _a === void 0 ? void 0 : _a.json) === null || _b === void 0 ? void 0 : _b.url) || '';
|
|
13130
13144
|
const json = Object.assign({}, (data.json || {}));
|
|
13131
13145
|
const assets = json.assets || [];
|
|
13132
13146
|
assets.forEach(item => {
|
|
@@ -13135,6 +13149,9 @@ let LottieSystem = class LottieSystem extends Renderer {
|
|
|
13135
13149
|
});
|
|
13136
13150
|
const anim = this.manager.parseAnimation(Object.assign({ keyframes: json, prefix: this.getDir(url) }, otherOpts));
|
|
13137
13151
|
component.anim = anim;
|
|
13152
|
+
if (component._replaceData) {
|
|
13153
|
+
anim.replaceData(component._replaceData);
|
|
13154
|
+
}
|
|
13138
13155
|
container.addChildAt(anim.group, 0);
|
|
13139
13156
|
this.managerLife.forEach(eventName => {
|
|
13140
13157
|
anim.on(eventName, e => component.emit(eventName, e));
|
|
@@ -13144,6 +13161,8 @@ let LottieSystem = class LottieSystem extends Renderer {
|
|
|
13144
13161
|
});
|
|
13145
13162
|
}
|
|
13146
13163
|
getDir(url) {
|
|
13164
|
+
if (!url)
|
|
13165
|
+
return url;
|
|
13147
13166
|
return new URL('./', url).href;
|
|
13148
13167
|
}
|
|
13149
13168
|
remove(changed) {
|
|
@@ -13167,6 +13186,7 @@ var LottieSystem$1 = LottieSystem;
|
|
|
13167
13186
|
class Lottie extends Component {
|
|
13168
13187
|
constructor(options) {
|
|
13169
13188
|
super();
|
|
13189
|
+
this._replaceData = null;
|
|
13170
13190
|
this.loadStatus = false;
|
|
13171
13191
|
this.firstPlay = null;
|
|
13172
13192
|
this.prevSlot = {};
|
|
@@ -13221,8 +13241,12 @@ class Lottie extends Component {
|
|
|
13221
13241
|
this.anim.playSegment(this.playParamsHandle(params), expandOpts);
|
|
13222
13242
|
}
|
|
13223
13243
|
replaceData(data) {
|
|
13224
|
-
if (data)
|
|
13225
|
-
this.anim
|
|
13244
|
+
if (data) {
|
|
13245
|
+
if (this.anim)
|
|
13246
|
+
this.anim.replaceData(data);
|
|
13247
|
+
else
|
|
13248
|
+
this._replaceData = data;
|
|
13249
|
+
}
|
|
13226
13250
|
}
|
|
13227
13251
|
playParamsHandle(params) {
|
|
13228
13252
|
let p = [].concat(params);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer-lottie",
|
|
3
|
-
"version": "2.0.1-beta.
|
|
3
|
+
"version": "2.0.1-beta.8",
|
|
4
4
|
"description": "@eva/plugin-renderer-lottie",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer-lottie.esm.js",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"homepage": "https://eva.js.org",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@eva/eva.js": "2.0.1-beta.
|
|
22
|
-
"@eva/plugin-renderer": "2.0.1-beta.
|
|
21
|
+
"@eva/eva.js": "2.0.1-beta.8",
|
|
22
|
+
"@eva/plugin-renderer": "2.0.1-beta.8",
|
|
23
23
|
"ios-version": "^1.0.1",
|
|
24
24
|
"pixi.js": "^8.8.1"
|
|
25
25
|
}
|