Skip to content

Commit

Permalink
Merge pull request #194 from LottieFiles/feat/disable-shadow-dom-prop
Browse files Browse the repository at this point in the history
feat: added disable shadow dom prop
  • Loading branch information
samuelOsborne authored Jan 30, 2023
2 parents c098e7c + 2285325 commit 6c222e7
Show file tree
Hide file tree
Showing 4 changed files with 61 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.6.3",
"version": "1.7.0",
"description": "Lottie animation and Telegram Sticker player web components.",
"main": "dist/lottie-player.js",
"module": "dist/lottie-player.esm.js",
Expand Down
47 changes: 44 additions & 3 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,61 @@
<html>
<head> </head>
<head>
<style type="text/css">
#animation-container {
background: red;
}
#player-one {
background: green;
}
.arm-l path {
fill: purple;
}

.body path {
fill: red;
}

.leg-l path {
fill: orange;
}

.leg-r path {
fill: orange;
}

.arm-r path {
fill: turquoise;
stroke-width: 8;
stroke: pink;
stroke-linecape: round;
}
</style>
</head>
<body>
<div
class="player-container"
style="width: 500px; height: 500px; margin: auto; justify-content: center"
>
<lottie-player
src="https://assets3.lottiefiles.com/packages/lf20_UJNc2t.json"
src="https://lottie.host/4458c0b5-4d8d-43f3-8d42-0739a212a523/L4yrEGvBsO.json"
autoplay
controls
loop
disableCheck
mode="normal"
viewBoxSize="0 0 50 600"
style="width: 320px"
id="player-one"
disableShadowDOM
></lottie-player>

<lottie-player
src="https://lottie.host/4458c0b5-4d8d-43f3-8d42-0739a212a523/L4yrEGvBsO.json"
autoplay
controls
loop
disableCheck
mode="normal"
style="width: 320px"
></lottie-player>
</div>

Expand Down
20 changes: 15 additions & 5 deletions src/lottie-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ export class LottiePlayer extends LitElement {
@property({ type: Boolean })
public disableCheck?: boolean = false;

/**
* Disable using shadow dom as the root
*/
@property({ type: Boolean })
public disableShadowDOM: boolean = false;

/**
* Whether to play on mouse hover
*/
Expand Down Expand Up @@ -239,10 +245,6 @@ export class LottiePlayer extends LitElement {
* Configure and initialize lottie-web player instance.
*/
public async load(src: string | object) {
if (!this.shadowRoot) {
return;
}

const options: any = {
container: this.container,
loop: false,
Expand Down Expand Up @@ -562,10 +564,18 @@ export class LottiePlayer extends LitElement {
? html`<div class="error">⚠️</div>`
: undefined}
</div>
${this.controls ? this.renderControls() : undefined}
${this.controls && !this.disableShadowDOM
? this.renderControls()
: undefined}
</div>`;
}

protected createRenderRoot(): Element | ShadowRoot {
this.style.display = "block";

return this.disableShadowDOM ? this : super.createRenderRoot();
}

/**
* Initialize everything on component first render.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/versions.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const LOTTIE_PLAYER_VERSION = "1.6.2";
export const LOTTIE_PLAYER_VERSION = "1.7.0";
export const LOTTIE_WEB_VERSION = "^5.10.0";

0 comments on commit 6c222e7

Please sign in to comment.