@aarsteinmedia/dotlottie-player 2.5.9 → 2.5.10

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.10";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,35 @@ 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 (currentAnimationManifest.loop !== undefined) {
369
+ loop = !!currentAnimationManifest.loop;
370
+ }
371
+ if (currentAnimationSettings?.loop !== undefined) {
372
+ loop = !!currentAnimationSettings.loop;
373
+ }
374
+ let autoplay = !!this.autoplay;
375
+ if (currentAnimationManifest.autoplay !== undefined) {
376
+ autoplay = !!currentAnimationManifest.autoplay;
377
+ }
378
+ if (currentAnimationSettings?.autoplay !== undefined) {
379
+ autoplay = !!currentAnimationSettings.autoplay;
380
+ }
381
+ if (this.animateOnScroll) {
382
+ autoplay = false;
383
+ }
384
+ let initialSegment = this.segment;
385
+ if (this.segment?.every((val)=>val > 0)) {
386
+ initialSegment = [
387
+ this.segment[0] - 1,
388
+ this.segment[1] - 1
389
+ ];
390
+ }
391
+ if (this.segment?.some((val)=>val < 0)) {
392
+ initialSegment = undefined;
393
+ }
394
+ const options = {
356
395
  container: this.container,
357
396
  loop,
358
397
  autoplay,
@@ -412,13 +451,20 @@ class DotLottiePlayer extends LitElement {
412
451
  this._intersectionObserver.observe(this.container);
413
452
  }
414
453
  async load(src) {
415
- if (!this.shadowRoot) return;
454
+ if (!this.shadowRoot) {
455
+ return;
456
+ }
416
457
  try {
417
458
  const { animations, manifest, isDotLottie } = await getAnimationData(src);
418
459
  if (!animations || animations.some((animation)=>!this._isLottie(animation))) {
419
460
  throw new Error('Broken or corrupted file');
420
461
  }
421
- this._isBounce = this.multiAnimationSettings?.[this._currentAnimation]?.mode !== undefined ? this.multiAnimationSettings?.[this._currentAnimation]?.mode === PlayMode.Bounce : this.mode === PlayMode.Bounce;
462
+ this._isBounce = this.mode === PlayMode.Bounce;
463
+ if (this.multiAnimationSettings?.length) {
464
+ if (this.multiAnimationSettings[this._currentAnimation]?.mode) {
465
+ this._isBounce = this.multiAnimationSettings[this._currentAnimation].mode === PlayMode.Bounce;
466
+ }
467
+ }
422
468
  this._isDotLottie = !!isDotLottie;
423
469
  this._animations = animations;
424
470
  this._manifest = manifest ?? {
@@ -433,8 +479,13 @@ class DotLottiePlayer extends LitElement {
433
479
  }
434
480
  ]
435
481
  };
436
- if (this._lottieInstance) this._lottieInstance.destroy();
437
- this.currentState = (this.autoplay || this.multiAnimationSettings?.[this._currentAnimation].autoplay) && !this.animateOnScroll ? PlayerState.Playing : PlayerState.Stopped;
482
+ if (this._lottieInstance) {
483
+ this._lottieInstance.destroy();
484
+ }
485
+ this.currentState = PlayerState.Stopped;
486
+ if (!this.animateOnScroll && (this.autoplay || this.multiAnimationSettings?.[this._currentAnimation]?.autoplay)) {
487
+ this.currentState = PlayerState.Playing;
488
+ }
438
489
  this._lottieInstance = Lottie.loadAnimation({
439
490
  ...this._getOptions(),
440
491
  animationData: animations[this._currentAnimation]
@@ -451,20 +502,25 @@ class DotLottiePlayer extends LitElement {
451
502
  this.setDirection(direction);
452
503
  this.setSubframe(!!this.subframe);
453
504
  if (this.autoplay || this.animateOnScroll) {
454
- if (this.direction === -1) this.seek('99%');
505
+ if (this.direction === -1) {
506
+ this.seek('99%');
507
+ }
455
508
  if (!('IntersectionObserver' in window)) {
456
- !this.animateOnScroll && this.play();
509
+ if (!this.animateOnScroll) {
510
+ this.play();
511
+ }
457
512
  this._playerState.visible = true;
458
513
  }
459
514
  this._addIntersectionObserver();
460
- return;
461
515
  }
462
516
  }
463
517
  getManifest() {
464
518
  return this._manifest;
465
519
  }
466
520
  _addEventListeners() {
467
- if (!this._lottieInstance) return;
521
+ if (!this._lottieInstance) {
522
+ return;
523
+ }
468
524
  this._lottieInstance.addEventListener('enterFrame', this._enterFrame);
469
525
  this._lottieInstance.addEventListener('complete', this._complete);
470
526
  this._lottieInstance.addEventListener('loopComplete', this._loopComplete);
@@ -491,7 +547,9 @@ class DotLottiePlayer extends LitElement {
491
547
  }
492
548
  }
493
549
  _removeEventListeners() {
494
- if (!this._lottieInstance || !this.container) return;
550
+ if (!this._lottieInstance || !this.container) {
551
+ return;
552
+ }
495
553
  this._lottieInstance.removeEventListener('enterFrame', this._enterFrame);
496
554
  this._lottieInstance.removeEventListener('complete', this._complete);
497
555
  this._lottieInstance.removeEventListener('loopComplete', this._loopComplete);
@@ -510,7 +568,11 @@ class DotLottiePlayer extends LitElement {
510
568
  }
511
569
  const { totalFrames, playDirection } = this._lottieInstance, inPoint = this.segment ? this.segment[0] : 0, outPoint = this.segment ? this.segment[0] : totalFrames;
512
570
  if (this.count) {
513
- this._isBounce ? this._playerState.count += 0.5 : this._playerState.count += 1;
571
+ if (this._isBounce) {
572
+ this._playerState.count += 0.5;
573
+ } else {
574
+ this._playerState.count += 1;
575
+ }
514
576
  if (this._playerState.count >= this.count) {
515
577
  this.setLooping(false);
516
578
  this.currentState = PlayerState.Completed;
@@ -523,12 +585,16 @@ class DotLottiePlayer extends LitElement {
523
585
  this._lottieInstance.goToAndStop(playDirection === -1 ? inPoint : outPoint * 0.99, true);
524
586
  this._lottieInstance.setDirection(playDirection * -1);
525
587
  return setTimeout(()=>{
526
- !this.animateOnScroll && this._lottieInstance?.play();
588
+ if (!this.animateOnScroll) {
589
+ this._lottieInstance?.play();
590
+ }
527
591
  }, this.intermission);
528
592
  }
529
593
  this._lottieInstance.goToAndStop(playDirection === -1 ? outPoint * 0.99 : inPoint, true);
530
594
  return setTimeout(()=>{
531
- !this.animateOnScroll && this._lottieInstance?.play();
595
+ if (!this.animateOnScroll) {
596
+ this._lottieInstance?.play();
597
+ }
532
598
  }, this.intermission);
533
599
  }
534
600
  _enterFrame() {
@@ -631,7 +697,9 @@ class DotLottiePlayer extends LitElement {
631
697
  }, 400);
632
698
  }
633
699
  _handleSeekChange({ target }) {
634
- if (!(target instanceof HTMLInputElement) || !this._lottieInstance || isNaN(Number(target.value))) return;
700
+ if (!(target instanceof HTMLInputElement) || !this._lottieInstance || isNaN(Number(target.value))) {
701
+ return;
702
+ }
635
703
  this.seek(Math.floor(Number(target.value) / 100 * this._lottieInstance.totalFrames));
636
704
  setTimeout(()=>{
637
705
  if (target.parentElement instanceof HTMLFormElement) {
@@ -691,7 +759,9 @@ class DotLottiePlayer extends LitElement {
691
759
  return this._lottieInstance;
692
760
  }
693
761
  play() {
694
- if (!this._lottieInstance) return;
762
+ if (!this._lottieInstance) {
763
+ return;
764
+ }
695
765
  if (this.currentState) {
696
766
  this._playerState.prev = this.currentState;
697
767
  }
@@ -702,7 +772,9 @@ class DotLottiePlayer extends LitElement {
702
772
  this.dispatchEvent(new CustomEvent(PlayerEvents.Play));
703
773
  }
704
774
  pause() {
705
- if (!this._lottieInstance) return;
775
+ if (!this._lottieInstance) {
776
+ return;
777
+ }
706
778
  if (this.currentState) {
707
779
  this._playerState.prev = this.currentState;
708
780
  }
@@ -713,7 +785,9 @@ class DotLottiePlayer extends LitElement {
713
785
  this.dispatchEvent(new CustomEvent(PlayerEvents.Pause));
714
786
  }
715
787
  stop() {
716
- if (!this._lottieInstance) return;
788
+ if (!this._lottieInstance) {
789
+ return;
790
+ }
717
791
  if (this.currentState) {
718
792
  this._playerState.prev = this.currentState;
719
793
  }
@@ -725,7 +799,9 @@ class DotLottiePlayer extends LitElement {
725
799
  this.dispatchEvent(new CustomEvent(PlayerEvents.Stop));
726
800
  }
727
801
  destroy() {
728
- if (!this._lottieInstance) return;
802
+ if (!this._lottieInstance) {
803
+ return;
804
+ }
729
805
  this.currentState = PlayerState.Destroyed;
730
806
  this._lottieInstance.destroy();
731
807
  this._lottieInstance = null;
@@ -734,7 +810,9 @@ class DotLottiePlayer extends LitElement {
734
810
  document.removeEventListener('visibilitychange', this._onVisibilityChange);
735
811
  }
736
812
  seek(value) {
737
- if (!this._lottieInstance) return;
813
+ if (!this._lottieInstance) {
814
+ return;
815
+ }
738
816
  const matches = value.toString().match(/^([0-9]+)(%?)$/);
739
817
  if (!matches) {
740
818
  return;
@@ -750,7 +828,9 @@ class DotLottiePlayer extends LitElement {
750
828
  this._lottieInstance.pause();
751
829
  }
752
830
  snapshot() {
753
- if (!this.shadowRoot) return;
831
+ if (!this.shadowRoot) {
832
+ return;
833
+ }
754
834
  const svgElement = this.shadowRoot.querySelector('.animation svg'), data = svgElement instanceof Node ? new XMLSerializer().serializeToString(svgElement) : null;
755
835
  if (!data) {
756
836
  console.error('Could not serialize data');
@@ -763,16 +843,22 @@ class DotLottiePlayer extends LitElement {
763
843
  return data;
764
844
  }
765
845
  setSubframe(value) {
766
- if (!this._lottieInstance) return;
846
+ if (!this._lottieInstance) {
847
+ return;
848
+ }
767
849
  this.subframe = value;
768
850
  this._lottieInstance.setSubframe(value);
769
851
  }
770
852
  setCount(value) {
771
- if (!this._lottieInstance) return;
853
+ if (!this._lottieInstance) {
854
+ return;
855
+ }
772
856
  this.count = value;
773
857
  }
774
858
  _freeze() {
775
- if (!this._lottieInstance) return;
859
+ if (!this._lottieInstance) {
860
+ return;
861
+ }
776
862
  if (this.currentState) {
777
863
  this._playerState.prev = this.currentState;
778
864
  }
@@ -783,19 +869,25 @@ class DotLottiePlayer extends LitElement {
783
869
  this.dispatchEvent(new CustomEvent(PlayerEvents.Freeze));
784
870
  }
785
871
  async reload() {
786
- if (!this._lottieInstance) return;
872
+ if (!this._lottieInstance) {
873
+ return;
874
+ }
787
875
  this._lottieInstance.destroy();
788
876
  if (this.src) {
789
877
  await this.load(this.src);
790
878
  }
791
879
  }
792
880
  setSpeed(value = 1) {
793
- if (!this._lottieInstance) return;
881
+ if (!this._lottieInstance) {
882
+ return;
883
+ }
794
884
  this.speed = value;
795
885
  this._lottieInstance.setSpeed(value);
796
886
  }
797
887
  setDirection(value) {
798
- if (!this._lottieInstance) return;
888
+ if (!this._lottieInstance) {
889
+ return;
890
+ }
799
891
  this.direction = value;
800
892
  this._lottieInstance.setDirection(value);
801
893
  }
@@ -813,7 +905,9 @@ class DotLottiePlayer extends LitElement {
813
905
  this.multiAnimationSettings = settings;
814
906
  }
815
907
  togglePlay() {
816
- if (!this._lottieInstance) return;
908
+ if (!this._lottieInstance) {
909
+ return;
910
+ }
817
911
  const { currentFrame, playDirection, totalFrames } = this._lottieInstance;
818
912
  if (this.currentState === PlayerState.Playing) {
819
913
  return this.pause();
@@ -865,9 +959,13 @@ class DotLottiePlayer extends LitElement {
865
959
  setTimeout(()=>this._toggleSettings(false), 200);
866
960
  }
867
961
  _switchInstance(isPrevious = false) {
868
- if (!this._animations[this._currentAnimation]) return;
962
+ if (!this._animations[this._currentAnimation]) {
963
+ return;
964
+ }
869
965
  try {
870
- if (this._lottieInstance) this._lottieInstance.destroy();
966
+ if (this._lottieInstance) {
967
+ this._lottieInstance.destroy();
968
+ }
871
969
  this._lottieInstance = Lottie.loadAnimation({
872
970
  ...this._getOptions(),
873
971
  animationData: this._animations[this._currentAnimation]
@@ -944,7 +1042,9 @@ class DotLottiePlayer extends LitElement {
944
1042
  this._intersectionObserver.disconnect();
945
1043
  this._intersectionObserver = undefined;
946
1044
  }
947
- if (this._lottieInstance) this._lottieInstance.destroy();
1045
+ if (this._lottieInstance) {
1046
+ this._lottieInstance.destroy();
1047
+ }
948
1048
  document.removeEventListener('visibilitychange', this._onVisibilityChange);
949
1049
  }
950
1050
  renderControls() {