@aarsteinmedia/dotlottie-player 6.1.1 → 6.2.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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ 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
+ ## [6.2.0] - 13-10-2025
11
+
12
+ ### Changed
13
+
14
+ - Adjusted length of animation on animateOnScroll, to fit screen height dynamically.
15
+
10
16
  ## [6.1.1] - 13-10-2025
11
17
 
12
18
  ### Changed
package/dist/canvas.js CHANGED
@@ -1,4 +1,4 @@
1
- import { isServer, PlayMode, PreserveAspectRatio, namespaceSVG, RendererType, createElementID, PlayerEvents, download, getFilename } from '@aarsteinmedia/lottie-web/utils';
1
+ import { isServer, PlayMode, PreserveAspectRatio, namespaceSVG, RendererType, createElementID, PlayerEvents, download, getFilename, clamp } from '@aarsteinmedia/lottie-web/utils';
2
2
  export { PlayMode, PlayerEvents } from '@aarsteinmedia/lottie-web/utils';
3
3
  import Lottie from '@aarsteinmedia/lottie-web/canvas';
4
4
  import { convert, getAnimationData } from '@aarsteinmedia/lottie-web/dotlottie';
@@ -1455,23 +1455,29 @@ const notImplemented = 'Method is not implemented';
1455
1455
  console.warn('DotLottie: Scroll animations might not work properly in a Server Side Rendering context. Try to wrap this in a client component.');
1456
1456
  return;
1457
1457
  }
1458
- if (this._playerState.visible) {
1459
- if (this._playerState.scrollTimeout) {
1460
- clearTimeout(this._playerState.scrollTimeout);
1461
- }
1462
- this._playerState.scrollTimeout = setTimeout(()=>{
1463
- this.playerState = PlayerState.Paused;
1464
- }, 400);
1465
- const adjustedScroll = scrollY > this._playerState.scrollY ? scrollY - this._playerState.scrollY : this._playerState.scrollY - scrollY, clampedScroll = Math.min(Math.max(adjustedScroll / 3, 1), this._lottieInstance.totalFrames * 3), roundedScroll = clampedScroll / 3;
1466
- requestAnimationFrame(()=>{
1467
- if (roundedScroll < (this._lottieInstance?.totalFrames ?? 0)) {
1468
- this.playerState = PlayerState.Playing;
1469
- this._lottieInstance?.goToAndStop(roundedScroll, true);
1470
- } else {
1471
- this.playerState = PlayerState.Paused;
1472
- }
1473
- });
1458
+ if (!this._playerState.visible) {
1459
+ return;
1474
1460
  }
1461
+ if (this._playerState.scrollTimeout) {
1462
+ clearTimeout(this._playerState.scrollTimeout);
1463
+ }
1464
+ this._playerState.scrollTimeout = setTimeout(()=>{
1465
+ this.playerState = PlayerState.Paused;
1466
+ }, 400);
1467
+ const { totalFrames } = this._lottieInstance;
1468
+ let scrollPosition = scrollY - this._playerState.scrollY;
1469
+ if (scrollY <= this._playerState.scrollY) {
1470
+ scrollPosition = this._playerState.scrollY - scrollY;
1471
+ }
1472
+ const scrollProgress = scrollPosition / innerHeight, currentFrame = clamp(scrollProgress * (totalFrames - 1), 1, totalFrames);
1473
+ requestAnimationFrame(()=>{
1474
+ if (currentFrame >= totalFrames) {
1475
+ this.playerState = PlayerState.Paused;
1476
+ return;
1477
+ }
1478
+ this.playerState = PlayerState.Playing;
1479
+ this._lottieInstance?.goToAndStop(currentFrame, true);
1480
+ });
1475
1481
  }
