Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added disable check prop #178

Merged
merged 1 commit into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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