@eva/plugin-renderer-lottie 2.0.1-beta.7 → 2.0.1-beta.9

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.
@@ -7158,7 +7158,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
7158
7158
  this.style.fontStyle = this._values.fontStyle;
7159
7159
  this.style.lineHeight = this._values.lineHeight;
7160
7160
  this.anchor.x = 0.5;
7161
- this.anchor.y = 1;
7161
+ this.anchor.y = 0.8;
7162
7162
  }
7163
7163
  updateLottie(lottieLayer, _forceUpdate = false) {
7164
7164
  let forceUpdate = true;
@@ -8204,8 +8204,11 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8204
8204
  }
8205
8205
  update(snippetCache, firstFrame = false) {
8206
8206
  if (!this.living || !this.isDisplayLoaded || this.isPaused && !firstFrame) return;
8207
- const isEnd = this._updateTime(snippetCache);
8208
- const correctedFrameNum = this.beginFrame + this.frameNum;
8207
+ let isEnd = this._updateTime(snippetCache);
8208
+ const correctedFrameNum = this.direction === 1 ? this.beginFrame + this.frameNum : this.frameNum;
8209
+ if (this.direction === -1 && correctedFrameNum <= this.beginFrame) {
8210
+ isEnd = true;
8211
+ }
8209
8212
  this.root.updateFrame(correctedFrameNum);
8210
8213
  const np = correctedFrameNum >> 0;
8211
8214
  if (this._lastFrame !== np) {
@@ -8283,6 +8286,11 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8283
8286
  if (Tools.isBoolean(options.alternate)) this.alternate = options.alternate;
8284
8287
  if (Tools.isNumber(options.wait)) this.wait = options.wait;
8285
8288
  if (Tools.isNumber(options.delay)) this.delay = options.delay;
8289
+ if (Tools.isNumber(options.direction)) {
8290
+ this.direction = options.direction;
8291
+ } else {
8292
+ this.direction = 1;
8293
+ }
8286
8294
  this.replay();
8287
8295
  return this;
8288
8296
  }
@@ -8337,9 +8345,12 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8337
8345
  this._repeatsCut = this.repeats;
8338
8346
  this._delayCut = this.delay;
8339
8347
  this.living = true;
8340
- this.frameNum = 0;
8348
+ if (this.direction === -1) {
8349
+ this.frameNum = this.duration;
8350
+ } else {
8351
+ this.frameNum = 0;
8352
+ }
8341
8353
  this.duration = Math.floor(this.endFrame - this.beginFrame);
8342
- this.direction = 1;
8343
8354
  return this;
8344
8355
  }
8345
8356
  show() {
@@ -8563,19 +8574,20 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8563
8574
  });
8564
8575
  }
8565
8576
  add(changed) {
8577
+ var _a, _b;
8566
8578
  return __awaiter(this, void 0, void 0, function* () {
8567
8579
  this.manager = new AnimationManager(this.app);
8568
8580
  const component = changed.component;
8569
8581
  const container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
8570
8582
  if (!container) return;
8571
- const _a = component.options,
8583
+ const _c = component.options,
8572
8584
  {
8573
8585
  resource: rn
8574
- } = _a,
8575
- otherOpts = __rest(_a, ["resource"]);
8586
+ } = _c,
8587
+ otherOpts = __rest(_c, ["resource"]);
8576
8588
  const res = yield eva_js.resource.getResource(rn);
8577
8589
  const data = res.data;
8578
- const url = res.src.json.url;
8590
+ const url = ((_b = (_a = res.src) === null || _a === void 0 ? void 0 : _a.json) === null || _b === void 0 ? void 0 : _b.url) || '';
8579
8591
  const json = _extends({}, data.json || {});
8580
8592
  const assets = json.assets || [];
8581
8593
  assets.forEach(item => {
@@ -8586,6 +8598,9 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8586
8598
  prefix: this.getDir(url)
8587
8599
  }, otherOpts));
8588
8600
  component.anim = anim;
8601
+ if (component._replaceData) {
8602
+ anim.replaceData(component._replaceData);
8603
+ }
8589
8604
  container.addChildAt(anim.group, 0);
8590
8605
  this.managerLife.forEach(eventName => {
8591
8606
  anim.on(eventName, e => component.emit(eventName, e));
@@ -8594,6 +8609,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8594
8609
  });
8595
8610
  }
8596
8611
  getDir(url) {
8612
+ if (!url) return url;
8597
8613
  return new URL('./', url).href;
8598
8614
  }
8599
8615
  remove(changed) {
@@ -8614,6 +8630,7 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8614
8630
  class Lottie extends eva_js.Component {
8615
8631
  constructor(options) {
8616
8632
  super();
8633
+ this._replaceData = null;
8617
8634
  this.loadStatus = false;
8618
8635
  this.firstPlay = null;
8619
8636
  this.prevSlot = {};
@@ -8687,7 +8704,9 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
8687
8704
  this.anim.playSegment(this.playParamsHandle(params), expandOpts);
8688
8705
  }
8689
8706
  replaceData(data) {
8690
- if (data) this.anim.replaceData(data);
8707
+ if (data) {
8708
+ if (this.anim) this.anim.replaceData(data);else this._replaceData = data;
8709
+ }
8691
8710
  }
8692
8711
  playParamsHandle(params) {
8693
8712
  let p = [].concat(params);