1476
1482
  _handleWindowBlur({ type }) {
1477
1483
  if (this.dontFreezeOnBlur) {
package/dist/full.js CHANGED
@@ -1,4 +1,4 @@
1
- import { isServer, PlayMode, PreserveAspectRatio, namespaceSVG, RendererType, createElementID, PlayerEvents, download, getFilename } from '@aarsteinmedia/lottie-web/utils';
1
+ import { isServer, PlayMode, PreserveAspectRatio, namespaceSVG, RendererType, createElementID, PlayerEvents, download, getFilename, clamp } from '@aarsteinmedia/lottie-web/utils';
2
2
  export { PlayMode, PlayerEvents } from '@aarsteinmedia/lottie-web/utils';
3
3
  import Lottie from '@aarsteinmedia/lottie-web';
4
4
  import { convert, getAnimationData, addAnimation } from '@aarsteinmedia/lottie-web/dotlottie';
@@ -1455,23 +1455,29 @@ const notImplemented = 'Method is not implemented';
1455
1455
  console.warn('DotLottie: Scroll animations might not work properly in a Server Side Rendering context. Try to wrap this in a client component.');
1456
1456
  return;
1457
1457
  }
1458
- if (this._playerState.visible) {
1459
- if (this._playerState.scrollTimeout) {
1460
- clearTimeout(this._playerState.scrollTimeout);
1461
- }
1462
- this._playerState.scrollTimeout = setTimeout(()=>{
1463
- this.playerState = PlayerState.Paused;
1464
- }, 400);
1465
- const adjustedScroll = scrollY > this._playerState.scrollY ? scrollY - this._playerState.scrollY : this._playerState.scrollY - scrollY, clampedScroll = Math.min(Math.max(adjustedScroll / 3, 1), this._lottieInstance.totalFrames * 3), roundedScroll = clampedScroll / 3;
1466
- requestAnimationFrame(()=>{
1467
- if (roundedScroll < (this._lottieInstance?.totalFrames ?? 0)) {
1468
- this.playerState = PlayerState.Playing;
1469
- this._lottieInstance?.goToAndStop(roundedScroll, true);
1470
- } else {
1471
- this.playerState = PlayerState.Paused;
1472
- }
1473
- });
1458
+ if (!this._playerState.visible) {
1459
+ return;
1474
1460
  }
1461
+ if (this._playerState.scrollTimeout) {
1462
+ clearTimeout(this._playerState.scrollTimeout);
1463
+ }
1464
+ this._playerState.scrollTimeout = setTimeout(()=>{
1465
+ this.playerState = PlayerState.Paused;
1466
+ }, 400);
1467
+ const { totalFrames } = this._lottieInstance;
1468
+ let scrollPosition = scrollY - this._playerState.scrollY;
1469
+ if (scrollY <= this._playerState.scrollY) {
1470
+ scrollPosition = this._playerState.scrollY - scrollY;
1471
+ }
1472
+ const scrollProgress = scrollPosition / innerHeight, currentFrame = clamp(scrollProgress * (totalFrames - 1), 1, totalFrames);
1473
+ requestAnimationFrame(()=>{
1474
+ if (currentFrame >= totalFrames) {
1475
+ this.playerState = PlayerState.Paused;
1476
+ return;
1477
+ }
1478
+ this.playerState = PlayerState.Playing;
1479
+ this._lottieInstance?.goToAndStop(currentFrame, true);
1480
+ });
1475
1481
  }
1476
1482
  _handleWindowBlur({ type }) {
1477
1483
  if (this.dontFreezeOnBlur) {
package/dist/light.js CHANGED
@@ -1,4 +1,4 @@
1
- import { isServer, PlayMode, PreserveAspectRatio, namespaceSVG, RendererType, createElementID, PlayerEvents, download, getFilename } from '@aarsteinmedia/lottie-web/utils';
1
+ import { isServer, PlayMode, PreserveAspectRatio, namespaceSVG, RendererType, createElementID, PlayerEvents, download, getFilename, clamp } from '@aarsteinmedia/lottie-web/utils';
2
2
  export { PlayMode, PlayerEvents } from '@aarsteinmedia/lottie-web/utils';
3
3
  import Lottie from '@aarsteinmedia/lottie-web/light';
4
4
  import { convert, getAnimationData } from '@aarsteinmedia/lottie-web/dotlottie';
@@ -1455,23 +1455,29 @@ const notImplemented = 'Method is not implemented';
1455
1455
  console.warn('DotLottie: Scroll animations might not work properly in a Server Side Rendering context. Try to wrap this in a client component.');
1456
1456
  return;
1457
1457
  }
1458
- if (this._playerState.visible) {
1459
- if (this._playerState.scrollTimeout) {
1460
- clearTimeout(this._playerState.scrollTimeout);
1461
- }
1462
- this._playerState.scrollTimeout = setTimeout(()=>{
1463
- this.playerState = PlayerState.Paused;
1464
- }, 400);
1465
- const adjustedScroll = scrollY > this._playerState.scrollY ? scrollY - this._playerState.scrollY : this._playerState.scrollY - scrollY, clampedScroll = Math.min(Math.max(adjustedScroll / 3, 1), this._lottieInstance.totalFrames * 3), roundedScroll = clampedScroll / 3;
1466
- requestAnimationFrame(()=>{
1467
- if (roundedScroll < (this._lottieInstance?.totalFrames ?? 0)) {
1468
- this.playerState = PlayerState.Playing;
1469
- this._lottieInstance?.goToAndStop(roundedScroll, true);
1470
- } else {
1471
- this.playerState = PlayerState.Paused;
1472
- }
1473
- });
1458
+ if (!this._playerState.visible) {
1459
+ return;
1474
1460
  }
1461
+ if (this._playerState.scrollTimeout) {
1462
+ clearTimeout(this._playerState.scrollTimeout);
1463
+ }
1464
+ this._playerState.scrollTimeout = setTimeout(()=>{
1465
+ this.playerState = PlayerState.Paused;
1466
+ }, 400);
1467
+ const { totalFrames } = this._lottieInstance;
1468
+ let scrollPosition = scrollY - this._playerState.scrollY;
1469
+ if (scrollY <= this._playerState.scrollY) {
1470
+ scrollPosition = this._playerState.scrollY - scrollY;
1471
+ }
1472
+ const scrollProgress = scrollPosition / innerHeight, currentFrame = clamp(scrollProgress * (totalFrames - 1), 1, totalFrames);
1473
+ requestAnimationFrame(()=>{
1474
+ if (currentFrame >= totalFrames) {
1475
+ this.playerState = PlayerState.Paused;
1476
+ return;
1477
+ }
1478
+ this.playerState = PlayerState.Playing;
1479
+ this._lottieInstance?.goToAndStop(currentFrame, true);
1480
+ });
1475
1481
  }
1476
1482
  _handleWindowBlur({ type }) {
1477
1483
  if (this.dontFreezeOnBlur) {
package/dist/svg.js CHANGED
@@ -1,4 +1,4 @@
1
- import { isServer, PlayMode, PreserveAspectRatio, namespaceSVG, RendererType, createElementID, PlayerEvents, download, getFilename } from '@aarsteinmedia/lottie-web/utils';
1
+ import { isServer, PlayMode, PreserveAspectRatio, namespaceSVG, RendererType, createElementID, PlayerEvents, download, getFilename, clamp } from '@aarsteinmedia/lottie-web/utils';
2
2
  export { PlayMode, PlayerEvents } from '@aarsteinmedia/lottie-web/utils';
3
3
  import Lottie from '@aarsteinmedia/lottie-web/svg';
4
4
  import { convert, getAnimationData } from '@aarsteinmedia/lottie-web/dotlottie';
@@ -1455,23 +1455,29 @@ const notImplemented = 'Method is not implemented';
1455
1455
  console.warn('DotLottie: Scroll animations might not work properly in a Server Side Rendering context. Try to wrap this in a client component.');
1456
1456
  return;
1457
1457
  }
1458
- if (this._playerState.visible) {
1459
- if (this._playerState.scrollTimeout) {
1460
- clearTimeout(this._playerState.scrollTimeout);
1461
- }
1462
- this._playerState.scrollTimeout = setTimeout(()=>{
1463
- this.playerState = PlayerState.Paused;
1464
- }, 400);
1465
- const adjustedScroll = scrollY > this._playerState.scrollY ? scrollY - this._playerState.scrollY : this._playerState.scrollY - scrollY, clampedScroll = Math.min(Math.max(adjustedScroll / 3, 1), this._lottieInstance.totalFrames * 3), roundedScroll = clampedScroll / 3;
1466
- requestAnimationFrame(()=>{
1467
- if (roundedScroll < (this._lottieInstance?.totalFrames ?? 0)) {
1468
- this.playerState = PlayerState.Playing;
1469
- this._lottieInstance?.goToAndStop(roundedScroll, true);
1470
- } else {
1471
- this.playerState = PlayerState.Paused;
1472
- }
1473
- });
1458
+ if (!this._playerState.visible) {
1459
+ return;
1474
1460
  }
1461
+ if (this._playerState.scrollTimeout) {
1462
+ clearTimeout(this._playerState.scrollTimeout);
1463
+ }
1464
+ this._playerState.scrollTimeout = setTimeout(()=>{
1465
+ this.playerState = PlayerState.Paused;
1466
+ }, 400);
1467
+ const { totalFrames } = this._lottieInstance;
1468
+ let scrollPosition = scrollY - this._playerState.scrollY;
1469
+ if (scrollY <= this._playerState.scrollY) {
1470
+ scrollPosition = this._playerState.scrollY - scrollY;
1471
+ }
1472
+ const scrollProgress = scrollPosition / innerHeight, currentFrame = clamp(scrollProgress * (totalFrames - 1), 1, totalFrames);
1473
+ requestAnimationFrame(()=>{
1474
+ if (currentFrame >= totalFrames) {
1475
+ this.playerState = PlayerState.Paused;
1476
+ return;
1477
+ }
1478
+ this.playerState = PlayerState.Playing;
1479
+ this._lottieInstance?.goToAndStop(currentFrame, true);
1480
+ });
1475
1481
  }
1476
1482
  _handleWindowBlur({ type }) {
1477
1483
  if (this.dontFreezeOnBlur) {