Skip to content

Commit

Permalink
feat(add web worker prop): added webworker prop
Browse files Browse the repository at this point in the history
  • Loading branch information
karamalie committed Nov 24, 2021
1 parent f1f3422 commit 8a19443
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
speed="1"
mode="normal"
style="width: 100%"
webworkers="true"
src="https://assets5.lottiefiles.com/packages/lf20_tl5nafup.json"
>
</lottie-player>
Expand Down
11 changes: 11 additions & 0 deletions src/lottie-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ export class LottiePlayer extends LitElement {
@property({ type: String })
public src?: string;

/**
* Enable web workers
*/
@property({type: Boolean})
public webworkers?: boolean;

/**
* Animation container.
*/
Expand Down Expand Up @@ -247,6 +253,10 @@ export class LottiePlayer extends LitElement {
this._lottie.destroy();
}

if(this.webworkers){
lottie.useWebWorker();
}

// Initialize lottie player and load animation
this._lottie = lottie.loadAnimation({
...options,
Expand Down Expand Up @@ -779,4 +789,5 @@ export class LottiePlayer extends LitElement {

this.dispatchEvent(new CustomEvent(PlayerEvents.Freeze));
}

}

0 comments on commit 8a19443

Please sign in to comment.