@eva/plugin-renderer-lottie 2.0.2 → 2.1.0-beta.2
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 +88 -31
- package/dist/EVA.plugin.renderer.lottie.min.js +1 -1
- package/dist/plugin-renderer-lottie.cjs.js +109 -49
- package/dist/plugin-renderer-lottie.cjs.prod.js +1 -1
- package/dist/plugin-renderer-lottie.d.ts +23 -0
- package/dist/plugin-renderer-lottie.esm.js +109 -49
- package/package.json +3 -3
|
@@ -8516,39 +8516,35 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
8516
8516
|
};
|
|
8517
8517
|
};
|
|
8518
8518
|
var iOSVersion = iosVersion;
|
|
8519
|
-
const {
|
|
8520
|
-
|
|
8521
|
-
|
|
8522
|
-
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
|
|
8519
|
+
const getIOSMajor = () => {
|
|
8520
|
+
var _a, _b;
|
|
8521
|
+
const userAgent = ((_a = globalThis.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) || '';
|
|
8522
|
+
return (_b = iOSVersion(userAgent)) === null || _b === void 0 ? void 0 : _b.major;
|
|
8523
|
+
};
|
|
8524
|
+
const dataURL2blob = dataURL => {
|
|
8525
|
+
var _a;
|
|
8526
|
+
const binaryString = atob(dataURL.split(',')[1]);
|
|
8527
|
+
const arrayBuffer = new ArrayBuffer(binaryString.length);
|
|
8528
|
+
const intArray = new Uint8Array(arrayBuffer);
|
|
8529
|
+
const mime = ((_a = dataURL.split(',')[0].match(/:(.*?);/)) === null || _a === void 0 ? void 0 : _a[1]) || 'image/png';
|
|
8527
8530
|
for (let i = 0, j = binaryString.length; i < j; i++) {
|
|
8528
8531
|
intArray[i] = binaryString.charCodeAt(i);
|
|
8529
8532
|
}
|
|
8530
|
-
|
|
8531
|
-
|
|
8532
|
-
|
|
8533
|
-
|
|
8534
|
-
|
|
8535
|
-
|
|
8536
|
-
|
|
8537
|
-
|
|
8538
|
-
}
|
|
8539
|
-
return result;
|
|
8540
|
-
}
|
|
8541
|
-
function dataURL2ObjUrl(dataURL) {
|
|
8542
|
-
window.URL = window.URL || window.webkitURL;
|
|
8543
|
-
if (window.URL && URL.createObjectURL) {
|
|
8544
|
-
const blob = dataURL2blob(dataURL);
|
|
8545
|
-
return URL.createObjectURL(blob);
|
|
8533
|
+
return new Blob([intArray], {
|
|
8534
|
+
type: mime
|
|
8535
|
+
});
|
|
8536
|
+
};
|
|
8537
|
+
const dataURL2ObjUrl = dataURL => {
|
|
8538
|
+
const urlFactory = globalThis.URL || window.webkitURL;
|
|
8539
|
+
if (urlFactory === null || urlFactory === void 0 ? void 0 : urlFactory.createObjectURL) {
|
|
8540
|
+
return urlFactory.createObjectURL(dataURL2blob(dataURL));
|
|
8546
8541
|
}
|
|
8547
8542
|
return dataURL;
|
|
8548
|
-
}
|
|
8543
|
+
};
|
|
8549
8544
|
function imageHandle(source) {
|
|
8550
8545
|
const isBase64Reg = /^data:image\/png;base64/;
|
|
8551
|
-
|
|
8546
|
+
const major = getIOSMajor();
|
|
8547
|
+
if (major && major <= 8 && isBase64Reg.test(source)) {
|
|
8552
8548
|
return dataURL2ObjUrl(source);
|
|
8553
8549
|
}
|
|
8554
8550
|
return source;
|
|
@@ -8629,17 +8625,30 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
8629
8625
|
var LottieSystem$1 = LottieSystem;
|
|
8630
8626
|
class Lottie extends eva_js.Component {
|
|
8631
8627
|
constructor(options) {
|
|
8628
|
+
var _a, _b, _c, _d;
|
|
8632
8629
|
super();
|
|
8633
8630
|
this._replaceData = null;
|
|
8631
|
+
this.autoplay = false;
|
|
8632
|
+
this.loop = false;
|
|
8633
|
+
this._speed = 1;
|
|
8634
8634
|
this.loadStatus = false;
|
|
8635
8635
|
this.firstPlay = null;
|
|
8636
8636
|
this.prevSlot = {};
|
|
8637
8637
|
this.currentSlot = {};
|
|
8638
|
-
|
|
8639
|
-
|
|
8640
|
-
|
|
8638
|
+
const autoStart = (_b = (_a = options.autoStart) !== null && _a !== void 0 ? _a : options.autoplay) !== null && _b !== void 0 ? _b : false;
|
|
8639
|
+
this.options = _extends(_extends({}, options), {
|
|
8640
|
+
autoStart
|
|
8641
|
+
});
|
|
8642
|
+
this.autoplay = autoStart;
|
|
8643
|
+
this.loop = (_c = options.loop) !== null && _c !== void 0 ? _c : false;
|
|
8644
|
+
this._speed = (_d = options.speed) !== null && _d !== void 0 ? _d : 1;
|
|
8645
|
+
this.onComplete = options.onComplete;
|
|
8646
|
+
this.onLoopComplete = options.onLoopComplete;
|
|
8647
|
+
if (this.onComplete) this.on('complete', this.onComplete);
|
|
8648
|
+
if (this.onLoopComplete) this.on('loopComplete', this.onLoopComplete);
|
|
8641
8649
|
this.on('success', () => {
|
|
8642
8650
|
this.loadStatus = true;
|
|
8651
|
+
this.applySpeed();
|
|
8643
8652
|
const {
|
|
8644
8653
|
ip,
|
|
8645
8654
|
op
|
|
@@ -8648,21 +8657,34 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
8648
8657
|
const event = `@${i}`;
|
|
8649
8658
|
this.anim.on(event, e => this.emit(event, e));
|
|
8650
8659
|
}
|
|
8660
|
+
if (this.options.autoStart) this.play();
|
|
8651
8661
|
this.firstPlay && this.firstPlay();
|
|
8652
8662
|
});
|
|
8653
8663
|
}
|
|
8664
|
+
get speed() {
|
|
8665
|
+
return this._speed;
|
|
8666
|
+
}
|
|
8667
|
+
set speed(value) {
|
|
8668
|
+
this._speed = value;
|
|
8669
|
+
this.options.speed = value;
|
|
8670
|
+
this.applySpeed();
|
|
8671
|
+
}
|
|
8654
8672
|
play(params = [], expandOpts = {
|
|
8655
8673
|
repeats: 0
|
|
8656
8674
|
}) {
|
|
8675
|
+
var _a;
|
|
8657
8676
|
if (!this.loadStatus) {
|
|
8658
8677
|
this.firstPlay = () => {
|
|
8659
8678
|
this.play(params, expandOpts);
|
|
8660
8679
|
};
|
|
8661
8680
|
return;
|
|
8662
8681
|
}
|
|
8682
|
+
const playOptions = _extends(_extends({}, expandOpts), {
|
|
8683
|
+
repeats: (_a = expandOpts.repeats) !== null && _a !== void 0 ? _a : this.loop ? -1 : 0
|
|
8684
|
+
});
|
|
8663
8685
|
const {
|
|
8664
8686
|
slot = []
|
|
8665
|
-
} =
|
|
8687
|
+
} = playOptions;
|
|
8666
8688
|
slot.forEach(({
|
|
8667
8689
|
name,
|
|
8668
8690
|
type,
|
|
@@ -8701,7 +8723,24 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
8701
8723
|
this.anim.bindSlot(name, this.currentSlot[name]);
|
|
8702
8724
|
this.prevSlot[name] = this.currentSlot[name];
|
|
8703
8725
|
});
|
|
8704
|
-
this.anim.playSegment(this.playParamsHandle(params),
|
|
8726
|
+
this.anim.playSegment(this.playParamsHandle(params), playOptions);
|
|
8727
|
+
}
|
|
8728
|
+
pause() {
|
|
8729
|
+
var _a;
|
|
8730
|
+
if ((_a = this.anim) === null || _a === void 0 ? void 0 : _a.pause) this.anim.pause();
|
|
8731
|
+
}
|
|
8732
|
+
stop() {
|
|
8733
|
+
var _a, _b;
|
|
8734
|
+
if ((_a = this.anim) === null || _a === void 0 ? void 0 : _a.stop) this.anim.stop();else if ((_b = this.anim) === null || _b === void 0 ? void 0 : _b.goToAndStop) this.anim.goToAndStop(0, true);
|
|
8735
|
+
}
|
|
8736
|
+
goToFrame(frame) {
|
|
8737
|
+
var _a;
|
|
8738
|
+
if ((_a = this.anim) === null || _a === void 0 ? void 0 : _a.goToAndStop) this.anim.goToAndStop(frame, true);
|
|
8739
|
+
}
|
|
8740
|
+
load() {
|
|
8741
|
+
var _a;
|
|
8742
|
+
if (this.loadStatus || this.anim) return;
|
|
8743
|
+
this.firstPlay = (_a = this.firstPlay) !== null && _a !== void 0 ? _a : () => {};
|
|
8705
8744
|
}
|
|
8706
8745
|
replaceData(data) {
|
|
8707
8746
|
if (data) {
|
|
@@ -8734,6 +8773,24 @@ var _EVA_IIFE_lottie = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
8734
8773
|
});
|
|
8735
8774
|
});
|
|
8736
8775
|
}
|
|
8776
|
+
destroy() {
|
|
8777
|
+
var _a;
|
|
8778
|
+
Object.keys(this.prevSlot).forEach(name => {
|
|
8779
|
+
var _a;
|
|
8780
|
+
const slot = this.prevSlot[name];
|
|
8781
|
+
if (((_a = this.anim) === null || _a === void 0 ? void 0 : _a.unbindSlot) && slot) this.anim.unbindSlot(name, slot);
|
|
8782
|
+
if (slot === null || slot === void 0 ? void 0 : slot.destroy) slot.destroy();
|
|
8783
|
+
});
|
|
8784
|
+
this.prevSlot = {};
|
|
8785
|
+
this.currentSlot = {};
|
|
8786
|
+
if ((_a = this.anim) === null || _a === void 0 ? void 0 : _a.destroy) this.anim.destroy();
|
|
8787
|
+
this.anim = null;
|
|
8788
|
+
this.loadStatus = false;
|
|
8789
|
+
}
|
|
8790
|
+
applySpeed() {
|
|
8791
|
+
var _a;
|
|
8792
|
+
if ((_a = this.anim) === null || _a === void 0 ? void 0 : _a.setSpeed) this.anim.setSpeed(this._speed);else if (this.anim) this.anim.timeScale = this._speed;
|
|
8793
|
+
}
|
|
8737
8794
|
}
|
|
8738
8795
|
Lottie.componentName = 'Lottie';
|
|
8739
8796
|
eva_js.resource.registerResourceType('LOTTIE');
|