@aarsteinmedia/dotlottie-player 2.5.9 → 2.5.11

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/dist/esm/index.js CHANGED
@@ -3,6 +3,8 @@ import { property, query, state, customElement } from 'lit/decorators.js';
3
3
  import Lottie from 'lottie-web';
4
4
  import { strToU8, zip, strFromU8, unzip as unzip$1 } from 'fflate';
5
5
 
6
+ var name="@aarsteinmedia/dotlottie-player";var version="2.5.11";var description="Web Component for playing Lottie animations in your web app. Previously @johanaarstein/dotlottie-player";var exports={".":{"import":"./dist/esm/index.js",node:"./dist/esm/index.js",require:"./dist/cjs/index.js",types:"./dist/index.d.ts"}};var main="./dist/esm/index.js";var unpkg="./dist/index.js";var module="./dist/esm/index.js";var types="./dist/index.d.ts";var type="module";var homepage="https://www.aarstein.media/en/dotlottie-player";var repository={url:"https://github.com/aarsteinmedia/dotlottie-player.git",type:"git"};var bugs="https://github.com/aarsteinmedia/dotlottie-player/issues";var author={name:"Johan Martin Aarstein",email:"johan@aarstein.media",url:"https://www.aarstein.media",organization:"Aarstein Media"};var license="GPL-2.0-or-later";var scripts={build:"rimraf ./dist && rollup -c","build:types":"rimraf ./types && tsc","build:cem":"npx cem analyze --config cem.config.mjs",prod:"pnpm build:types && pnpm build && pnpm build:cem",dev:"rollup -c -w --environment NODE_ENV:development",lint:"tsc && eslint . --ext .ts","lint:fix":"eslint . --ext .ts --fix"};var dependencies={fflate:"^0.8.2",lit:"^3.1.3","lottie-web":"^5.12.2"};var peerDependencies={"@types/react":">= 16.0.0"};var devDependencies={"@custom-elements-manifest/analyzer":"^0.9.9","@rollup/plugin-commonjs":"^25.0.8","@rollup/plugin-json":"^6.1.0","@rollup/plugin-node-resolve":"^15.2.3","@rollup/plugin-replace":"^5.0.5","@swc/core":"^1.5.24","@types/node":"^20.14.1","@typescript-eslint/eslint-plugin":"^7.12.0","@typescript-eslint/parser":"^7.12.0",autoprefixer:"^10.4.19","esbuild-sass-plugin":"^3.3.0",eslint:"^8.57.0","eslint-import-resolver-typescript":"^3.6.1","eslint-plugin-import":"^2.29.1","eslint-plugin-jsdoc":"^48.2.7","eslint-plugin-lit":"^1.14.0","postcss-flexbugs-fixes":"^5.0.2",rimraf:"^5.0.7",rollup:"^4.18.0","rollup-plugin-dts":"^6.1.1","rollup-plugin-html-literals":"^1.1.8","rollup-plugin-livereload":"^2.0.5","rollup-plugin-postcss":"^4.0.2","rollup-plugin-postcss-lit":"^2.1.0","rollup-plugin-serve":"^1.1.1","rollup-plugin-summary":"^2.0.1","rollup-plugin-swc3":"^0.11.2",sass:"^1.77.4","ts-lit-plugin":"^2.0.2",typescript:"^5.4.5"};var customElements="dist/custom-elements.json";var files=["dist","README.md"];var keywords=["lottie","dotlottie","animation","web component","component","lit-element","svg","vector","player"];var publishConfig={access:"public"};var engines={node:">= 8.17.0"};var funding={type:"paypal",url:"https://www.paypal.com/donate/?hosted_button_id=E7C7DMN8KSQ6A"};var pkg = {name:name,version:version,description:description,exports:exports,main:main,unpkg:unpkg,module:module,types:types,type:type,homepage:homepage,repository:repository,bugs:bugs,author:author,license:license,scripts:scripts,dependencies:dependencies,peerDependencies:peerDependencies,devDependencies:devDependencies,customElements:customElements,files:files,keywords:keywords,publishConfig:publishConfig,engines:engines,funding:funding};
7
+
6
8
  var PlayerState;
