@aarsteinmedia/dotlottie-player 6.2.4 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/dist/canvas.d.ts +3 -2
- package/dist/canvas.js +15 -5
- package/dist/full.d.ts +5 -4
- package/dist/full.js +15 -5
- package/dist/light.d.ts +3 -2
- package/dist/light.js +15 -5
- package/dist/svg.d.ts +5 -4
- package/dist/svg.js +15 -5
- package/dist/unpkg-canvas.js +9 -7
- package/dist/unpkg-full.js +9 -7
- package/dist/unpkg-light.js +9 -7
- package/dist/unpkg-svg.js +8 -6
- package/package.json +20 -24
package/CHANGELOG.md
CHANGED
|
@@ -7,7 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
Changelog was only added since [3.2.3], so it's not exhaustive. [Please report any missing noteable changes to us](https://github.com/aarsteinmedia/dotlottie-player/issues), and we'll add them promptly.
|
|
9
9
|
|
|
10
|
-
## [6.
|
|
10
|
+
## [6.3.0] - 22-02-2026
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Added partial support for Lottie v2.0 folder structure.
|
|
15
|
+
- Made it so that aria-label only is set if explicitly specified.
|
|
16
|
+
|
|
17
|
+
## [6.2.5] - 12-11-2025
|
|
11
18
|
|
|
12
19
|
### Changed
|
|
13
20
|
|
|
@@ -348,6 +355,7 @@ Changelog was only added since [3.2.3], so it's not exhaustive. [Please report a
|
|
|
348
355
|
- Removed dependencies
|
|
349
356
|
- `@lit`
|
|
350
357
|
|
|
358
|
+
[6.3.0]: https://www.npmjs.com/package/@aarsteinmedia/dotlottie-player/v/6.3.0
|
|
351
359
|
[6.0.1]: https://www.npmjs.com/package/@aarsteinmedia/dotlottie-player/v/6.0.1
|
|
352
360
|
[5.3.2]: https://www.npmjs.com/package/@aarsteinmedia/dotlottie-player/v/5.3.2
|
|
353
361
|
[5.2.4]: https://www.npmjs.com/package/@aarsteinmedia/dotlottie-player/v/5.2.4
|
package/dist/canvas.d.ts
CHANGED
|
@@ -94,6 +94,7 @@ declare abstract class DotLottiePlayerBase extends PropertyCallbackElement {
|
|
|
94
94
|
set subframe(value: HTMLBooleanAttribute);
|
|
95
95
|
get subframe(): HTMLBooleanAttribute;
|
|
96
96
|
protected _container: HTMLElement | null;
|
|
97
|
+
protected _DOMRect: DOMRect | null;
|
|
97
98
|
protected _errorMessage: string;
|
|
98
99
|
protected _identifier: string;
|
|
99
100
|
protected _isSettingsOpen: boolean;
|
|
@@ -155,9 +156,9 @@ declare abstract class DotLottiePlayerBase extends PropertyCallbackElement {
|
|
|
155
156
|
protected _handleSeekChange({ target }: Event): void;
|
|
156
157
|
protected _handleSettingsClick({ target }: Event): void;
|
|
157
158
|
protected setOptions(_options: {
|
|
158
|
-
container?: HTMLElement;
|
|
159
|
+
container?: undefined | HTMLElement;
|
|
159
160
|
rendererType: RendererType;
|
|
160
|
-
initialSegment?: Vector2;
|
|
161
|
+
initialSegment?: undefined | Vector2;
|
|
161
162
|
hasAutoplay: boolean;
|
|
162
163
|
hasLoop: boolean;
|
|
163
164
|
preserveAspectRatio: PreserveAspectRatio;
|
package/dist/canvas.js
CHANGED
|
@@ -20,7 +20,7 @@ if (isServer) {
|
|
|
20
20
|
if (updateOnConnected in this) {
|
|
21
21
|
this[updateOnConnected] = [];
|
|
22
22
|
}
|
|
23
|
-
const { observedProperties
|
|
23
|
+
const { observedProperties } = this.constructor;
|
|
24
24
|
const { length } = observedProperties;
|
|
25
25
|
for(let i = 0; i < length; i++){
|
|
26
26
|
const initialValue = this[observedProperties[i]], cachedValue = Symbol(observedProperties[i]);
|
|
@@ -252,7 +252,9 @@ const pauseIcon = /* HTML */ `
|
|
|
252
252
|
if (!this.shadow || !this.template) {
|
|
253
253
|
throw new Error('No Shadow Element or Template');
|
|
254
254
|
}
|
|
255
|
-
this.template.innerHTML = /* HTML */ `<div class="animation-container main" data-controls="${this.controls ?? false}" lang="${this.description ? document.documentElement.lang : 'en'}"
|
|
255
|
+
this.template.innerHTML = /* HTML */ `<div class="animation-container main" data-controls="${this.controls ?? false}" lang="${this.description ? document.documentElement.lang : 'en'}" data-loaded="${this._playerState.loaded}"><figure class="animation" style="background:${this.background}" ${this.description ? /* HTML */ `
|
|
256
|
+
aria-label="${this.description}"
|
|
257
|
+
` : ''}>${this.playerState === PlayerState.Error ? /* HTML */ `<div class="error"><svg preserveAspectRatio="${PreserveAspectRatio.Cover}" xmlns="${namespaceSVG}" width="1920" height="1080" viewBox="0 0 1920 1080" style="white-space:preserve"><path fill="#fff" d="M0 0h1920v1080H0z"/><path fill="#3a6d8b" d="M1190.2 531 1007 212.4c-22-38.2-77.2-38-98.8.5L729.5 531.3c-21.3 37.9 6.1 84.6 49.5 84.6l361.9.3c43.7 0 71.1-47.3 49.3-85.2zM937.3 288.7c.2-7.5 3.3-23.9 23.2-23.9 16.3 0 23 16.1 23 23.5 0 55.3-10.7 197.2-12.2 214.5-.1 1-.9 1.7-1.9 1.7h-18.3c-1 0-1.8-.7-1.9-1.7-1.4-17.5-13.4-162.9-11.9-214.1zm24.2 283.8c-13.1 0-23.7-10.6-23.7-23.7s10.6-23.7 23.7-23.7 23.7 10.6 23.7 23.7-10.6 23.7-23.7 23.7zM722.1 644h112.6v34.4h-70.4V698h58.8v31.7h-58.8v22.6h72.4v36.2H722.1V644zm162 57.1h.6c8.3-12.9 18.2-17.8 31.3-17.8 3 0 5.1.4 6.3 1v32.6h-.8c-22.4-3.8-35.6 6.3-35.6 29.5v42.3h-38.2V685.5h36.4v15.6zm78.9 0h.6c8.3-12.9 18.2-17.8 31.3-17.8 3 0 5.1.4 6.3 1v32.6h-.8c-22.4-3.8-35.6 6.3-35.6 29.5v42.3h-38.2V685.5H963v15.6zm39.5 36.2c0-31.3 22.2-54.8 56.6-54.8 34.4 0 56.2 23.5 56.2 54.8s-21.8 54.6-56.2 54.6c-34.4-.1-56.6-23.3-56.6-54.6zm74 0c0-17.4-6.1-29.1-17.8-29.1-11.7 0-17.4 11.7-17.4 29.1 0 17.4 5.7 29.1 17.4 29.1s17.8-11.8 17.8-29.1zm83.1-36.2h.6c8.3-12.9 18.2-17.8 31.3-17.8 3 0 5.1.4 6.3 1v32.6h-.8c-22.4-3.8-35.6 6.3-35.6 29.5v42.3h-38.2V685.5h36.4v15.6z"/><path fill="none" d="M718.9 807.7h645v285.4h-645z"/><text fill="#3a6d8b" style="text-align:center;position:absolute;left:100%;font-size:47px;font-family:system-ui,-apple-system,BlinkMacSystemFont,'.SFNSText-Regular',sans-serif" x="50%" y="848.017" text-anchor="middle">${this._errorMessage}</text></svg></div>` : ''}</figure><slot name="controls"></slot></div>`;
|
|
256
258
|
this.shadow.adoptedStyleSheets = [
|
|
257
259
|
await DotLottiePlayerBase.styles()
|
|
258
260
|
];
|
|
@@ -634,7 +636,7 @@ const notImplemented = 'Method is not implemented';
|
|
|
634
636
|
* Player state.
|
|
635
637
|
*/ this.playerState = PlayerState.Loading, /**
|
|
636
638
|
* Animation Container.
|
|
637
|
-
*/ this._container = null, this._errorMessage = 'Something went wrong', this._identifier = this.id || createElementID(), /**
|
|
639
|
+
*/ this._container = null, this._DOMRect = null, this._errorMessage = 'Something went wrong', this._identifier = this.id || createElementID(), /**
|
|
638
640
|
* Whether settings toolbar is open.
|
|
639
641
|
*/ this._isSettingsOpen = false, this._playerState = {
|
|
640
642
|
count: 0,
|
|
@@ -823,6 +825,9 @@ const notImplemented = 'Method is not implemented';
|
|
|
823
825
|
if (typeof document.hidden !== 'undefined') {
|
|
824
826
|
document.addEventListener('visibilitychange', this._onVisibilityChange);
|
|
825
827
|
}
|
|
828
|
+
if (this._container) {
|
|
829
|
+
this._DOMRect = this._container.getBoundingClientRect();
|
|
830
|
+
}
|
|
826
831
|
// Add intersection observer for detecting component being out-of-view.
|
|
827
832
|
this._addIntersectionObserver();
|
|
828
833
|
this.dispatchEvent(new CustomEvent(PlayerEvents.Rendered));
|
|
@@ -1455,7 +1460,7 @@ const notImplemented = 'Method is not implemented';
|
|
|
1455
1460
|
/**
|
|
1456
1461
|
* Handle scroll.
|
|
1457
1462
|
*/ _handleScroll() {
|
|
1458
|
-
if (!this.animateOnScroll || !this._lottieInstance) {
|
|
1463
|
+
if (!this.animateOnScroll || !this._DOMRect || !this._lottieInstance) {
|
|
1459
1464
|
return;
|
|
1460
1465
|
}
|
|
1461
1466
|
if (isServer) {
|
|
@@ -1476,7 +1481,12 @@ const notImplemented = 'Method is not implemented';
|
|
|
1476
1481
|
if (scrollY <= this._playerState.scrollY) {
|
|
1477
1482
|
scrollPosition = this._playerState.scrollY - scrollY;
|
|
1478
1483
|
}
|
|
1479
|
-
const
|
|
1484
|
+
const { bottom, height, top } = this._DOMRect;
|
|
1485
|
+
let offset = height - bottom;
|
|
1486
|
+
if (top >= innerHeight) {
|
|
1487
|
+
offset = height;
|
|
1488
|
+
}
|
|
1489
|
+
const scrollProgress = scrollPosition / (innerHeight + offset), currentFrame = clamp(scrollProgress * (totalFrames - 1), 0, totalFrames);
|
|
1480
1490
|
requestAnimationFrame(()=>{
|
|
1481
1491
|
if (currentFrame >= totalFrames) {
|
|
1482
1492
|
this.playerState = PlayerState.Paused;
|
package/dist/full.d.ts
CHANGED
|
@@ -95,6 +95,7 @@ declare abstract class DotLottiePlayerBase extends PropertyCallbackElement {
|
|
|
95
95
|
set subframe(value: HTMLBooleanAttribute);
|
|
96
96
|
get subframe(): HTMLBooleanAttribute;
|
|
97
97
|
protected _container: HTMLElement | null;
|
|
98
|
+
protected _DOMRect: DOMRect | null;
|
|
98
99
|
protected _errorMessage: string;
|
|
99
100
|
protected _identifier: string;
|
|
100
101
|
protected _isSettingsOpen: boolean;
|
|
@@ -156,9 +157,9 @@ declare abstract class DotLottiePlayerBase extends PropertyCallbackElement {
|
|
|
156
157
|
protected _handleSeekChange({ target }: Event): void;
|
|
157
158
|
protected _handleSettingsClick({ target }: Event): void;
|
|
158
159
|
protected setOptions(_options: {
|
|
159
|
-
container?: HTMLElement;
|
|
160
|
+
container?: undefined | HTMLElement;
|
|
160
161
|
rendererType: RendererType;
|
|
161
|
-
initialSegment?: Vector2;
|
|
162
|
+
initialSegment?: undefined | Vector2;
|
|
162
163
|
hasAutoplay: boolean;
|
|
163
164
|
hasLoop: boolean;
|
|
164
165
|
preserveAspectRatio: PreserveAspectRatio;
|
|
@@ -189,9 +190,9 @@ declare class DotLottiePlayer extends DotLottiePlayerBase {
|
|
|
189
190
|
convert: typeof convert;
|
|
190
191
|
loadAnimation: typeof _aarsteinmedia_lottie_web.loadAnimation;
|
|
191
192
|
protected setOptions({ container, hasAutoplay, hasLoop, initialSegment, preserveAspectRatio, rendererType }: {
|
|
192
|
-
container?: HTMLElement;
|
|
193
|
+
container?: undefined | HTMLElement;
|
|
193
194
|
rendererType: RendererType;
|
|
194
|
-
initialSegment?: Vector2;
|
|
195
|
+
initialSegment?: undefined | Vector2;
|
|
195
196
|
hasAutoplay: boolean;
|
|
196
197
|
hasLoop: boolean;
|
|
197
198
|
preserveAspectRatio: PreserveAspectRatio;
|
package/dist/full.js
CHANGED
|
@@ -20,7 +20,7 @@ if (isServer) {
|
|
|
20
20
|
if (updateOnConnected in this) {
|
|
21
21
|
this[updateOnConnected] = [];
|
|
22
22
|
}
|
|
23
|
-
const { observedProperties
|
|
23
|
+
const { observedProperties } = this.constructor;
|
|
24
24
|
const { length } = observedProperties;
|
|
25
25
|
for(let i = 0; i < length; i++){
|
|
26
26
|
const initialValue = this[observedProperties[i]], cachedValue = Symbol(observedProperties[i]);
|
|
@@ -252,7 +252,9 @@ const pauseIcon = /* HTML */ `
|
|
|
252
252
|
if (!this.shadow || !this.template) {
|
|
253
253
|
throw new Error('No Shadow Element or Template');
|
|
254
254
|
}
|
|
255
|
-
this.template.innerHTML = /* HTML */ `<div class="animation-container main" data-controls="${this.controls ?? false}" lang="${this.description ? document.documentElement.lang : 'en'}"
|
|
255
|
+
this.template.innerHTML = /* HTML */ `<div class="animation-container main" data-controls="${this.controls ?? false}" lang="${this.description ? document.documentElement.lang : 'en'}" data-loaded="${this._playerState.loaded}"><figure class="animation" style="background:${this.background}" ${this.description ? /* HTML */ `
|
|
256
|
+
aria-label="${this.description}"
|
|
257
|
+
` : ''}>${this.playerState === PlayerState.Error ? /* HTML */ `<div class="error"><svg preserveAspectRatio="${PreserveAspectRatio.Cover}" xmlns="${namespaceSVG}" width="1920" height="1080" viewBox="0 0 1920 1080" style="white-space:preserve"><path fill="#fff" d="M0 0h1920v1080H0z"/><path fill="#3a6d8b" d="M1190.2 531 1007 212.4c-22-38.2-77.2-38-98.8.5L729.5 531.3c-21.3 37.9 6.1 84.6 49.5 84.6l361.9.3c43.7 0 71.1-47.3 49.3-85.2zM937.3 288.7c.2-7.5 3.3-23.9 23.2-23.9 16.3 0 23 16.1 23 23.5 0 55.3-10.7 197.2-12.2 214.5-.1 1-.9 1.7-1.9 1.7h-18.3c-1 0-1.8-.7-1.9-1.7-1.4-17.5-13.4-162.9-11.9-214.1zm24.2 283.8c-13.1 0-23.7-10.6-23.7-23.7s10.6-23.7 23.7-23.7 23.7 10.6 23.7 23.7-10.6 23.7-23.7 23.7zM722.1 644h112.6v34.4h-70.4V698h58.8v31.7h-58.8v22.6h72.4v36.2H722.1V644zm162 57.1h.6c8.3-12.9 18.2-17.8 31.3-17.8 3 0 5.1.4 6.3 1v32.6h-.8c-22.4-3.8-35.6 6.3-35.6 29.5v42.3h-38.2V685.5h36.4v15.6zm78.9 0h.6c8.3-12.9 18.2-17.8 31.3-17.8 3 0 5.1.4 6.3 1v32.6h-.8c-22.4-3.8-35.6 6.3-35.6 29.5v42.3h-38.2V685.5H963v15.6zm39.5 36.2c0-31.3 22.2-54.8 56.6-54.8 34.4 0 56.2 23.5 56.2 54.8s-21.8 54.6-56.2 54.6c-34.4-.1-56.6-23.3-56.6-54.6zm74 0c0-17.4-6.1-29.1-17.8-29.1-11.7 0-17.4 11.7-17.4 29.1 0 17.4 5.7 29.1 17.4 29.1s17.8-11.8 17.8-29.1zm83.1-36.2h.6c8.3-12.9 18.2-17.8 31.3-17.8 3 0 5.1.4 6.3 1v32.6h-.8c-22.4-3.8-35.6 6.3-35.6 29.5v42.3h-38.2V685.5h36.4v15.6z"/><path fill="none" d="M718.9 807.7h645v285.4h-645z"/><text fill="#3a6d8b" style="text-align:center;position:absolute;left:100%;font-size:47px;font-family:system-ui,-apple-system,BlinkMacSystemFont,'.SFNSText-Regular',sans-serif" x="50%" y="848.017" text-anchor="middle">${this._errorMessage}</text></svg></div>` : ''}</figure><slot name="controls"></slot></div>`;
|
|
256
258
|
this.shadow.adoptedStyleSheets = [
|
|
257
259
|
await DotLottiePlayerBase.styles()
|
|
258
260
|
];
|
|
@@ -634,7 +636,7 @@ const notImplemented = 'Method is not implemented';
|
|
|
634
636
|
* Player state.
|
|
635
637
|
*/ this.playerState = PlayerState.Loading, /**
|
|
636
638
|
* Animation Container.
|
|
637
|
-
*/ this._container = null, this._errorMessage = 'Something went wrong', this._identifier = this.id || createElementID(), /**
|
|
639
|
+
*/ this._container = null, this._DOMRect = null, this._errorMessage = 'Something went wrong', this._identifier = this.id || createElementID(), /**
|
|
638
640
|
* Whether settings toolbar is open.
|
|
639
641
|
*/ this._isSettingsOpen = false, this._playerState = {
|
|
640
642
|
count: 0,
|
|
@@ -823,6 +825,9 @@ const notImplemented = 'Method is not implemented';
|
|
|
823
825
|
if (typeof document.hidden !== 'undefined') {
|
|
824
826
|
document.addEventListener('visibilitychange', this._onVisibilityChange);
|
|
825
827
|
}
|
|
828
|
+
if (this._container) {
|
|
829
|
+
this._DOMRect = this._container.getBoundingClientRect();
|
|
830
|
+
}
|
|
826
831
|
// Add intersection observer for detecting component being out-of-view.
|
|
827
832
|
this._addIntersectionObserver();
|
|
828
833
|
this.dispatchEvent(new CustomEvent(PlayerEvents.Rendered));
|
|
@@ -1455,7 +1460,7 @@ const notImplemented = 'Method is not implemented';
|
|
|
1455
1460
|
/**
|
|
1456
1461
|
* Handle scroll.
|
|
1457
1462
|
*/ _handleScroll() {
|
|
1458
|
-
if (!this.animateOnScroll || !this._lottieInstance) {
|
|
1463
|
+
if (!this.animateOnScroll || !this._DOMRect || !this._lottieInstance) {
|
|
1459
1464
|
return;
|
|
1460
1465
|
}
|
|
1461
1466
|
if (isServer) {
|
|
@@ -1476,7 +1481,12 @@ const notImplemented = 'Method is not implemented';
|
|
|
1476
1481
|
if (scrollY <= this._playerState.scrollY) {
|
|
1477
1482
|
scrollPosition = this._playerState.scrollY - scrollY;
|
|
1478
1483
|
}
|
|
1479
|
-
const
|
|
1484
|
+
const { bottom, height, top } = this._DOMRect;
|
|
1485
|
+
let offset = height - bottom;
|
|
1486
|
+
if (top >= innerHeight) {
|
|
1487
|
+
offset = height;
|
|
1488
|
+
}
|
|
1489
|
+
const scrollProgress = scrollPosition / (innerHeight + offset), currentFrame = clamp(scrollProgress * (totalFrames - 1), 0, totalFrames);
|
|
1480
1490
|
requestAnimationFrame(()=>{
|
|
1481
1491
|
if (currentFrame >= totalFrames) {
|
|
1482
1492
|
this.playerState = PlayerState.Paused;
|
package/dist/light.d.ts
CHANGED
|
@@ -94,6 +94,7 @@ declare abstract class DotLottiePlayerBase extends PropertyCallbackElement {
|
|
|
94
94
|
set subframe(value: HTMLBooleanAttribute);
|
|
95
95
|
get subframe(): HTMLBooleanAttribute;
|
|
96
96
|
protected _container: HTMLElement | null;
|
|
97
|
+
protected _DOMRect: DOMRect | null;
|
|
97
98
|
protected _errorMessage: string;
|
|
98
99
|
protected _identifier: string;
|
|
99
100
|
protected _isSettingsOpen: boolean;
|
|
@@ -155,9 +156,9 @@ declare abstract class DotLottiePlayerBase extends PropertyCallbackElement {
|
|
|
155
156
|
protected _handleSeekChange({ target }: Event): void;
|
|
156
157
|
protected _handleSettingsClick({ target }: Event): void;
|
|
157
158
|
protected setOptions(_options: {
|
|
158
|
-
container?: HTMLElement;
|
|
159
|
+
container?: undefined | HTMLElement;
|
|
159
160
|
rendererType: RendererType;
|
|
160
|
-
initialSegment?: Vector2;
|
|
161
|
+
initialSegment?: undefined | Vector2;
|
|
161
162
|
hasAutoplay: boolean;
|
|
162
163
|
hasLoop: boolean;
|
|
163
164
|
preserveAspectRatio: PreserveAspectRatio;
|
package/dist/light.js
CHANGED
|
@@ -20,7 +20,7 @@ if (isServer) {
|
|
|
20
20
|
if (updateOnConnected in this) {
|
|
21
21
|
this[updateOnConnected] = [];
|
|
22
22
|
}
|
|
23
|
-
const { observedProperties
|
|
23
|
+
const { observedProperties } = this.constructor;
|
|
24
24
|
const { length } = observedProperties;
|
|
25
25
|
for(let i = 0; i < length; i++){
|
|
26
26
|
const initialValue = this[observedProperties[i]], cachedValue = Symbol(observedProperties[i]);
|
|
@@ -252,7 +252,9 @@ const pauseIcon = /* HTML */ `
|
|
|
252
252
|
if (!this.shadow || !this.template) {
|
|
253
253
|
throw new Error('No Shadow Element or Template');
|
|
254
254
|
}
|
|
255
|
-
this.template.innerHTML = /* HTML */ `<div class="animation-container main" data-controls="${this.controls ?? false}" lang="${this.description ? document.documentElement.lang : 'en'}"
|
|
255
|
+
this.template.innerHTML = /* HTML */ `<div class="animation-container main" data-controls="${this.controls ?? false}" lang="${this.description ? document.documentElement.lang : 'en'}" data-loaded="${this._playerState.loaded}"><figure class="animation" style="background:${this.background}" ${this.description ? /* HTML */ `
|
|
256
|
+
aria-label="${this.description}"
|
|
257
|
+
` : ''}>${this.playerState === PlayerState.Error ? /* HTML */ `<div class="error"><svg preserveAspectRatio="${PreserveAspectRatio.Cover}" xmlns="${namespaceSVG}" width="1920" height="1080" viewBox="0 0 1920 1080" style="white-space:preserve"><path fill="#fff" d="M0 0h1920v1080H0z"/><path fill="#3a6d8b" d="M1190.2 531 1007 212.4c-22-38.2-77.2-38-98.8.5L729.5 531.3c-21.3 37.9 6.1 84.6 49.5 84.6l361.9.3c43.7 0 71.1-47.3 49.3-85.2zM937.3 288.7c.2-7.5 3.3-23.9 23.2-23.9 16.3 0 23 16.1 23 23.5 0 55.3-10.7 197.2-12.2 214.5-.1 1-.9 1.7-1.9 1.7h-18.3c-1 0-1.8-.7-1.9-1.7-1.4-17.5-13.4-162.9-11.9-214.1zm24.2 283.8c-13.1 0-23.7-10.6-23.7-23.7s10.6-23.7 23.7-23.7 23.7 10.6 23.7 23.7-10.6 23.7-23.7 23.7zM722.1 644h112.6v34.4h-70.4V698h58.8v31.7h-58.8v22.6h72.4v36.2H722.1V644zm162 57.1h.6c8.3-12.9 18.2-17.8 31.3-17.8 3 0 5.1.4 6.3 1v32.6h-.8c-22.4-3.8-35.6 6.3-35.6 29.5v42.3h-38.2V685.5h36.4v15.6zm78.9 0h.6c8.3-12.9 18.2-17.8 31.3-17.8 3 0 5.1.4 6.3 1v32.6h-.8c-22.4-3.8-35.6 6.3-35.6 29.5v42.3h-38.2V685.5H963v15.6zm39.5 36.2c0-31.3 22.2-54.8 56.6-54.8 34.4 0 56.2 23.5 56.2 54.8s-21.8 54.6-56.2 54.6c-34.4-.1-56.6-23.3-56.6-54.6zm74 0c0-17.4-6.1-29.1-17.8-29.1-11.7 0-17.4 11.7-17.4 29.1 0 17.4 5.7 29.1 17.4 29.1s17.8-11.8 17.8-29.1zm83.1-36.2h.6c8.3-12.9 18.2-17.8 31.3-17.8 3 0 5.1.4 6.3 1v32.6h-.8c-22.4-3.8-35.6 6.3-35.6 29.5v42.3h-38.2V685.5h36.4v15.6z"/><path fill="none" d="M718.9 807.7h645v285.4h-645z"/><text fill="#3a6d8b" style="text-align:center;position:absolute;left:100%;font-size:47px;font-family:system-ui,-apple-system,BlinkMacSystemFont,'.SFNSText-Regular',sans-serif" x="50%" y="848.017" text-anchor="middle">${this._errorMessage}</text></svg></div>` : ''}</figure><slot name="controls"></slot></div>`;
|
|
256
258
|
this.shadow.adoptedStyleSheets = [
|
|
257
259
|
await DotLottiePlayerBase.styles()
|
|
258
260
|
];
|
|
@@ -634,7 +636,7 @@ const notImplemented = 'Method is not implemented';
|
|
|
634
636
|
* Player state.
|
|
635
637
|
*/ this.playerState = PlayerState.Loading, /**
|
|
636
638
|
* Animation Container.
|
|
637
|
-
*/ this._container = null, this._errorMessage = 'Something went wrong', this._identifier = this.id || createElementID(), /**
|
|
639
|
+
*/ this._container = null, this._DOMRect = null, this._errorMessage = 'Something went wrong', this._identifier = this.id || createElementID(), /**
|
|
638
640
|
* Whether settings toolbar is open.
|
|
639
641
|
*/ this._isSettingsOpen = false, this._playerState = {
|
|
640
642
|
count: 0,
|
|
@@ -823,6 +825,9 @@ const notImplemented = 'Method is not implemented';
|
|
|
823
825
|
if (typeof document.hidden !== 'undefined') {
|
|
824
826
|
document.addEventListener('visibilitychange', this._onVisibilityChange);
|
|
825
827
|
}
|
|
828
|
+
if (this._container) {
|
|
829
|
+
this._DOMRect = this._container.getBoundingClientRect();
|
|
830
|
+
}
|
|
826
831
|
// Add intersection observer for detecting component being out-of-view.
|
|
827
832
|
this._addIntersectionObserver();
|
|
828
833
|
this.dispatchEvent(new CustomEvent(PlayerEvents.Rendered));
|
|
@@ -1455,7 +1460,7 @@ const notImplemented = 'Method is not implemented';
|
|
|
1455
1460
|
/**
|
|
1456
1461
|
* Handle scroll.
|
|
1457
1462
|
*/ _handleScroll() {
|
|
1458
|
-
if (!this.animateOnScroll || !this._lottieInstance) {
|
|
1463
|
+
if (!this.animateOnScroll || !this._DOMRect || !this._lottieInstance) {
|
|
1459
1464
|
return;
|
|
1460
1465
|
}
|
|
1461
1466
|
if (isServer) {
|
|
@@ -1476,7 +1481,12 @@ const notImplemented = 'Method is not implemented';
|
|
|
1476
1481
|
if (scrollY <= this._playerState.scrollY) {
|
|
1477
1482
|
scrollPosition = this._playerState.scrollY - scrollY;
|
|
1478
1483
|
}
|
|
1479
|
-
const
|
|
1484
|
+
const { bottom, height, top } = this._DOMRect;
|
|
1485
|
+
let offset = height - bottom;
|
|
1486
|
+
if (top >= innerHeight) {
|
|
1487
|
+
offset = height;
|
|
1488
|
+
}
|
|
1489
|
+
const scrollProgress = scrollPosition / (innerHeight + offset), currentFrame = clamp(scrollProgress * (totalFrames - 1), 0, totalFrames);
|
|
1480
1490
|
requestAnimationFrame(()=>{
|
|
1481
1491
|
if (currentFrame >= totalFrames) {
|
|
1482
1492
|
this.playerState = PlayerState.Paused;
|
package/dist/svg.d.ts
CHANGED
|
@@ -94,6 +94,7 @@ declare abstract class DotLottiePlayerBase extends PropertyCallbackElement {
|
|
|
94
94
|
set subframe(value: HTMLBooleanAttribute);
|
|
95
95
|
get subframe(): HTMLBooleanAttribute;
|
|
96
96
|
protected _container: HTMLElement | null;
|
|
97
|
+
protected _DOMRect: DOMRect | null;
|
|
97
98
|
protected _errorMessage: string;
|
|
98
99
|
protected _identifier: string;
|
|
99
100
|
protected _isSettingsOpen: boolean;
|
|
@@ -155,9 +156,9 @@ declare abstract class DotLottiePlayerBase extends PropertyCallbackElement {
|
|
|
155
156
|
protected _handleSeekChange({ target }: Event): void;
|
|
156
157
|
protected _handleSettingsClick({ target }: Event): void;
|
|
157
158
|
protected setOptions(_options: {
|
|
158
|
-
container?: HTMLElement;
|
|
159
|
+
container?: undefined | HTMLElement;
|
|
159
160
|
rendererType: RendererType;
|
|
160
|
-
initialSegment?: Vector2;
|
|
161
|
+
initialSegment?: undefined | Vector2;
|
|
161
162
|
hasAutoplay: boolean;
|
|
162
163
|
hasLoop: boolean;
|
|
163
164
|
preserveAspectRatio: PreserveAspectRatio;
|
|
@@ -188,9 +189,9 @@ declare class DotLottiePlayerSVG extends DotLottiePlayerBase {
|
|
|
188
189
|
get renderer(): RendererType;
|
|
189
190
|
constructor();
|
|
190
191
|
protected setOptions({ container, hasAutoplay, hasLoop, initialSegment, preserveAspectRatio, }: {
|
|
191
|
-
container?: HTMLElement;
|
|
192
|
+
container?: undefined | HTMLElement;
|
|
192
193
|
rendererType: RendererType;
|
|
193
|
-
initialSegment?: Vector2;
|
|
194
|
+
initialSegment?: undefined | Vector2;
|
|
194
195
|
hasAutoplay: boolean;
|
|
195
196
|
hasLoop: boolean;
|
|
196
197
|
preserveAspectRatio: PreserveAspectRatio;
|
package/dist/svg.js
CHANGED
|
@@ -20,7 +20,7 @@ if (isServer) {
|
|
|
20
20
|
if (updateOnConnected in this) {
|
|
21
21
|
this[updateOnConnected] = [];
|
|
22
22
|
}
|
|
23
|
-
const { observedProperties
|
|
23
|
+
const { observedProperties } = this.constructor;
|
|
24
24
|
const { length } = observedProperties;
|
|
25
25
|
for(let i = 0; i < length; i++){
|
|
26
26
|
const initialValue = this[observedProperties[i]], cachedValue = Symbol(observedProperties[i]);
|
|
@@ -252,7 +252,9 @@ const pauseIcon = /* HTML */ `
|
|
|
252
252
|
if (!this.shadow || !this.template) {
|
|
253
253
|
throw new Error('No Shadow Element or Template');
|
|
254
254
|
}
|
|
255
|
-
this.template.innerHTML = /* HTML */ `<div class="animation-container main" data-controls="${this.controls ?? false}" lang="${this.description ? document.documentElement.lang : 'en'}"
|
|
255
|
+
this.template.innerHTML = /* HTML */ `<div class="animation-container main" data-controls="${this.controls ?? false}" lang="${this.description ? document.documentElement.lang : 'en'}" data-loaded="${this._playerState.loaded}"><figure class="animation" style="background:${this.background}" ${this.description ? /* HTML */ `
|
|
256
|
+
aria-label="${this.description}"
|
|
257
|
+
` : ''}>${this.playerState === PlayerState.Error ? /* HTML */ `<div class="error"><svg preserveAspectRatio="${PreserveAspectRatio.Cover}" xmlns="${namespaceSVG}" width="1920" height="1080" viewBox="0 0 1920 1080" style="white-space:preserve"><path fill="#fff" d="M0 0h1920v1080H0z"/><path fill="#3a6d8b" d="M1190.2 531 1007 212.4c-22-38.2-77.2-38-98.8.5L729.5 531.3c-21.3 37.9 6.1 84.6 49.5 84.6l361.9.3c43.7 0 71.1-47.3 49.3-85.2zM937.3 288.7c.2-7.5 3.3-23.9 23.2-23.9 16.3 0 23 16.1 23 23.5 0 55.3-10.7 197.2-12.2 214.5-.1 1-.9 1.7-1.9 1.7h-18.3c-1 0-1.8-.7-1.9-1.7-1.4-17.5-13.4-162.9-11.9-214.1zm24.2 283.8c-13.1 0-23.7-10.6-23.7-23.7s10.6-23.7 23.7-23.7 23.7 10.6 23.7 23.7-10.6 23.7-23.7 23.7zM722.1 644h112.6v34.4h-70.4V698h58.8v31.7h-58.8v22.6h72.4v36.2H722.1V644zm162 57.1h.6c8.3-12.9 18.2-17.8 31.3-17.8 3 0 5.1.4 6.3 1v32.6h-.8c-22.4-3.8-35.6 6.3-35.6 29.5v42.3h-38.2V685.5h36.4v15.6zm78.9 0h.6c8.3-12.9 18.2-17.8 31.3-17.8 3 0 5.1.4 6.3 1v32.6h-.8c-22.4-3.8-35.6 6.3-35.6 29.5v42.3h-38.2V685.5H963v15.6zm39.5 36.2c0-31.3 22.2-54.8 56.6-54.8 34.4 0 56.2 23.5 56.2 54.8s-21.8 54.6-56.2 54.6c-34.4-.1-56.6-23.3-56.6-54.6zm74 0c0-17.4-6.1-29.1-17.8-29.1-11.7 0-17.4 11.7-17.4 29.1 0 17.4 5.7 29.1 17.4 29.1s17.8-11.8 17.8-29.1zm83.1-36.2h.6c8.3-12.9 18.2-17.8 31.3-17.8 3 0 5.1.4 6.3 1v32.6h-.8c-22.4-3.8-35.6 6.3-35.6 29.5v42.3h-38.2V685.5h36.4v15.6z"/><path fill="none" d="M718.9 807.7h645v285.4h-645z"/><text fill="#3a6d8b" style="text-align:center;position:absolute;left:100%;font-size:47px;font-family:system-ui,-apple-system,BlinkMacSystemFont,'.SFNSText-Regular',sans-serif" x="50%" y="848.017" text-anchor="middle">${this._errorMessage}</text></svg></div>` : ''}</figure><slot name="controls"></slot></div>`;
|
|
256
258
|
this.shadow.adoptedStyleSheets = [
|
|
257
259
|
await DotLottiePlayerBase.styles()
|
|
258
260
|
];
|
|
@@ -634,7 +636,7 @@ const notImplemented = 'Method is not implemented';
|
|
|
634
636
|
* Player state.
|
|
635
637
|
*/ this.playerState = PlayerState.Loading, /**
|
|
636
638
|
* Animation Container.
|
|
637
|
-
*/ this._container = null, this._errorMessage = 'Something went wrong', this._identifier = this.id || createElementID(), /**
|
|
639
|
+
*/ this._container = null, this._DOMRect = null, this._errorMessage = 'Something went wrong', this._identifier = this.id || createElementID(), /**
|
|
638
640
|
* Whether settings toolbar is open.
|
|
639
641
|
*/ this._isSettingsOpen = false, this._playerState = {
|
|
640
642
|
count: 0,
|
|
@@ -823,6 +825,9 @@ const notImplemented = 'Method is not implemented';
|
|
|
823
825
|
if (typeof document.hidden !== 'undefined') {
|
|
824
826
|
document.addEventListener('visibilitychange', this._onVisibilityChange);
|
|
825
827
|
}
|
|
828
|
+
if (this._container) {
|
|
829
|
+
this._DOMRect = this._container.getBoundingClientRect();
|
|
830
|
+
}
|
|
826
831
|
// Add intersection observer for detecting component being out-of-view.
|
|
827
832
|
this._addIntersectionObserver();
|
|
828
833
|
this.dispatchEvent(new CustomEvent(PlayerEvents.Rendered));
|
|
@@ -1455,7 +1460,7 @@ const notImplemented = 'Method is not implemented';
|
|
|
1455
1460
|
/**
|
|
1456
1461
|
* Handle scroll.
|
|
1457
1462
|
*/ _handleScroll() {
|
|
1458
|
-
if (!this.animateOnScroll || !this._lottieInstance) {
|
|
1463
|
+
if (!this.animateOnScroll || !this._DOMRect || !this._lottieInstance) {
|
|
1459
1464
|
return;
|
|
1460
1465
|
}
|
|
1461
1466
|
if (isServer) {
|
|
@@ -1476,7 +1481,12 @@ const notImplemented = 'Method is not implemented';
|
|
|
1476
1481
|
if (scrollY <= this._playerState.scrollY) {
|
|
1477
1482
|
scrollPosition = this._playerState.scrollY - scrollY;
|
|
1478
1483
|
}
|
|
1479
|
-
const
|
|
1484
|
+
const { bottom, height, top } = this._DOMRect;
|
|
1485
|
+
let offset = height - bottom;
|
|
1486
|
+
if (top >= innerHeight) {
|
|
1487
|
+
offset = height;
|
|
1488
|
+
}
|
|
1489
|
+
const scrollProgress = scrollPosition / (innerHeight + offset), currentFrame = clamp(scrollProgress * (totalFrames - 1), 0, totalFrames);
|
|
1480
1490
|
requestAnimationFrame(()=>{
|
|
1481
1491
|
if (currentFrame >= totalFrames) {
|
|
1482
1492
|
this.playerState = PlayerState.Paused;
|