@aarsteinmedia/dotlottie-player 5.0.2 → 5.0.4

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 CHANGED
@@ -7,7 +7,13 @@ 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
- ## [5.0.2] - 23-05-2025
10
+ ## [5.0.4] - 31-05-2025
11
+
12
+ ### Changed
13
+
14
+ - Fixed bug preventing autoplay on some animations
15
+
16
+ ## [5.0.3] - 28-05-2025
11
17
 
12
18
  ### Changed
13
19
 
@@ -217,6 +223,8 @@ Changelog was only added since [3.2.3], so it's not exhaustive. [Please report a
217
223
  - Removed dependencies
218
224
  - `@lit`
219
225
 
226
+ [5.0.4]: https://www.npmjs.com/package/@aarsteinmedia/dotlottie-player/v/5.0.4
227
+ [5.0.3]: https://www.npmjs.com/package/@aarsteinmedia/dotlottie-player/v/5.0.3
220
228
  [5.0.1]: https://www.npmjs.com/package/@aarsteinmedia/dotlottie-player/v/5.0.1
221
229
  [5.0.0]: https://www.npmjs.com/package/@aarsteinmedia/dotlottie-player/v/5.0.0
222
230
  [4.0.14]: https://www.npmjs.com/package/@aarsteinmedia/dotlottie-player/v/4.0.14
package/dist/index.js CHANGED
@@ -632,6 +632,7 @@ const unzip = async (resp)=>{
632
632
  }
633
633
  };
634
634
 
635
+ const generator = '@aarsteinmedia/dotlottie-player';
635
636
  /**
636
637
  * DotLottie Player Web Component.
637
638
  */ class DotLottiePlayer extends PropertyCallbackElement {
@@ -934,7 +935,7 @@ const unzip = async (resp)=>{
934
935
  if (!manifest) {
935
936
  throw new Error('Manifest is not set');
936
937
  }
937
- manifest.generator = '@aarsteinmedia/dotlottie-player';
938
+ manifest.generator = generator;
938
939
  const { length } = configs;
939
940
  for(let i = 0; i < length; i++){
940
941
  const { url } = configs[i], { animations: animationsToAdd } = await getAnimationData(url);
@@ -971,7 +972,7 @@ const unzip = async (resp)=>{
971
972
  /**
972
973
  * Runs when the value of an attribute is changed on the component.
973
974
  */ async attributeChangedCallback(name, _oldValue, value) {
974
- if (!this._lottieInstance) {
975
+ if (!this._lottieInstance || !this.shadow) {
975
976
  return;
976
977
  }
977
978
  if (name === 'animateOnScroll') {
@@ -1015,14 +1016,14 @@ const unzip = async (resp)=>{
1015
1016
  this._container.removeEventListener('mouseleave', this._mouseLeave);
1016
1017
  }
1017
1018
  if (name === 'loop') {
1018
- const toggleLoop = this.shadow?.querySelector('.toggleLoop');
1019
+ const toggleLoop = this.shadow.querySelector('.toggleLoop');
1019
1020
  if (toggleLoop instanceof HTMLButtonElement) {
1020
1021
  toggleLoop.dataset.active = value;
1021
1022
  }
1022
1023
  this.setLoop(value === '' || Boolean(value));
1023
1024
  }
1024
1025
  if (name === 'mode') {
1025
- const toggleBoomerang = this.shadow?.querySelector('.toggleBoomerang');
1026
+ const toggleBoomerang = this.shadow.querySelector('.toggleBoomerang');
1026
1027
  if (toggleBoomerang instanceof HTMLButtonElement) {
1027
1028
  toggleBoomerang.dataset.active = (value === PlayMode.Bounce).toString();
1028
1029
  }
@@ -1085,7 +1086,7 @@ const unzip = async (resp)=>{
1085
1086
  fileName: `${getFilename(fileName || src || 'converted')}.lottie`,
1086
1087
  manifest: {
1087
1088
  ...manifest ?? this._manifest,
1088
- generator: '[[GENERATOR]]'
1089
+ generator
1089
1090
  },
1090
1091
  shouldDownload
1091
1092
  });
@@ -1093,7 +1094,7 @@ const unzip = async (resp)=>{
1093
1094
  /**
1094
1095
  * Destroy animation and element.
1095
1096
  */ destroy() {
1096
- if (!this._lottieInstance) {
1097
+ if (!this._lottieInstance?.destroy) {
1097
1098
  return;
1098
1099
  }
1099
1100
  this.playerState = PlayerState.Destroyed;
@@ -1111,12 +1112,10 @@ const unzip = async (resp)=>{
1111
1112
  this._intersectionObserver.disconnect();
1112
1113
  this._intersectionObserver = undefined;
1113
1114
  }
1114
- // Destroy the animation instance
1115
- if (this._lottieInstance) {
1116
- this._lottieInstance.destroy();
1117
- }
1118
1115
  // Remove the attached Visibility API's change event listener
1119
1116
  document.removeEventListener('visibilitychange', this._onVisibilityChange);
1117
+ // Destroy the animation instance
1118
+ this.destroy();
1120
1119
  }
1121
1120
  /**
1122
1121
  * Returns the lottie-web instance used in the component.
@@ -1157,6 +1156,10 @@ const unzip = async (resp)=>{
1157
1156
  if (this._multiAnimationSettings.length > 0 && this._multiAnimationSettings[this._currentAnimation]?.mode) {
1158
1157
  this._isBounce = this._multiAnimationSettings[this._currentAnimation].mode === PlayMode.Bounce;
1159
1158
  }
1159
+ if (manifest?.animations.length === 1) {
1160
+ manifest.animations[0].autoplay = this.autoplay;
1161
+ manifest.animations[0].loop = this.loop;
1162
+ }
1160
1163
  this._isDotLottie = Boolean(isDotLottie);
1161
1164
  this._animations = animations;
1162
1165
  this._manifest = manifest ?? {
@@ -1172,9 +1175,7 @@ const unzip = async (resp)=>{
1172
1175
  ]
1173
1176
  };
1174
1177
  // Clear previous animation, if any
1175
- if (this._lottieInstance) {
1176
- this._lottieInstance.destroy();
1177
- }
1178
+ this._lottieInstance?.destroy();
1178
1179
  this.playerState = PlayerState.Stopped;
1179
1180
  if (!this.animateOnScroll && (this.autoplay || this._multiAnimationSettings[this._currentAnimation]?.autoplay)) {
1180
1181
  this.playerState = PlayerState.Playing;