Skip to content

Commit

Permalink
Merge pull request #178 from LottieFiles/feat/disable-check
Browse files Browse the repository at this point in the history
feat: added disable check prop
  • Loading branch information
samuelOsborne authored Dec 1, 2022
2 parents 4ae7a87 + 860771f commit 26c26d7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ node_modules
.idea
.vscode
.history

coverage/lcov-report/

dist/

Expand Down
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.6.0",
"version": "1.6.1",
"description": "Lottie animation and Telegram Sticker player web components.",
"main": "dist/lottie-player.js",
"module": "dist/lottie-player.esm.js",
Expand Down
28 changes: 18 additions & 10 deletions src/lottie-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ export class LottiePlayer extends LitElement {
@property({ type: Number })
public direction: number = 1;

/**
* Disable checking if the Lottie is valid before loading
*/
@property({ type: Boolean })
public disableCheck?: boolean = false;

/**
* Whether to play on mouse hover
*/
Expand Down Expand Up @@ -262,17 +268,19 @@ export class LottiePlayer extends LitElement {
// Attach the event listeners before we check the requested json file for errors
this._attachEventListeners();

// Fetch resource if src is a remote URL
if (srcAttrib === "path") {
jsonData = await fromURL(srcParsed as string);
srcAttrib = "animationData";
} else {
jsonData = srcParsed;
}
if (!this.disableCheck) {
// Fetch resource if src is a remote URL
if (srcAttrib === "path") {
jsonData = await fromURL(srcParsed as string);
srcAttrib = "animationData";
} else {
jsonData = srcParsed;
}

if (!isLottie(jsonData)) {
this.currentState = PlayerState.Error;
this.dispatchEvent(new CustomEvent(PlayerEvents.Error));
if (!isLottie(jsonData)) {
this.currentState = PlayerState.Error;
this.dispatchEvent(new CustomEvent(PlayerEvents.Error));
}
}
} catch (err) {
this.currentState = PlayerState.Error;
Expand Down

0 comments on commit 26c26d7

Please sign in to comment.