@aarsteinmedia/dotlottie-player 5.3.1 → 6.0.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.
@@ -1,7 +1,35 @@
1
- import { PlayMode, PreserveAspectRatio, RendererType } from '@aarsteinmedia/lottie-web/utils';
1
+ import { RendererType, PreserveAspectRatio, PlayMode } from '@aarsteinmedia/lottie-web/utils';
2
2
  export { PlayMode, PlayerEvents } from '@aarsteinmedia/lottie-web/utils';
3
- import { AnimationDirection, AnimationItem, LottieManifest, AnimationSettings, Vector2 } from '@aarsteinmedia/lottie-web';
3
+ import * as _aarsteinmedia_lottie_web from '@aarsteinmedia/lottie-web';
4
+ import { Vector2, AnimationConfiguration, AnimationData, AnimationDirection, AddAnimationParams, Result, ConvertParams, AnimationItem, LottieManifest, AnimationSettings } from '@aarsteinmedia/lottie-web';
4
5
  import { addAnimation, convert } from '@aarsteinmedia/lottie-web/dotlottie';
6
+ import * as _aarsteinmedia_lottie_web_light from '@aarsteinmedia/lottie-web/light';
7
+
8
+ declare class DotLottiePlayerLight extends DotLottiePlayerBase {
9
+ loadAnimation: typeof _aarsteinmedia_lottie_web_light.loadAnimation;
10
+ get renderer(): RendererType;
11
+ constructor();
12
+ protected setOptions({ container, hasAutoplay, hasLoop, initialSegment, preserveAspectRatio, }: {
13
+ container?: HTMLElement;
14
+ rendererType: RendererType;
15
+ initialSegment?: Vector2;
16
+ hasAutoplay: boolean;
17
+ hasLoop: boolean;
18
+ preserveAspectRatio: PreserveAspectRatio;
19
+ }): AnimationConfiguration<RendererType.SVG>;
20
+ }
21
+
22
+ declare enum PlayerState {
23
+ Completed = "completed",
24
+ Destroyed = "destroyed",
25
+ Error = "error",
26
+ Frozen = "frozen",
27
+ Loading = "loading",
28
+ Paused = "paused",
29
+ Playing = "playing",
30
+ Stopped = "stopped"
31
+ }
32
+ declare const tagName = "dotlottie-player";
5
33
 
6
34
  type AnimateOnScroll = boolean | '' | null;
7
35
  type Autoplay = boolean | '' | 'autoplay' | null;
@@ -10,11 +38,11 @@ type Loop = boolean | '' | 'loop' | null;
10
38
  type Subframe = boolean | '' | null;
11
39
  declare global {
12
40
  interface HTMLElementTagNameMap {
13
- [tagName]: DotLottiePlayer;
41
+ [tagName]: DotLottiePlayer | DotLottiePlayerLight;
14
42
  }
15
- function dotLottiePlayer(): DotLottiePlayer;
43
+ function dotLottiePlayer(): DotLottiePlayer | DotLottiePlayerLight;
16
44
  }
