@aarsteinmedia/dotlottie-player 2.1.8 → 2.2.1

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/cjs/index.js CHANGED
@@ -38,7 +38,6 @@ exports.PlayerEvents = void 0;
38
38
  })(exports.PlayerEvents || (exports.PlayerEvents = {}));
39
39
  class CustomError extends Error {
40
40
  }
41
-
42
41
  const addExt = (ext, str)=>{
43
42
  if (!str) return;
44
43
  if (getExt(str)) {
@@ -300,7 +299,7 @@ const addExt = (ext, str)=>{
300
299
  };
301
300
 
302
301
  var name = "@aarsteinmedia/dotlottie-player";
303
- var version = "2.1.8";
302
+ var version = "2.2.1";
304
303
  var description = "Web Component for playing Lottie animations in your web app. Previously @johanaarstein/dotlottie-player";
305
304
  var exports$1 = {
306
305
  ".": {
@@ -431,13 +430,13 @@ function _ts_decorate(decorators, target, key, desc) {
431
430
  }
432
431
  class DotLottiePlayer extends lit.LitElement {
433
432
  _getOptions() {
434
- const preserveAspectRatio = this.preserveAspectRatio ?? (this.objectfit && aspectRatio(this.objectfit)), initialSegment = !this.segment || this.segment.some((val)=>val < 0) ? undefined : this.segment.every((val)=>val > 0) ? [
433
+ 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 = 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) ? [
435
434
  this.segment[0] - 1,
436
435
  this.segment[1] - 1
437
436
  ] : this.segment, options = {
438
437
  container: this.container,
439
- loop: !!this.loop,
440
- autoplay: !!this.autoplay,
438
+ loop,
439
+ autoplay,
441
440
  renderer: this.renderer,
442
441
  initialSegment,
443
442
  rendererSettings: {
@@ -502,8 +501,9 @@ class DotLottiePlayer extends lit.LitElement {
502
501
  return;
503
502
  }
504
503
  this._addEventListeners();
505
- this.setSpeed(this.speed);
506
- this.setDirection(this.direction ?? 1);
504
+ const speed = this.multiAnimationSettings?.[this._currentAnimation]?.speed ?? this.speed ?? this._manifest.animations[this._currentAnimation].speed, direction = this.multiAnimationSettings?.[this._currentAnimation]?.direction ?? this.direction ?? this._manifest.animations[this._currentAnimation].direction ?? 1;
505
+ this.setSpeed(speed);
506
+ this.setDirection(direction);
507
507
  this.setSubframe(!!this.subframe);
508
508
  if (this.autoplay) {
509
509
  if (this.direction === -1) this.seek('99%');
@@ -538,9 +538,9 @@ class DotLottiePlayer extends lit.LitElement {
538
538
  if (!this._lottieInstance) {
539
539
  return;
540
540
  }
541
- const { firstFrame, totalFrames, playDirection } = this._lottieInstance;
541
+ const { firstFrame, totalFrames, playDirection } = this._lottieInstance, isBounce = this.mode === exports.PlayMode.Bounce || this._manifest.animations[this._currentAnimation].mode === exports.PlayMode.Bounce;
542
542
  if (this.count) {
543
- this.mode === exports.PlayMode.Bounce ? this._playerState.count += 1 : this._playerState.count += 0.5;
543
+ isBounce ? this._playerState.count += 1 : this._playerState.count += 0.5;
544
544
  if (this._playerState.count >= this.count) {
545
545
  this.setLooping(false);
546
546
  this.currentState = exports.PlayerState.Completed;
@@ -549,7 +549,7 @@ class DotLottiePlayer extends lit.LitElement {
549
549
  }
550
550
  }
551
551
  this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Loop));
552
- if (this.mode === exports.PlayMode.Bounce) {
552
+ if (isBounce) {
553
553
  this._lottieInstance?.goToAndStop(playDirection === -1 ? firstFrame : totalFrames * 0.99, true);
554
554
  this._lottieInstance?.setDirection(playDirection * -1);
555
555
  return setTimeout(()=>{
@@ -761,6 +761,11 @@ class DotLottiePlayer extends lit.LitElement {
761
761
  this._lottieInstance.setLoop(value);
762
762
  }
763
763
  }
764
+ setMultiAnimationSettings(settings) {
765
+ if (this._lottieInstance) {
766
+ this.multiAnimationSettings = settings;
767
+ }
768
+ }
764
769
  togglePlay() {
765
770
  if (!this._lottieInstance) return;
766
771
  const { currentFrame, playDirection, totalFrames } = this._lottieInstance;
@@ -966,6 +971,11 @@ _ts_decorate([
966
971
  type: String
967
972
  })
968
973
  ], DotLottiePlayer.prototype, "mode", void 0);
974
+ _ts_decorate([
975
+ decorators_js.property({
976
+ type: Array
977
+ })
978
+ ], DotLottiePlayer.prototype, "multiAnimationSettings", void 0);
969
979
  _ts_decorate([
970
980
  decorators_js.property({
971
981
  type: String