7
9
  (function(PlayerState) {
8
10
  PlayerState["Completed"] = "completed";
@@ -39,9 +41,13 @@ var PlayerEvents;
39
41
  class CustomError extends Error {
40
42
  }
41
43
  const addExt = (ext, str)=>{
42
- if (!str) return;
44
+ if (!str) {
45
+ return;
46
+ }
43
47
  if (getExt(str)) {
44
- if (getExt(str) === ext) return str;
48
+ if (getExt(str) === ext) {
49
+ return str;
50
+ }
45
51
  return `${getFilename(str)}.${ext}`;
46
52
  }
47
53
  return `${str}.${ext}`;
@@ -62,7 +68,7 @@ const addExt = (ext, str)=>{
62
68
  }, base64ToU8 = (str)=>strToU8(isServer() ? Buffer.from(parseBase64(str), 'base64').toString('binary') : atob(parseBase64(str)), true), createDotLottie = async ({ animations, manifest, fileName, shouldDownload = true })=>{
63
69
  try {
64
70
  if (!animations?.length || !manifest) {
65
- throw new Error(`Missing or malformed required parameter(s):\n ${!animations?.length ? '- animations\n' : ''} ${!manifest ? '- manifest \n' : ''}`);
71
+ throw new Error(`Missing or malformed required parameter(s):\n ${animations?.length ? '- manifest\n' : ''} ${manifest ? '- animations\n' : ''}`);
66
72
  }
67
73
  const name = addExt('lottie', fileName) || `${useId()}.lottie`, dotlottie = {
68
74
  'manifest.json': [
@@ -227,7 +233,9 @@ const addExt = (ext, str)=>{
227
233
  });
228
234
  return arrayBuffer;
229
235
  }, getExt = (str)=>{
230
- if (!str || !hasExt(str)) return;
236
+ if (!str || !hasExt(str)) {
237
+ return;
238
+ }
231
239
  const ext = str.split('.').pop()?.toLowerCase();
232
240
  if (ext === 'jpeg') {
233
241
  return 'jpg';
@@ -256,8 +264,12 @@ const addExt = (ext, str)=>{
256
264
  };
257
265
  }, getManifest = (unzipped)=>{
258
266
  const file = strFromU8(unzipped['manifest.json'], false), manifest = JSON.parse(file);
259
- if (!('animations' in manifest)) throw new Error('Manifest not found');
260
- if (!manifest.animations.length) throw new Error('No animations listed in manifest');
267
+ if (!('animations' in manifest)) {
268
+ throw new Error('Manifest not found');
269
+ }
270
+ if (!manifest.animations.length) {
271
+ throw new Error('No animations listed in manifest');
272
+ }
261
273
  return manifest;
262
274
  }, getMimeFromExt = (ext)=>{
263
275
  switch(ext){
@@ -296,21 +308,27 @@ const addExt = (ext, str)=>{
296
308
  const lastDotIndex = path?.split('/').pop()?.lastIndexOf('.');
297
309
  return (lastDotIndex ?? 0) > 1 && path && path.length - 1 > (lastDotIndex ?? 0);
298
310
  }, isAudio = (asset)=>!('h' in asset) && !('w' in asset) && 'p' in asset && 'e' in asset && 'u' in asset && 'id' in asset, isBase64 = (str)=>{
299
- if (!str) return false;
311
+ if (!str) {
312
+ return false;
313
+ }
300
314
  const regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
301
315
  return regex.test(parseBase64(str));
302
- }, isImage = (asset)=>'w' in asset && 'h' in asset && !('xt' in asset) && 'p' in asset, isServer = ()=>!(typeof window !== 'undefined' && window.document), parseBase64 = (str)=>str.substring(str.indexOf(',') + 1), prepareString = (str)=>{
303
- return str.replace(new RegExp(/"""/, 'g'), '""').replace(/(["'])(.*?)\1/g, (_match, quote, content)=>{
316
+ }, isImage = (asset)=>'w' in asset && 'h' in asset && !('xt' in asset) && 'p' in asset, isServer = ()=>!(typeof window !== 'undefined' && window.document), parseBase64 = (str)=>str.substring(str.indexOf(',') + 1), prepareString = (str)=>str.replace(new RegExp(/"""/, 'g'), '""').replace(/(["'])(.*?)\1/g, (_match, quote, content)=>{
304
317
  const replacedContent = content.replace(/[^\w\s\d.#]/g, '');
305
318
  return `${quote}${replacedContent}${quote}`;
306
- });
307
- }, resolveAssets = async (unzipped, assets)=>{
308
- if (!Array.isArray(assets)) return;
319
+ }), resolveAssets = async (unzipped, assets)=>{
320
+ if (!Array.isArray(assets)) {
321
+ return;
322
+ }
309
323
  const toResolve = [];
310
324
  for (const asset of assets){
311
- if (!isAudio(asset) && !isImage(asset)) continue;
325
+ if (!isAudio(asset) && !isImage(asset)) {
326
+ continue;
327
+ }
312
328
  const type = isImage(asset) ? 'images' : 'audio', u8 = unzipped?.[`${type}/${asset.p}`];
313
- if (!u8) continue;
329
+ if (!u8) {
330
+ continue;
331
+ }
314
332
  toResolve.push(new Promise((resolveAsset)=>{
315
333
  const assetB64 = isServer() ? Buffer.from(u8).toString('base64') : btoa(u8.reduce((dat, byte)=>`${dat}${String.fromCharCode(byte)}`, ''));
316
334
  asset.p = asset.p?.startsWith('data:') || isBase64(asset.p) ? asset.p : `data:${getMimeFromExt(getExt(asset.p))};base64,${assetB64}`;
@@ -331,14 +349,10 @@ const addExt = (ext, str)=>{
331
349
  });
332
350
  return unzipped;
333
351
  }, useId = (prefix)=>{
334
- const s4 = ()=>{
335
- return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1);
336
- };
352
+ const s4 = ()=>((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1);
337
353
  return `${prefix ?? `:${s4()}`}-${s4()}`;
338
354
  };
339
355
 
340
- var name="@aarsteinmedia/dotlottie-player";var version="2.5.9";var description="Web Component for playing Lottie animations in your web app. Previously @johanaarstein/dotlottie-player";var exports={".":{"import":"./dist/esm/index.js",node:"./dist/esm/index.js",require:"./dist/cjs/index.js",types:"./dist/index.d.ts"}};var main="./dist/esm/index.js";var unpkg="./dist/index.js";var module="./dist/esm/index.js";var types="./dist/index.d.ts";var type="module";var homepage="https://www.aarstein.media/en/dotlottie-player";var repository={url:"https://github.com/aarsteinmedia/dotlottie-player.git",type:"git"};var bugs="https://github.com/aarsteinmedia/dotlottie-player/issues";var author={name:"Johan Martin Aarstein",email:"johan@aarstein.media",url:"https://www.aarstein.media",organization:"Aarstein Media"};var license="GPL-2.0-or-later";var scripts={build:"rimraf ./dist && rollup -c","build:types":"rimraf ./types && tsc","build:cem":"npx cem analyze --config cem.config.mjs",prod:"pnpm build:types && pnpm build && pnpm build:cem",dev:"rollup -c -w --environment NODE_ENV:development",lint:"tsc && eslint . --ext .ts","lint:fix":"eslint . --ext .ts --fix"};var dependencies={fflate:"^0.8.2",lit:"^3.1.3","lottie-web":"^5.12.2"};var peerDependencies={"@types/react":">= 16.0.0"};var devDependencies={"@custom-elements-manifest/analyzer":"^0.9.9","@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-json":"^6.1.0","@rollup/plugin-node-resolve":"^15.2.3","@rollup/plugin-replace":"^5.0.5","@swc/core":"^1.5.7","@types/node":"^20.12.12","@typescript-eslint/eslint-plugin":"^7.9.0","@typescript-eslint/parser":"^7.9.0",autoprefixer:"^10.4.19","esbuild-sass-plugin":"^3.2.0",eslint:"^8.57.0","eslint-plugin-lit":"^1.13.0","postcss-flexbugs-fixes":"^5.0.2",rimraf:"^5.0.7",rollup:"^4.17.2","rollup-plugin-dts":"^6.1.0","rollup-plugin-html-literals":"^1.1.8","rollup-plugin-livereload":"^2.0.5","rollup-plugin-postcss":"^4.0.2","rollup-plugin-postcss-lit":"^2.1.0","rollup-plugin-serve":"^1.1.1","rollup-plugin-summary":"^2.0.0","rollup-plugin-swc3":"^0.11.2",sass:"^1.77.1","ts-lit-plugin":"^2.0.2",typescript:"^5.4.5"};var customElements="dist/custom-elements.json";var files=["dist","README.md"];var keywords=["lottie","dotlottie","animation","web component","component","lit-element","svg","vector","player"];var publishConfig={access:"public"};var engines={node:">= 8.17.0"};var funding={type:"paypal",url:"https://www.paypal.com/donate/?hosted_button_id=E7C7DMN8KSQ6A"};var pkg = {name:name,version:version,description:description,exports:exports,main:main,unpkg:unpkg,module:module,types:types,type:type,homepage:homepage,repository:repository,bugs:bugs,author:author,license:license,scripts:scripts,dependencies:dependencies,peerDependencies:peerDependencies,devDependencies:devDependencies,customElements:customElements,files:files,keywords:keywords,publishConfig:publishConfig,engines:engines,funding:funding};
341
-
342
356
  var css_248z = css`*{box-sizing:border-box}:host{--lottie-player-toolbar-height:35px;--lottie-player-toolbar-background-color:#FFF;--lottie-player-toolbar-icon-color:#000;--lottie-player-toolbar-icon-hover-color:#000;--lottie-player-toolbar-icon-active-color:#4285f4;--lottie-player-seeker-track-color:rgba(0, 0, 0, 0.2);--lottie-player-seeker-thumb-color:#4285f4;--lottie-player-seeker-display:block;display:block;width:100%;height:100%}@media (prefers-color-scheme:dark){:host{--lottie-player-toolbar-background-color:#000;--lottie-player-toolbar-icon-color:#FFF;--lottie-player-toolbar-icon-hover-color:#FFF;--lottie-player-seeker-track-color:rgba(255, 255, 255, 0.6)}}.main{display:flex;flex-direction:column;height:100%;width:100%;margin:0;padding:0}.animation{width:100%;height:100%;display:flex}[data-controls=true] .animation{height:calc(100% - 35px)}.animation-container{position:relative}.popover{position:absolute;right:5px;bottom:40px;background-color:var(--lottie-player-toolbar-background-color);border-radius:5px;padding:10px 15px;border:solid 2px var(--lottie-player-toolbar-icon-color);animation:fadeIn .2s ease-in-out}.popover::before{content:"";right:10px;border:7px solid transparent;border-top-color:transparent;margin-right:-7px;height:0;width:0;position:absolute;pointer-events:none;top:100%;border-top-color:var(--lottie-player-toolbar-icon-color)}.toolbar{display:flex;align-items:center;justify-items:center;background:var(--lottie-player-toolbar-background-color);margin:0;height:35px;padding:5px;border-radius:5px;gap:5px}.toolbar.has-error{pointer-events:none;opacity:.5}.toolbar button{cursor:pointer;fill:var(--lottie-player-toolbar-icon-color);color:var(--lottie-player-toolbar-icon-color);display:flex;background:0 0;border:0;padding:0;outline:0;height:100%;margin:0;align-items:center;gap:5px;opacity:.9}.toolbar button:hover{opacity:1}.toolbar button[data-active=true]{opacity:1;fill:var(--lottie-player-toolbar-icon-active-color)}.toolbar button:disabled{opacity:.5}.toolbar button:focus{outline:0}.toolbar button svg{pointer-events:none}.toolbar button svg>*{fill:inherit}.toolbar button.disabled svg{display:none}.progress-container{position:relative;width:100%}.progress-container.simple{margin-right:12px}.seeker{-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:0}.seeker::-webkit-slider-runnable-track,.seeker::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;outline:0}progress{-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:0}.seeker{width:100%;height:20px;border-radius:3px;border:0;cursor:pointer;background-color:transparent;display:var(--lottie-player-seeker-display);color:var(--lottie-player-seeker-thumb-color);margin:0;padding:7.5px 0;position:relative;z-index:1}progress{position:absolute;width:100%;height:5px;border-radius:3px;border:0;top:0;left:0;margin:7.5px 0;background-color:var(--lottie-player-seeker-track-color);pointer-events:none}::-moz-progress-bar{background-color:var(--lottie-player-seeker-thumb-color)}::-webkit-progress-inner-element{border-radius:3px;overflow:hidden}::-webkit-slider-runnable-track{background-color:transparent}::-webkit-progress-value{background-color:var(--lottie-player-seeker-thumb-color)}.seeker::-webkit-slider-thumb{height:15px;width:15px;border-radius:50%;border:0;background-color:var(--lottie-player-seeker-thumb-color);cursor:pointer;-webkit-transition:transform .2s ease-in-out;transition:transform .2s ease-in-out;transform:scale(0)}.seeker:focus::-webkit-slider-thumb,.seeker:hover::-webkit-slider-thumb{transform:scale(1)}.seeker::-moz-range-progress{background-color:var(--lottie-player-seeker-thumb-color);height:5px;border-radius:3px}.seeker::-moz-range-thumb{height:15px;width:15px;border-radius:50%;background-color:var(--lottie-player-seeker-thumb-color);border:0;cursor:pointer;-moz-transition:transform .2s ease-in-out;transition:transform .2s ease-in-out;transform:scale(0)}.seeker:focus::-moz-range-thumb,.seeker:hover::-moz-range-thumb{transform:scale(1)}.seeker::-ms-track{width:100%;height:5px;cursor:pointer;background:0 0;border-color:transparent;color:transparent}.seeker::-ms-fill-upper{background:var(--lottie-player-seeker-track-color);border-radius:3px}.seeker::-ms-fill-lower{background-color:var(--lottie-player-seeker-thumb-color);border-radius:3px}.seeker::-ms-thumb{border:0;height:15px;width:15px;border-radius:50%;background:var(--lottie-player-seeker-thumb-color);cursor:pointer;-ms-transition:transform .2s ease-in-out;transition:transform .2s ease-in-out;transform:scale(0)}.seeker:hover::-ms-thumb{transform:scale(1)}.seeker:focus::-ms-thumb{transform:scale(1)}.seeker:focus::-ms-fill-lower,.seeker:focus::-ms-fill-upper{background:var(--lottie-player-seeker-track-color)}.error{display:flex;margin:auto;justify-content:center;height:100%;align-items:center}.error svg{width:100%;height:auto}@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}`;
343
357
 
344
358
  function _ts_decorate(decorators, target, key, desc) {
@@ -349,10 +363,32 @@ function _ts_decorate(decorators, target, key, desc) {
349
363
  }
350
364
  class DotLottiePlayer extends LitElement {
351
365
  _getOptions() {
352
- const preserveAspectRatio = this.preserveAspectRatio ?? (this.objectfit && aspectRatio(this.objectfit)), currentAnimationSettings = this.multiAnimationSettings?.[this._currentAnimation], currentAnimationManifest = this._manifest.animations?.[this._currentAnimation], loop = currentAnimationSettings?.loop !== undefined ? !!currentAnimationSettings.loop : this.loop !== undefined ? !!this.loop : currentAnimationManifest.loop !== undefined && !!currentAnimationManifest.loop, autoplay = !this.animateOnScroll && (currentAnimationSettings?.autoplay !== undefined ? !!currentAnimationSettings.autoplay : this.autoplay !== undefined ? !!this.autoplay : currentAnimationManifest.autoplay !== undefined && !!currentAnimationManifest.autoplay), initialSegment = !this.segment || this.segment.some((val)=>val < 0) ? undefined : this.segment.every((val)=>val > 0) ? [
353
- this.segment[0] - 1,
354
- this.segment[1] - 1
355
- ] : this.segment, options = {
366
+ const preserveAspectRatio = this.preserveAspectRatio ?? (this.objectfit && aspectRatio(this.objectfit)), currentAnimationSettings = this.multiAnimationSettings?.length ? this.multiAnimationSettings?.[this._currentAnimation] : undefined, currentAnimationManifest = this._manifest.animations?.[this._currentAnimation];
367
+ let loop = !!this.loop;
368
+ if (currentAnimationSettings?.loop !== undefined) {
369
+ loop = !!currentAnimationSettings.loop;
370
+ }
371
+ let autoplay = !!this.autoplay;
372
+ if (currentAnimationManifest.autoplay !== undefined) {
373
+ autoplay = !!currentAnimationManifest.autoplay;
374
+ }
375
+ if (currentAnimationSettings?.autoplay !== undefined) {
376
+ autoplay = !!currentAnimationSettings.autoplay;
377
+ }
378
+ if (this.animateOnScroll) {
379
+ autoplay = false;
380
+ }
381
+ let initialSegment = this.segment;
382
+ if (this.segment?.every((val)=>val > 0)) {
383
+ initialSegment = [
384
+ this.segment[0] - 1,
385
+ this.segment[1] - 1
386
+ ];
387
+ }
388
+ if (this.segment?.some((val)=>val < 0)) {
389
+ initialSegment = undefined;
390
+ }
391
+ const options = {
356
392
  container: this.container,
357
393
  loop,
358
394
  autoplay,
@@ -412,13 +448,20 @@ class DotLottiePlayer extends LitElement {
412
448
  this._intersectionObserver.observe(this.container);
413
449
  }
414
450
  async load(src) {
415
- if (!this.shadowRoot) return;
451
+ if (!this.shadowRoot) {
452
+ return;
453
+ }
416
454
  try {
417
455
  const { animations, manifest, isDotLottie } = await getAnimationData(src);
418
456
  if (!animations || animations.some((animation)=>!this._isLottie(animation))) {
419
457
  throw new Error('Broken or corrupted file');
420
458
  }
421
- this._isBounce = this.multiAnimationSettings?.[this._currentAnimation]?.mode !== undefined ? this.multiAnimationSettings?.[this._currentAnimation]?.mode === PlayMode.Bounce : this.mode === PlayMode.Bounce;
459
+ this._isBounce = this.mode === PlayMode.Bounce;
460
+ if (this.multiAnimationSettings?.length) {
461
+ if (this.multiAnimationSettings[this._currentAnimation]?.mode) {
462
+ this._isBounce = this.multiAnimationSettings[this._currentAnimation].mode === PlayMode.Bounce;
463
+ }
464
+ }
422
465
  this._isDotLottie = !!isDotLottie;
423
466
  this._animations = animations;
424
467
  this._manifest = manifest ?? {
@@ -433,8 +476,13 @@ class DotLottiePlayer extends LitElement {
433
476
  }
434
477
  ]
435
478
  };
436
- if (this._lottieInstance) this._lottieInstance.destroy();
437
- this.currentState = (this.autoplay || this.multiAnimationSettings?.[this._currentAnimation].autoplay) && !this.animateOnScroll ? PlayerState.Playing : PlayerState.Stopped;
479
+ if (this._lottieInstance) {
480
+ this._lottieInstance.destroy();
481
+ }
482
+ this.currentState = PlayerState.Stopped;
483
+ if (!this.animateOnScroll && (this.autoplay || this.multiAnimationSettings?.[this._currentAnimation]?.autoplay)) {
484
+ this.currentState = PlayerState.Playing;
485
+ }
438
486
  this._lottieInstance = Lottie.loadAnimation({
439
487
  ...this._getOptions(),
440
488
  animationData: animations[this._currentAnimation]
@@ -451,20 +499,25 @@ class DotLottiePlayer extends LitElement {
451
499
  this.setDirection(direction);
452
500
  this.setSubframe(!!this.subframe);
453
501
  if (this.autoplay || this.animateOnScroll) {
454
- if (this.direction === -1) this.seek('99%');
502
+ if (this.direction === -1) {
503
+ this.seek('99%');
504
+ }
455
505
  if (!('IntersectionObserver' in window)) {
456
- !this.animateOnScroll && this.play();
506
+ if (!this.animateOnScroll) {
507
+ this.play();
508
+ }
457
509
  this._playerState.visible = true;
458
510
  }
459
511
  this._addIntersectionObserver();
460
- return;
461
512
  }
462
513
  }
463
514
  getManifest() {
464
515
  return this._manifest;
465
516
  }
466
517
  _addEventListeners() {
467
- if (!this._lottieInstance) return;
518
+ if (!this._lottieInstance) {
519
+ return;
520
+ }
468
521
  this._lottieInstance.addEventListener('enterFrame', this._enterFrame);
469
522
  this._lottieInstance.addEventListener('complete', this._complete);
470
523
  this._lottieInstance.addEventListener('loopComplete', this._loopComplete);
@@ -491,7 +544,9 @@ class DotLottiePlayer extends LitElement {
491
544
  }
492
545
  }
493
546
  _removeEventListeners() {
494
- if (!this._lottieInstance || !this.container) return;
547
+ if (!this._lottieInstance || !this.container) {
548
+ return;
549
+ }
495
550
  this._lottieInstance.removeEventListener('enterFrame', this._enterFrame);
496
551
  this._lottieInstance.removeEventListener('complete', this._complete);
497
552
  this._lottieInstance.removeEventListener('loopComplete', this._loopComplete);
@@ -510,7 +565,11 @@ class DotLottiePlayer extends LitElement {
510
565
  }
511
566
  const { totalFrames, playDirection } = this._lottieInstance, inPoint = this.segment ? this.segment[0] : 0, outPoint = this.segment ? this.segment[0] : totalFrames;
512
567
  if (this.count) {
513
- this._isBounce ? this._playerState.count += 0.5 : this._playerState.count += 1;
568
+ if (this._isBounce) {
569
+ this._playerState.count += 0.5;
570
+ } else {
571
+ this._playerState.count += 1;
572
+ }
514
573
  if (this._playerState.count >= this.count) {
515
574
  this.setLooping(false);
516
575
  this.currentState = PlayerState.Completed;
@@ -523,12 +582,16 @@ class DotLottiePlayer extends LitElement {
523
582
  this._lottieInstance.goToAndStop(playDirection === -1 ? inPoint : outPoint * 0.99, true);
524
583
  this._lottieInstance.setDirection(playDirection * -1);
525
584
  return setTimeout(()=>{
526
- !this.animateOnScroll && this._lottieInstance?.play();
585
+ if (!this.animateOnScroll) {
586
+ this._lottieInstance?.play();
587
+ }
527
588
  }, this.intermission);
528
589
  }
529
590
  this._lottieInstance.goToAndStop(playDirection === -1 ? outPoint * 0.99 : inPoint, true);
530
591
  return setTimeout(()=>{
531
- !this.animateOnScroll && this._lottieInstance?.play();
592
+ if (!this.animateOnScroll) {
593
+ this._lottieInstance?.play();
594
+ }
532
595
  }, this.intermission);
533
596
  }
534
597
  _enterFrame() {
@@ -631,7 +694,9 @@ class DotLottiePlayer extends LitElement {
631
694
  }, 400);
632
695
  }
633
696
  _handleSeekChange({ target }) {
634
- if (!(target instanceof HTMLInputElement) || !this._lottieInstance || isNaN(Number(target.value))) return;
697
+ if (!(target instanceof HTMLInputElement) || !this._lottieInstance || isNaN(Number(target.value))) {
698
+ return;
699
+ }
635
700
  this.seek(Math.floor(Number(target.value) / 100 * this._lottieInstance.totalFrames));
636
701
  setTimeout(()=>{
637
702
  if (target.parentElement instanceof HTMLFormElement) {
@@ -691,7 +756,9 @@ class DotLottiePlayer extends LitElement {
691
756
  return this._lottieInstance;
692
757
  }
693
758
  play() {
694
- if (!this._lottieInstance) return;
759
+ if (!this._lottieInstance) {
760
+ return;
761
+ }
695
762
  if (this.currentState) {
696
763
  this._playerState.prev = this.currentState;
697
764
  }
@@ -702,7 +769,9 @@ class DotLottiePlayer extends LitElement {
702
769
  this.dispatchEvent(new CustomEvent(PlayerEvents.Play));
703
770
  }
704
771
  pause() {
705
- if (!this._lottieInstance) return;
772
+ if (!this._lottieInstance) {
773
+ return;
774
+ }
706
775
  if (this.currentState) {
707
776
  this._playerState.prev = this.currentState;
708
777
  }
@@ -713,7 +782,9 @@ class DotLottiePlayer extends LitElement {
713
782
  this.dispatchEvent(new CustomEvent(PlayerEvents.Pause));
714
783
  }
715
784
  stop() {
716
- if (!this._lottieInstance) return;
785
+ if (!this._lottieInstance) {
786
+ return;
787
+ }
717
788
  if (this.currentState) {
718
789
  this._playerState.prev = this.currentState;
719
790
  }
@@ -725,7 +796,9 @@ class DotLottiePlayer extends LitElement {
725
796
  this.dispatchEvent(new CustomEvent(PlayerEvents.Stop));
726
797
  }
727
798
  destroy() {
728
- if (!this._lottieInstance) return;
799
+ if (!this._lottieInstance) {
800
+ return;
801
+ }
729
802
  this.currentState = PlayerState.Destroyed;
730
803
  this._lottieInstance.destroy();
731
804
  this._lottieInstance = null;
@@ -734,7 +807,9 @@ class DotLottiePlayer extends LitElement {
734
807
  document.removeEventListener('visibilitychange', this._onVisibilityChange);
735
808
  }
736
809
  seek(value) {
737
- if (!this._lottieInstance) return;
810
+ if (!this._lottieInstance) {
811
+ return;
812
+ }
738
813
  const matches = value.toString().match(/^([0-9]+)(%?)$/);
739
814
  if (!matches) {
740
815
  return;
@@ -750,7 +825,9 @@ class DotLottiePlayer extends LitElement {
750
825
  this._lottieInstance.pause();
751
826
  }
752
827
  snapshot() {
753
- if (!this.shadowRoot) return;
828
+ if (!this.shadowRoot) {
829
+ return;
830
+ }
754
831
  const svgElement = this.shadowRoot.querySelector('.animation svg'), data = svgElement instanceof Node ? new XMLSerializer().serializeToString(svgElement) : null;
755
832
  if (!data) {
756
833
  console.error('Could not serialize data');
@@ -763,16 +840,22 @@ class DotLottiePlayer extends LitElement {
763
840
  return data;
764
841
  }
765
842
  setSubframe(value) {
766
- if (!this._lottieInstance) return;
843
+ if (!this._lottieInstance) {
844
+ return;
845
+ }
767
846
  this.subframe = value;
768
847
  this._lottieInstance.setSubframe(value);
769
848
  }
770
849
  setCount(value) {
771
- if (!this._lottieInstance) return;
850
+ if (!this._lottieInstance) {
851
+ return;
852
+ }
772
853
  this.count = value;
773
854
  }
774
855
  _freeze() {
775
- if (!this._lottieInstance) return;
856
+ if (!this._lottieInstance) {
857
+ return;
858
+ }
776
859
  if (this.currentState) {
777
860
  this._playerState.prev = this.currentState;
778
861
  }
@@ -783,19 +866,25 @@ class DotLottiePlayer extends LitElement {
783
866
  this.dispatchEvent(new CustomEvent(PlayerEvents.Freeze));
784
867
  }
785
868
  async reload() {
786
- if (!this._lottieInstance) return;
869
+ if (!this._lottieInstance) {
870
+ return;
871
+ }
787
872
  this._lottieInstance.destroy();
788
873
  if (this.src) {
789
874
  await this.load(this.src);
790
875
  }
791
876
  }
792
877
  setSpeed(value = 1) {
793
- if (!this._lottieInstance) return;
878
+ if (!this._lottieInstance) {
879
+ return;
880
+ }
794
881
  this.speed = value;
795
882
  this._lottieInstance.setSpeed(value);
796
883
  }
797
884
  setDirection(value) {
798
- if (!this._lottieInstance) return;
885
+ if (!this._lottieInstance) {
886
+ return;
887
+ }
799
888
  this.direction = value;
800
889
  this._lottieInstance.setDirection(value);
801
890
  }
@@ -813,7 +902,9 @@ class DotLottiePlayer extends LitElement {
813
902
  this.multiAnimationSettings = settings;
814
903
  }
815
904
  togglePlay() {
816
- if (!this._lottieInstance) return;
905
+ if (!this._lottieInstance) {
906
+ return;
907
+ }
817
908
  const { currentFrame, playDirection, totalFrames } = this._lottieInstance;
818
909
  if (this.currentState === PlayerState.Playing) {
819
910
  return this.pause();
@@ -865,9 +956,13 @@ class DotLottiePlayer extends LitElement {
865
956
  setTimeout(()=>this._toggleSettings(false), 200);
866
957
  }
867
958
  _switchInstance(isPrevious = false) {
868
- if (!this._animations[this._currentAnimation]) return;
959
+ if (!this._animations[this._currentAnimation]) {
960
+ return;
961
+ }
869
962
  try {
870
- if (this._lottieInstance) this._lottieInstance.destroy();
963
+ if (this._lottieInstance) {
964
+ this._lottieInstance.destroy();
965
+ }
871
966
  this._lottieInstance = Lottie.loadAnimation({
872
967
  ...this._getOptions(),
873
968
  animationData: this._animations[this._currentAnimation]
@@ -944,7 +1039,9 @@ class DotLottiePlayer extends LitElement {
944
1039
  this._intersectionObserver.disconnect();
945
1040
  this._intersectionObserver = undefined;
946
1041
  }
947
- if (this._lottieInstance) this._lottieInstance.destroy();
1042
+ if (this._lottieInstance) {
1043
+ this._lottieInstance.destroy();
1044
+ }
948
1045
  document.removeEventListener('visibilitychange', this._onVisibilityChange);
949
1046
  }
950
1047
  renderControls() {