Skip to content

Commit

Permalink
fix(rollback): rollback due to race condition issues
Browse files Browse the repository at this point in the history
  • Loading branch information
karamalie committed Sep 2, 2021
1 parent e100bdf commit 556307f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lottiefiles/lottie-player",
"version": "1.3.0",
"version": "1.3.1",
"description": "Lottie animation and Telegram Sticker player web components.",
"main": "dist/lottie-player.js",
"module": "dist/lottie-player.esm.js",
Expand Down
17 changes: 8 additions & 9 deletions src/lottie-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,28 +255,27 @@ export class LottiePlayer extends LitElement {
try {
const srcParsed = parseSrc(src);
let jsonData = {};
let assetsPath = "/images/";
let srcAttrib = typeof srcParsed === "string" ? "path" : "animationData";

// Clear previous animation, if any
if (this._lottie) {
this._lottie.destroy();
}

// Initialize lottie player and load animation
this._lottie = lottie.loadAnimation({
...options,

[srcAttrib]: srcParsed,
});

// Fetch resource if src is a remote URL
if (srcAttrib === "path") {
jsonData = await fromURL(srcParsed as string);
const url = srcParsed.toString();
assetsPath = url.substring(0, url.lastIndexOf("/")) + assetsPath;
srcAttrib = "animationData";
} else {
jsonData = srcParsed;
}
// Initialize lottie player and load animation
this._lottie = lottie.loadAnimation({
...options,
assetsPath: assetsPath,
animationData: jsonData,
});

if (!isLottie(jsonData)) {
this.currentState = PlayerState.Error;
Expand Down

0 comments on commit 556307f

Please sign in to comment.