未验证 提交 9975418a 编写于 作者: C Carl de Billy 提交者: GitHub

Merge pull request #12371 from unoplatform/dev/cdb/lottie-module-loading

fix(lottie): Improved the loadeability of Lottie library on Wasm
declare const require: any;
declare const require: unknown | undefined;
declare const config: any;
declare namespace Uno.UI {
import AnimationData = Lottie.AnimationData;
......
......@@ -63,7 +63,7 @@ var Uno;
static setProgress(elementId, progress) {
Lottie.withPlayer(p => {
const animation = Lottie._runningAnimations[elementId].animation;
var frame = Lottie._numberOfFrames * progress;
let frame = Lottie._numberOfFrames * progress;
if (frame < animation.firstFrame) {
frame = frame - animation.firstFrame;
}
......@@ -194,7 +194,17 @@ var Uno;
action(Lottie._player);
}
else {
require([`${config.uno_app_base}/lottie`], (p) => {
if (typeof require !== "function") {
console.error("RequireJS not present.");
return;
}
const dependencyToLoad = "/lottie";
const lottieDependencyName = config.uno_dependencies.find((d) => d.endsWith(dependencyToLoad));
require([lottieDependencyName], (p) => {
if (!p) {
console.error("Unable to load lottie player.");
return;
}
if (!Lottie._player) {
Lottie._player = p;
}
......
declare const require: any;
declare const require: unknown | undefined;
declare const config: any;
namespace Uno.UI {
......@@ -102,7 +102,7 @@ namespace Uno.UI {
public static setProgress(elementId: number, progress: number): string {
Lottie.withPlayer(p => {
const animation = Lottie._runningAnimations[elementId].animation;
var frame = Lottie._numberOfFrames * progress;
let frame = Lottie._numberOfFrames * progress;
if (frame < (animation as any).firstFrame) {
frame = frame - (animation as any).firstFrame
} else {
......@@ -266,7 +266,18 @@ namespace Uno.UI {
if (Lottie._player) {
action(Lottie._player);
} else {
require([`${config.uno_app_base}/lottie`], (p: LottiePlayer) => {
if (typeof require !== "function") {
console.error("RequireJS not present.");
return;
}
const dependencyToLoad = "/lottie";
const lottieDependencyName = config.uno_dependencies.find((d: string) => d.endsWith(dependencyToLoad));
require([lottieDependencyName], (p: LottiePlayer) => {
if(!p) {
console.error("Unable to load lottie player.");
return;
}
if (!Lottie._player) {
Lottie._player = p;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册