17
- type JSXLottiePlayer = Omit<Partial<DotLottiePlayer>, 'style'> & {
45
+ type JSXLottiePlayer = Omit<Partial<DotLottiePlayer | DotLottiePlayerLight>, 'style'> & {
18
46
  class?: string;
19
47
  ref?: React.RefObject<unknown>;
20
48
  style?: React.CSSProperties;
@@ -48,33 +76,22 @@ declare abstract class PropertyCallbackElement extends HTMLElement {
48
76
  propertyChangedCallback(_name: string, _oldValue: unknown, _value: unknown): void;
49
77
  }
50
78
 
51
- declare function renderControls(this: DotLottiePlayer): void;
79
+ declare function renderControls(this: DotLottiePlayerBase): void;
52
80
 
53
- declare function renderPlayer(this: DotLottiePlayer): Promise<void>;
81
+ declare function renderPlayer(this: DotLottiePlayerBase): Promise<void>;
54
82
 
55
- declare enum PlayerState {
56
- Completed = "completed",
57
- Destroyed = "destroyed",
58
- Error = "error",
59
- Frozen = "frozen",
60
- Loading = "loading",
61
- Paused = "paused",
62
- Playing = "playing",
63
- Stopped = "stopped"
64
- }
65
-
66
- declare class DotLottiePlayer extends PropertyCallbackElement {
83
+ declare abstract class DotLottiePlayerBase extends PropertyCallbackElement {
67
84
  static get observedAttributes(): string[];
68
85
  static get observedProperties(): string[];
69
86
  static get styles(): () => Promise<CSSStyleSheet>;
70
- addAnimation: typeof addAnimation;
71
- convert: typeof convert;
87
+ isLight: boolean;
72
88
  playerState: PlayerState;
73
89
  shadow: ShadowRoot | undefined;
74
90
  source?: string;
75
- template: HTMLTemplateElement;
91
+ template?: HTMLTemplateElement;
76
92
  set animateOnScroll(value: AnimateOnScroll);
77
93
  get animateOnScroll(): AnimateOnScroll;
94
+ get animations(): AnimationData[];
78
95
  set autoplay(value: Autoplay);
79
96
  get autoplay(): Autoplay;
80
97
  set background(value: string);
@@ -83,6 +100,7 @@ declare class DotLottiePlayer extends PropertyCallbackElement {
83
100
  get controls(): Controls;
84
101
  set count(value: number);
85
102
  get count(): number;
103
+ get currentAnimation(): number;
86
104
  set description(value: string | null);
87
105
  get description(): string | null;
88
106
  set direction(value: AnimationDirection);
@@ -135,8 +153,10 @@ declare class DotLottiePlayer extends PropertyCallbackElement {
135
153
  private _multiAnimationSettings;
136
154
  private _segment?;
137
155
  constructor();
156
+ addAnimation(_params: AddAnimationParams): Promise<Result>;
138
157
  attributeChangedCallback(name: string, _oldValue: unknown, value: string): Promise<void>;
139
158
  connectedCallback(): void;
159
+ convert(_params: ConvertParams): Promise<Result>;
140
160
  destroy(): void;
141
161
  disconnectedCallback(): void;
142
162
  getLottie(): AnimationItem | null;
@@ -144,6 +164,7 @@ declare class DotLottiePlayer extends PropertyCallbackElement {
144
164
  getMultiAnimationSettings(): AnimationSettings[];
145
165
  getSegment(): Vector2 | undefined;
146
166
  load(src: string | null): Promise<void>;
167
+ loadAnimation(_config: AnimationConfiguration): AnimationItem;
147
168
  next(): void;
148
169
  pause(): void;
149
170
  play(): void;
@@ -167,6 +188,14 @@ declare class DotLottiePlayer extends PropertyCallbackElement {
167
188
  protected _handleBlur(): void;
168
189
  protected _handleSeekChange({ target }: Event): void;
169
190
  protected _handleSettingsClick({ target }: Event): void;
191
+ protected setOptions(_options: {
192
+ container?: HTMLElement;
193
+ rendererType: RendererType;
194
+ initialSegment?: Vector2;
195
+ hasAutoplay: boolean;
196
+ hasLoop: boolean;
197
+ preserveAspectRatio: PreserveAspectRatio;
198
+ }): AnimationConfiguration<RendererType.SVG | RendererType.Canvas | RendererType.HTML>;
170
199
  private _addEventListeners;
171
200
  private _addIntersectionObserver;
172
201
  private _complete;
@@ -188,6 +217,18 @@ declare class DotLottiePlayer extends PropertyCallbackElement {
188
217
  private _toggleSettings;
189
218
  }
190
219
 
191
- declare const tagName = "dotlottie-player";
220
+ declare class DotLottiePlayer extends DotLottiePlayerBase {
221
+ addAnimation: typeof addAnimation;
222
+ convert: typeof convert;
223
+ loadAnimation: typeof _aarsteinmedia_lottie_web.loadAnimation;
224
+ protected setOptions({ container, hasAutoplay, hasLoop, initialSegment, preserveAspectRatio, rendererType }: {
225
+ container?: HTMLElement;
226
+ rendererType: RendererType;
227
+ initialSegment?: Vector2;
228
+ hasAutoplay: boolean;
229
+ hasLoop: boolean;
230
+ preserveAspectRatio: PreserveAspectRatio;
231
+ }): AnimationConfiguration<RendererType>;
232
+ }
192
233
 
193
234
  export { PlayerState, DotLottiePlayer as default, tagName };
@@ -1,7 +1,7 @@
1
1
  import { isServer, PlayMode, PreserveAspectRatio, namespaceSVG, RendererType, createElementID, PlayerEvents, download, getFilename } from '@aarsteinmedia/lottie-web/utils';
2
2
  export { PlayMode, PlayerEvents } from '@aarsteinmedia/lottie-web/utils';
3
3
  import Lottie from '@aarsteinmedia/lottie-web';
4
- import { convert, addAnimation, getAnimationData } from '@aarsteinmedia/lottie-web/dotlottie';
4
+ import { convert, getAnimationData, addAnimation } from '@aarsteinmedia/lottie-web/dotlottie';
5
5
 
6
6
  /**
7
7
  * Credit to: Leonardo Favre https://github.com/leofavre/observed-properties.
@@ -156,6 +156,7 @@ var PlayerState = /*#__PURE__*/ function(PlayerState) {
156
156
  PlayerState["Stopped"] = "stopped";
157
157
  return PlayerState;
158
158
  }({});
159
+ const tagName = 'dotlottie-player';
159
160
 
160
161
  /**
161
162
  * Render Controls.
@@ -171,22 +172,28 @@ var PlayerState = /*#__PURE__*/ function(PlayerState) {
171
172
  slot.innerHTML = '';
172
173
  return;
173
174
  }
174
- slot.innerHTML = /* HTML */ `<div class="lottie-controls toolbar ${this.playerState === PlayerState.Error ? 'has-error' : ''}" aria-label="Lottie Animation controls"><button class="togglePlay" data-active="${this.autoplay}" aria-label="Toggle Play/Pause">${playIcon}</button> <button class="stop" data-active="${!this.autoplay}" aria-label="Stop">${stopIcon}</button> <button class="prev" aria-label="Previous animation" hidden>${prevIcon}</button> <button class="next" aria-label="Next animation" hidden>${nextIcon}</button><form class="progress-container${this.simple ? ' simple' : ''}"><input type="range" class="seeker" min="0" max="100" step="1" value="${this._seeker.toString()}" aria-valuemin="0" aria-valuemax="100" aria-valuenow="${this._seeker.toString()}" tabindex="0" aria-label="Slider for search"><progress max="100" value="${this._seeker}"></progress></form>${this.simple ? '' : /* HTML */ `<button class="toggleLoop" data-active="${this.loop}" tabindex="0" aria-label="Toggle loop">${loopIcon}</button> <button class="toggleBoomerang" data-active="${this.mode === PlayMode.Bounce}" aria-label="Toggle boomerang" tabindex="0">${boomerangIcon}</button> <button class="toggleSettings" aria-label="Settings" aria-haspopup="true" aria-expanded="${Boolean(this._isSettingsOpen)}" aria-controls="${this._identifier}-settings">${settingsIcon}</button><div id="${this._identifier}-settings" class="popover" hidden><button class="convert" aria-label="Convert JSON animation to dotLottie format" aria-label="Convert ${this.isDotLottie ? 'dotLottie animation to JSON format' : 'JSON animation to dotLottie format'}" hidden>${convertIcon} ${this.isDotLottie ? 'Convert to JSON' : 'Convert to dotLottie'}</button> <button class="snapshot" aria-label="Download still image">${downloadIcon} Download still image</button></div>`}</div>`;
175
+ slot.innerHTML = /* HTML */ `<div class="lottie-controls toolbar ${this.playerState === PlayerState.Error ? 'has-error' : ''}" aria-label="Lottie Animation controls"><button class="togglePlay" data-active="${this.autoplay}" aria-label="Toggle Play/Pause">${playIcon}</button> <button class="stop" data-active="${!this.autoplay}" aria-label="Stop">${stopIcon}</button> <button class="prev" aria-label="Previous animation" hidden="false">${prevIcon}</button> <button class="next" aria-label="Next animation" hidden>${nextIcon}</button><form class="progress-container${this.simple ? ' simple' : ''}"><input type="range" class="seeker" min="0" max="100" step="1" value="${this._seeker.toString()}" aria-valuemin="0" aria-valuemax="100" aria-valuenow="${this._seeker.toString()}" tabindex="0" aria-label="Slider for search"><progress max="100" value="${this._seeker}"></progress></form>${this.simple ? '' : /* HTML */ `<button class="toggleLoop" data-active="${this.loop}" tabindex="0" aria-label="Toggle loop">${loopIcon}</button> <button class="toggleBoomerang" data-active="${this.mode === PlayMode.Bounce}" aria-label="Toggle boomerang" tabindex="0">${boomerangIcon}</button> <button class="toggleSettings" aria-label="Settings" aria-haspopup="true" aria-expanded="${Boolean(this._isSettingsOpen)}" aria-controls="${this._identifier}-settings">${settingsIcon}</button><div id="${this._identifier}-settings" class="popover" hidden><button class="convert" aria-label="Convert JSON animation to dotLottie format" aria-label="Convert ${this.isDotLottie ? 'dotLottie animation to JSON format' : 'JSON animation to dotLottie format'}" hidden>${convertIcon} ${this.isDotLottie ? 'Convert to JSON' : 'Convert to dotLottie'}</button> <button class="snapshot" aria-label="Download still image">${downloadIcon} Download still image</button></div>`}</div>`;
175
176
  const togglePlay = this.shadow.querySelector('.togglePlay');
176
177
  if (togglePlay instanceof HTMLButtonElement) {
177
178
  togglePlay.onclick = this.togglePlay;
178
179
  }
179
- const stop = this.shadow.querySelector('.stop');
180
- if (stop instanceof HTMLButtonElement) {
181
- stop.onclick = this.stop;
180
+ const stopButton = this.shadow.querySelector('.stop');
181
+ if (stopButton instanceof HTMLButtonElement) {
182
+ stopButton.onclick = this.stop;
182
183
  }
183
- const prev = this.shadow.querySelector('.prev');
184
- if (prev instanceof HTMLButtonElement) {
185
- prev.onclick = this.prev;
184
+ const prevButton = this.shadow.querySelector('.prev');
185
+ if (prevButton instanceof HTMLButtonElement) {
186
+ if (this.animations.length > 0 && this.currentAnimation) {
187
+ prevButton.hidden = false;
188
+ }
189
+ prevButton.onclick = this.prev;
186
190
  }
187
- const next = this.shadow.querySelector('.next');
188
- if (next instanceof HTMLButtonElement) {
189
- next.onclick = this.next;
191
+ const nextButton = this.shadow.querySelector('.next');
192
+ if (nextButton instanceof HTMLButtonElement) {
193
+ if (this.animations.length > 0 && this.currentAnimation < this.animations.length - 1) {
194
+ nextButton.hidden = false;
195
+ }
196
+ nextButton.onclick = this.next;
190
197
  }
191
198
  const seeker = this.shadow.querySelector('.seeker');
192
199
  if (seeker instanceof HTMLInputElement) {
@@ -235,12 +242,12 @@ const pauseIcon = /* HTML */ `
235
242
  /**
236
243
  * Render Player.
237
244
  */ async function renderPlayer() {
238
- if (!this.shadow) {
239
- throw new Error('No Shadow Element');
245
+ if (!this.shadow || !this.template) {
246
+ throw new Error('No Shadow Element or Template');
240
247
  }
241
248
  this.template.innerHTML = /* HTML */ `<div class="animation-container main" data-controls="${this.controls ?? false}" lang="${this.description ? document.documentElement.lang : 'en'}" aria-label="${this.description ?? 'Lottie animation'}" data-loaded="${this._playerState.loaded}"><figure class="animation" style="background:${this.background}">${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>`;
242
249
  this.shadow.adoptedStyleSheets = [
243
- await DotLottiePlayer.styles()
250
+ await DotLottiePlayerBase.styles()
244
251
  ];
245
252
  this.shadow.appendChild(this.template.content.cloneNode(true));
246
253
  }
@@ -287,9 +294,10 @@ const pauseIcon = /* HTML */ `
287
294
  return res;
288
295
  }, frameOutput = (frame)=>((frame ?? 0) + 1).toString().padStart(3, '0');
289
296
 
297
+ const notImplemented = 'Method is not implemented';
290
298
  /**
291
299
  * DotLottie Player Web Component.
292
- */ class DotLottiePlayer extends PropertyCallbackElement {
300
+ */ class DotLottiePlayerBase extends PropertyCallbackElement {
293
301
  /**
294
302
  * Attributes to observe.
295
303
  */ static get observedAttributes() {
@@ -333,6 +341,9 @@ const pauseIcon = /* HTML */ `
333
341
  const val = this.getAttribute('animateOnScroll');
334
342
  return Boolean(val === 'true' || val === '' || val === '1');
335
343
  }
344
+ get animations() {
345
+ return this._animations;
346
+ }
336
347
  /**
337
348
  * Autoplay.
338
349
  */ set autoplay(value) {
@@ -371,6 +382,9 @@ const pauseIcon = /* HTML */ `
371
382
  }
372
383
  return 0;
373
384
  }
385
+ get currentAnimation() {
386
+ return this._currentAnimation;
387
+ }
374
388
  /**
375
389
  * Description for screen readers.
376
390
  */ set description(value) {
@@ -513,7 +527,7 @@ const pauseIcon = /* HTML */ `
513
527
  return Boolean(val === 'true' || val === '' || val === '1');
514
528
  }
515
529
  constructor(){
516
- super(), this.addAnimation = addAnimation, this.convert = convert, /**
530
+ super(), this.isLight = false, /**
517
531
  * Player state.
518
532
  */ this.playerState = PlayerState.Loading, /**
519
533
  * Animation Container.
@@ -567,6 +581,9 @@ const pauseIcon = /* HTML */ `
567
581
  mode: 'open'
568
582
  });
569
583
  }
584
+ addAnimation(_params) {
585
+ throw new Error(notImplemented);
586
+ }
570
587
  /**
571
588
  * Runs when the value of an attribute is changed on the component.
572
589
  */ async attributeChangedCallback(name, _oldValue, value) {
@@ -666,6 +683,9 @@ const pauseIcon = /* HTML */ `
666
683
  this.dispatchEvent(new CustomEvent(PlayerEvents.Error));
667
684
  }
668
685
  }
686
+ convert(_params) {
687
+ throw new Error(notImplemented);
688
+ }
669
689
  /**
670
690
  * Destroy animation and element.
671
691
  */ destroy() {
@@ -754,7 +774,7 @@ const pauseIcon = /* HTML */ `
754
774
  this.playerState = PlayerState.Playing;
755
775
  }
756
776
  // Initialize lottie player and load animation
757
- this._lottieInstance = Lottie.loadAnimation({
777
+ this._lottieInstance = this.loadAnimation({
758
778
  ...this._getOptions(),
759
779
  animationData: animations[this._currentAnimation]
760
780
  });
@@ -791,6 +811,9 @@ const pauseIcon = /* HTML */ `
791
811
  this.dispatchEvent(new CustomEvent(PlayerEvents.Error));
792
812
  }
793
813
  }
814
+ loadAnimation(_config) {
815
+ throw new Error(notImplemented);
816
+ }
794
817
  /**
795
818
  * Skip to next animation.
796
819
  */ next() {
@@ -837,13 +860,13 @@ const pauseIcon = /* HTML */ `
837
860
  if (!this.shadow) {
838
861
  return;
839
862
  }
840
- const togglePlay = this.shadow.querySelector('.togglePlay'), stop = this.shadow.querySelector('.stop'), prev = this.shadow.querySelector('.prev'), next = this.shadow.querySelector('.next'), seeker = this.shadow.querySelector('.seeker'), progress = this.shadow.querySelector('progress'), popover = this.shadow.querySelector('.popover'), convertButton = this.shadow.querySelector('.convert'), snapshot = this.shadow.querySelector('.snapshot');
841
- if (!(togglePlay instanceof HTMLButtonElement) || !(stop instanceof HTMLButtonElement) || !(next instanceof HTMLButtonElement) || !(prev instanceof HTMLButtonElement) || !(seeker instanceof HTMLInputElement) || !(progress instanceof HTMLProgressElement)) {
863
+ const togglePlay = this.shadow.querySelector('.togglePlay'), stopButton = this.shadow.querySelector('.stop'), prevButton = this.shadow.querySelector('.prev'), nextButton = this.shadow.querySelector('.next'), seeker = this.shadow.querySelector('.seeker'), progress = this.shadow.querySelector('progress'), popover = this.shadow.querySelector('.popover'), convertButton = this.shadow.querySelector('.convert'), snapshot = this.shadow.querySelector('.snapshot');
864
+ if (!(togglePlay instanceof HTMLButtonElement) || !(stopButton instanceof HTMLButtonElement) || !(nextButton instanceof HTMLButtonElement) || !(prevButton instanceof HTMLButtonElement) || !(seeker instanceof HTMLInputElement) || !(progress instanceof HTMLProgressElement)) {
842
865
  return;
843
866
  }
844
867
  if (name === 'playerState') {
845
868
  togglePlay.dataset.active = (value === PlayerState.Playing || value === PlayerState.Paused).toString();
846
- stop.dataset.active = (value === PlayerState.Stopped).toString();
869
+ stopButton.dataset.active = (value === PlayerState.Stopped).toString();
847
870
  if (value === PlayerState.Playing) {
848
871
  togglePlay.innerHTML = pauseIcon;
849
872
  } else {
@@ -856,15 +879,15 @@ const pauseIcon = /* HTML */ `
856
879
  progress.value = value;
857
880
  }
858
881
  if (name === '_animations' && Array.isArray(value) && this._currentAnimation + 1 < value.length) {
859
- next.hidden = false;
882
+ nextButton.hidden = false;
860
883
  }
861
884
  if (name === '_currentAnimation' && typeof value === 'number') {
862
- next.hidden = value + 1 >= this._animations.length;
863
- prev.hidden = !value;
885
+ nextButton.hidden = value + 1 >= this._animations.length;
886
+ prevButton.hidden = !value;
864
887
  }
865
888
  if (name === '_isSettingsOpen' && typeof value === 'boolean' && popover instanceof HTMLDivElement && convertButton instanceof HTMLButtonElement && snapshot instanceof HTMLButtonElement) {
866
889
  popover.hidden = !value;
867
- convertButton.hidden = false;
890
+ convertButton.hidden = this.isLight;
868
891
  snapshot.hidden = this.renderer !== RendererType.SVG;
869
892
  }
870
893
  }
@@ -1096,6 +1119,9 @@ const pauseIcon = /* HTML */ `
1096
1119
  target.focus();
1097
1120
  }
1098
1121
  }
1122
+ setOptions(_options) {
1123
+ throw new Error('Method not implemented');
1124
+ }
1099
1125
  /**
1100
1126
  * Add event listeners.
1101
1127
  */ _addEventListeners() {
@@ -1179,7 +1205,6 @@ const pauseIcon = /* HTML */ `
1179
1205
  }
1180
1206
  /**
1181
1207
  * Get options from props.
1182
- *
1183
1208
  */ _getOptions() {
1184
1209
  if (!this._container) {
1185
1210
  throw new Error('Container not rendered');
@@ -1215,47 +1240,14 @@ const pauseIcon = /* HTML */ `
1215
1240
  if (this._segment?.some((val)=>val < 0)) {
1216
1241
  initialSegment = undefined;
1217
1242
  }
1218
- const options = {
1219
- autoplay: hasAutoplay,
1243
+ return this.setOptions({
1220
1244
  container: this._container,
1245
+ hasAutoplay,
1246
+ hasLoop,
1221
1247
  initialSegment,
1222
- loop: hasLoop,
1223
- renderer: this.renderer,
1224
- rendererSettings: {
1225
- imagePreserveAspectRatio: preserveAspectRatio
1226
- }
1227
- };
1228
- switch(this.renderer){
1229
- case RendererType.SVG:
1230
- {
1231
- options.rendererSettings = {
1232
- ...options.rendererSettings,
1233
- hideOnTransparent: true,
1234
- preserveAspectRatio,
1235
- progressiveLoad: true
1236
- };
1237
- break;
1238
- }
1239
- case RendererType.Canvas:
1240
- {
1241
- options.rendererSettings = {
1242
- ...options.rendererSettings,
1243
- // @ts-expect-error TODO:
1244
- clearCanvas: true,
1245
- preserveAspectRatio,
1246
- progressiveLoad: true
1247
- };
1248
- break;
1249
- }
1250
- case RendererType.HTML:
1251
- {
1252
- options.rendererSettings = {
1253
- ...options.rendererSettings,
1254
- hideOnTransparent: true
1255
- };
1256
- }
1257
- }
1258
- return options;
1248
+ preserveAspectRatio,
1249
+ rendererType: this.renderer
1250
+ });
1259
1251
  }
1260
1252
  /**
1261
1253
  * Handle scroll.
@@ -1382,7 +1374,7 @@ const pauseIcon = /* HTML */ `
1382
1374
  this._lottieInstance.destroy();
1383
1375
  }
1384
1376
  // Re-initialize lottie player
1385
- this._lottieInstance = Lottie.loadAnimation({
1377
+ this._lottieInstance = this.loadAnimation({
1386
1378
  ...this._getOptions(),
1387
1379
  animationData: this._animations[this._currentAnimation]
1388
1380
  });
@@ -1454,10 +1446,54 @@ const pauseIcon = /* HTML */ `
1454
1446
  }
1455
1447
  }
1456
1448
 
1449
+ /**
1450
+ * DotLottie Player Web Component.
1451
+ */ class DotLottiePlayer extends DotLottiePlayerBase {
1452
+ setOptions({ container, hasAutoplay, hasLoop, initialSegment, preserveAspectRatio, rendererType }) {
1453
+ const options = {
1454
+ autoplay: hasAutoplay,
1455
+ container,
1456
+ initialSegment,
1457
+ loop: hasLoop,
1458
+ renderer: rendererType,
1459
+ rendererSettings: {
1460
+ imagePreserveAspectRatio: preserveAspectRatio
1461
+ }
1462
+ };
1463
+ switch(this.renderer){
1464
+ case RendererType.HTML:
1465
+ case RendererType.SVG:
1466
+ {
1467
+ options.rendererSettings = {
1468
+ ...options.rendererSettings,
1469
+ hideOnTransparent: true,
1470
+ preserveAspectRatio,
1471
+ progressiveLoad: true
1472
+ };
1473
+ break;
1474
+ }
1475
+ case RendererType.Canvas:
1476
+ {
1477
+ options.rendererSettings = {
1478
+ ...options.rendererSettings,
1479
+ // @ts-expect-error TODO:
1480
+ clearCanvas: true,
1481
+ preserveAspectRatio,
1482
+ progressiveLoad: true
1483
+ };
1484
+ break;
1485
+ }
1486
+ }
1487
+ return options;
1488
+ }
1489
+ constructor(...args){
1490
+ super(...args), this.addAnimation = addAnimation, this.convert = convert, this.loadAnimation = Lottie.loadAnimation;
1491
+ }
1492
+ }
1493
+
1457
1494
  /**
1458
1495
  * Expose DotLottiePlayer class as global variable.
1459
1496
  */ globalThis.dotLottiePlayer = ()=>new DotLottiePlayer();
1460
- const tagName = 'dotlottie-player';
1461
1497
  if (!isServer) {
1462
1498
  customElements.define(tagName, DotLottiePlayer);
1463
1499
  }