@aarsteinmedia/dotlottie-player 6.1.1 → 6.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/CHANGELOG.md CHANGED
@@ -7,6 +7,18 @@ 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.1] - 11-11-2025
11
+
12
+ ### Changed
13
+
14
+ - Added enum to `mouseout` attribute
15
+
16
+ ## [6.2.0] - 06-11-2025
17
+
18
+ ### Changed
19
+
20
+ - Adjusted length of animation on animateOnScroll, to fit screen height dynamically.
21
+
10
22
  ## [6.1.1] - 13-10-2025
11
23
 
12
24
  ### Changed
package/dist/canvas.d.ts CHANGED
@@ -35,6 +35,12 @@ declare class DotLottiePlayerLight extends DotLottiePlayerBase {
35
35
  }): AnimationConfiguration<RendererType.SVG>;
36
36
  }
37
37
 
38
+ declare enum MouseOut {
39
+ Pause = "pause",
40
+ Reverse = "reverse",
41
+ Stop = "stop",
42
+ Void = "void"
43
+ }
38
44
  declare enum PlayerState {
39
45
  Completed = "completed",
40
46
  Destroyed = "destroyed",
@@ -148,8 +154,8 @@ declare abstract class DotLottiePlayerBase extends PropertyCallbackElement {
148
154
  get loop(): Loop;
149
155
  set mode(value: PlayMode);
150
156
  get mode(): PlayMode;
151
- set mouseout(value: 'void' | 'stop' | 'pause' | 'reverse');
152
- get mouseout(): "void" | "stop" | "pause" | "reverse";
157
+ set mouseout(value: MouseOut);
158
+ get mouseout(): MouseOut;
153
159
  set objectfit(value: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down');
154
160
  get objectfit(): "contain" | "cover" | "fill" | "none" | "scale-down";
155
161
  set once(value: boolean);
@@ -276,4 +282,4 @@ declare class DotLottiePlayerCanvas extends DotLottiePlayerBase {
276
282
  }): AnimationConfiguration<RendererType.Canvas>;
277
283
  }
278
284
 
279
- export { PlayerState, DotLottiePlayerCanvas as default, tagName };
285
+ export { MouseOut, PlayerState, DotLottiePlayerCanvas as default, tagName };
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';
@@ -145,6 +145,13 @@ var ObjectFit = /*#__PURE__*/ function(ObjectFit) {
145
145
  ObjectFit["ScaleDown"] = "scale-down";
146
146
  return ObjectFit;
147
147
  }({});
148
+ var MouseOut = /*#__PURE__*/ function(MouseOut) {
149
+ MouseOut["Pause"] = "pause";
150
+ MouseOut["Reverse"] = "reverse";
151
+ MouseOut["Stop"] = "stop";
152
+ MouseOut["Void"] = "void";
153
+ return MouseOut;
154
+ }({});
148
155
  var PlayerState = /*#__PURE__*/ function(PlayerState) {
149
156
  PlayerState["Completed"] = "completed";
150
157
  PlayerState["Destroyed"] = "destroyed";
@@ -496,15 +503,15 @@ const notImplemented = 'Method is not implemented';
496
503
  get mouseout() {
497
504
  const val = this.getAttribute('mouseout');
498
505
  switch(val){
499
- case 'void':
500
- case 'pause':
501
- case 'reverse':
506
+ case MouseOut.Void:
507
+ case MouseOut.Pause:
508
+ case MouseOut.Reverse:
502
509
  {
503
510
  return val;
504
511
  }
505
512
  default:
506
513
  {
507
- return 'stop';
514
+ return MouseOut.Stop;
508
515
  }
509
516
  }
510
517
  }
@@ -1455,23 +1462,29 @@ const notImplemented = 'Method is not implemented';
1455
1462
  console.warn('DotLottie: Scroll animations might not work properly in a Server Side Rendering context. Try to wrap this in a client component.');
1456
1463
  return;
1457
1464
  }
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
- });
1465
+ if (!this._playerState.visible) {
1466
+ return;
1474
1467
  }
1468
+ if (this._playerState.scrollTimeout) {
1469
+ clearTimeout(this._playerState.scrollTimeout);
1470
+ }
1471
+ this._playerState.scrollTimeout = setTimeout(()=>{
1472
+ this.playerState = PlayerState.Paused;
1473
+ }, 400);
1474
+ const { totalFrames } = this._lottieInstance;
1475
+ let scrollPosition = scrollY - this._playerState.scrollY;
1476
+ if (scrollY <= this._playerState.scrollY) {
1477
+ scrollPosition = this._playerState.scrollY - scrollY;
1478
+ }
1479
+ const scrollProgress = scrollPosition / innerHeight, currentFrame = clamp(scrollProgress * (totalFrames - 1), 1, totalFrames);
1480
+ requestAnimationFrame(()=>{
1481
+ if (currentFrame >= totalFrames) {
1482
+ this.playerState = PlayerState.Paused;
1483
+ return;
1484
+ }
1485
+ this.playerState = PlayerState.Playing;
1486
+ this._lottieInstance?.goToAndStop(currentFrame, true);
1487
+ });
1475
1488
  }
1476
1489
  _handleWindowBlur({ type }) {
1477
1490
  if (this.dontFreezeOnBlur) {
@@ -1540,7 +1553,7 @@ const notImplemented = 'Method is not implemented';
1540
1553
  if (!this.hover || !this._lottieInstance || isTouch()) {
1541
1554
  return;
1542
1555
  }
1543
- if (this.mouseout === 'reverse') {
1556
+ if (this.mouseout === MouseOut.Reverse) {
1544
1557
  this._lottieInstance.setDirection(1);
1545
1558
  }
1546
1559
  if (this.playerState === PlayerState.Completed) {
@@ -1559,16 +1572,16 @@ const notImplemented = 'Method is not implemented';
1559
1572
  return;
1560
1573
  }
1561
1574
  switch(this.mouseout){
1562
- case 'void':
1575
+ case MouseOut.Void:
1563
1576
  {
1564
1577
  break;
1565
1578
  }
1566
- case 'pause':
1579
+ case MouseOut.Pause:
1567
1580
  {
1568
1581
  this.pause();
1569
1582
  break;
1570
1583
  }
1571
- case 'reverse':
1584
+ case MouseOut.Reverse:
1572
1585
  {
1573
1586
  // const { direction = 1 } =
1574
1587
  // this._multiAnimationSettings.length > 0 ?
@@ -1738,4 +1751,4 @@ if (!isServer) {
1738
1751
  customElements.define(tagName, DotLottiePlayerCanvas);
1739
1752
  }
1740
1753
 
1741
- export { PlayerState, DotLottiePlayerCanvas as default, tagName };
1754
+ export { MouseOut, PlayerState, DotLottiePlayerCanvas as default, tagName };
package/dist/full.d.ts CHANGED
@@ -21,6 +21,12 @@ declare class DotLottiePlayerLight extends DotLottiePlayerBase {
21
21
  }): AnimationConfiguration<RendererType.SVG>;
22
22
  }
23
23
 
24
+ declare enum MouseOut {
25
+ Pause = "pause",
26
+ Reverse = "reverse",
27
+ Stop = "stop",
28
+ Void = "void"
29
+ }
24
30
  declare enum PlayerState {
25
31
  Completed = "completed",
26
32
  Destroyed = "destroyed",
@@ -148,8 +154,8 @@ declare abstract class DotLottiePlayerBase extends PropertyCallbackElement {
148
154
  get loop(): Loop;
149
155
  set mode(value: PlayMode);
150
156
  get mode(): PlayMode;
151
- set mouseout(value: 'void' | 'stop' | 'pause' | 'reverse');
152
- get mouseout(): "void" | "stop" | "pause" | "reverse";
157
+ set mouseout(value: MouseOut);
158
+ get mouseout(): MouseOut;
153
159
  set objectfit(value: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down');
154
160
  get objectfit(): "contain" | "cover" | "fill" | "none" | "scale-down";
155
161
  set once(value: boolean);
@@ -276,4 +282,4 @@ declare class DotLottiePlayer extends DotLottiePlayerBase {
276
282
  }): AnimationConfiguration<RendererType>;
277
283
  }
278
284
 
279
- export { PlayerState, DotLottiePlayer as default, tagName };
285
+ export { MouseOut, PlayerState, DotLottiePlayer as default, tagName };
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';
@@ -145,6 +145,13 @@ var ObjectFit = /*#__PURE__*/ function(ObjectFit) {
145
145
  ObjectFit["ScaleDown"] = "scale-down";
146
146
  return ObjectFit;
147
147
  }({});
148
+ var MouseOut = /*#__PURE__*/ function(MouseOut) {
149
+ MouseOut["Pause"] = "pause";
150
+ MouseOut["Reverse"] = "reverse";
151
+ MouseOut["Stop"] = "stop";
152
+ MouseOut["Void"] = "void";
153
+ return MouseOut;
154
+ }({});
148
155
  var PlayerState = /*#__PURE__*/ function(PlayerState) {
149
156
  PlayerState["Completed"] = "completed";
150
157
  PlayerState["Destroyed"] = "destroyed";
@@ -496,15 +503,15 @@ const notImplemented = 'Method is not implemented';
496
503
  get mouseout() {
497
504
  const val = this.getAttribute('mouseout');
498
505
  switch(val){
499
- case 'void':
500
- case 'pause':
501
- case 'reverse':
506
+ case MouseOut.Void:
507
+ case MouseOut.Pause:
508
+ case MouseOut.Reverse:
502
509
  {
503
510
  return val;
504
511
  }
505
512
  default:
506
513
  {
507
- return 'stop';
514
+ return MouseOut.Stop;
508
515
  }
509
516
  }
510
517
  }
@@ -1455,23 +1462,29 @@ const notImplemented = 'Method is not implemented';
1455
1462
  console.warn('DotLottie: Scroll animations might not work properly in a Server Side Rendering context. Try to wrap this in a client component.');
1456
1463
  return;
1457
1464
  }
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
- });
1465
+ if (!this._playerState.visible) {
1466
+ return;
1474
1467
  }
1468
+ if (this._playerState.scrollTimeout) {
1469
+ clearTimeout(this._playerState.scrollTimeout);
1470
+ }
1471
+ this._playerState.scrollTimeout = setTimeout(()=>{
1472
+ this.playerState = PlayerState.Paused;
1473
+ }, 400);
1474
+ const { totalFrames } = this._lottieInstance;
1475
+ let scrollPosition = scrollY - this._playerState.scrollY;
1476
+ if (scrollY <= this._playerState.scrollY) {
1477
+ scrollPosition = this._playerState.scrollY - scrollY;
1478
+ }
1479
+ const scrollProgress = scrollPosition / innerHeight, currentFrame = clamp(scrollProgress * (totalFrames - 1), 1, totalFrames);
1480
+ requestAnimationFrame(()=>{
1481
+ if (currentFrame >= totalFrames) {
1482
+ this.playerState = PlayerState.Paused;
1483
+ return;
1484
+ }
1485
+ this.playerState = PlayerState.Playing;
1486
+ this._lottieInstance?.goToAndStop(currentFrame, true);
1487
+ });
1475
1488
  }
1476
1489
  _handleWindowBlur({ type }) {
1477
1490
  if (this.dontFreezeOnBlur) {
@@ -1540,7 +1553,7 @@ const notImplemented = 'Method is not implemented';
1540
1553
  if (!this.hover || !this._lottieInstance || isTouch()) {
1541
1554
  return;
1542
1555
  }
1543
- if (this.mouseout === 'reverse') {
1556
+ if (this.mouseout === MouseOut.Reverse) {
1544
1557
  this._lottieInstance.setDirection(1);
1545
1558
  }
1546
1559
  if (this.playerState === PlayerState.Completed) {
@@ -1559,16 +1572,16 @@ const notImplemented = 'Method is not implemented';
1559
1572
  return;
1560
1573
  }
1561
1574
  switch(this.mouseout){
1562
- case 'void':
1575
+ case MouseOut.Void:
1563
1576
  {
1564
1577
  break;
1565
1578
  }
1566
- case 'pause':
1579
+ case MouseOut.Pause:
1567
1580
  {
1568
1581
  this.pause();
1569
1582
  break;
1570
1583
  }
1571
- case 'reverse':
1584
+ case MouseOut.Reverse:
1572
1585
  {
1573
1586
  // const { direction = 1 } =
1574
1587
  // this._multiAnimationSettings.length > 0 ?
@@ -1753,4 +1766,4 @@ if (!isServer) {
1753
1766
  customElements.define(tagName, DotLottiePlayer);
1754
1767
  }
1755
1768
 
1756
- export { PlayerState, DotLottiePlayer as default, tagName };
1769
+ export { MouseOut, PlayerState, DotLottiePlayer as default, tagName };
package/dist/light.d.ts CHANGED
@@ -21,6 +21,12 @@ declare class DotLottiePlayer extends DotLottiePlayerBase {
21
21
  }): AnimationConfiguration<RendererType>;
22
22
  }
23
23
 
24
+ declare enum MouseOut {
25
+ Pause = "pause",
26
+ Reverse = "reverse",
27
+ Stop = "stop",
28
+ Void = "void"
29
+ }
24
30
  declare enum PlayerState {
25
31
  Completed = "completed",
26
32
  Destroyed = "destroyed",
@@ -148,8 +154,8 @@ declare abstract class DotLottiePlayerBase extends PropertyCallbackElement {
148
154
  get loop(): Loop;
149
155
  set mode(value: PlayMode);
150
156
  get mode(): PlayMode;
151
- set mouseout(value: 'void' | 'stop' | 'pause' | 'reverse');
152
- get mouseout(): "void" | "stop" | "pause" | "reverse";
157
+ set mouseout(value: MouseOut);
158
+ get mouseout(): MouseOut;
153
159
  set objectfit(value: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down');
154
160
  get objectfit(): "contain" | "cover" | "fill" | "none" | "scale-down";
155
161
  set once(value: boolean);
@@ -276,4 +282,4 @@ declare class DotLottiePlayerLight extends DotLottiePlayerBase {
276
282
  }): AnimationConfiguration<RendererType.SVG>;
277
283
  }
278
284
 
279
- export { PlayerState, DotLottiePlayerLight as default, tagName };
285
+ export { MouseOut, PlayerState, DotLottiePlayerLight as default, tagName };
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';
@@ -145,6 +145,13 @@ var ObjectFit = /*#__PURE__*/ function(ObjectFit) {
145
145
  ObjectFit["ScaleDown"] = "scale-down";
146
146
  return ObjectFit;
147
147
  }({});
148
+ var MouseOut = /*#__PURE__*/ function(MouseOut) {
149
+ MouseOut["Pause"] = "pause";
150
+ MouseOut["Reverse"] = "reverse";
151
+ MouseOut["Stop"] = "stop";
152
+ MouseOut["Void"] = "void";
153
+ return MouseOut;
154
+ }({});
148
155
  var PlayerState = /*#__PURE__*/ function(PlayerState) {
149
156
  PlayerState["Completed"] = "completed";
150
157
  PlayerState["Destroyed"] = "destroyed";
@@ -496,15 +503,15 @@ const notImplemented = 'Method is not implemented';
496
503
  get mouseout() {
497
504
  const val = this.getAttribute('mouseout');
498
505
  switch(val){
499
- case 'void':
500
- case 'pause':
501
- case 'reverse':
506
+ case MouseOut.Void:
507
+ case MouseOut.Pause:
508
+ case MouseOut.Reverse:
502
509
  {
503
510
  return val;
504
511
  }
505
512
  default:
506
513
  {
507
- return 'stop';
514
+ return MouseOut.Stop;
508
515
  }
509
516
  }
510
517
  }
@@ -1455,23 +1462,29 @@ const notImplemented = 'Method is not implemented';
1455
1462
  console.warn('DotLottie: Scroll animations might not work properly in a Server Side Rendering context. Try to wrap this in a client component.');
1456
1463
  return;
1457
1464
  }
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
- });
1465
+ if (!this._playerState.visible) {
1466
+ return;
1474
1467
  }
1468
+ if (this._playerState.scrollTimeout) {
1469
+ clearTimeout(this._playerState.scrollTimeout);
1470
+ }
1471
+ this._playerState.scrollTimeout = setTimeout(()=>{
1472
+ this.playerState = PlayerState.Paused;
1473
+ }, 400);
1474
+ const { totalFrames } = this._lottieInstance;
1475
+ let scrollPosition = scrollY - this._playerState.scrollY;
1476
+ if (scrollY <= this._playerState.scrollY) {
1477
+ scrollPosition = this._playerState.scrollY - scrollY;
1478
+ }
1479
+ const scrollProgress = scrollPosition / innerHeight, currentFrame = clamp(scrollProgress * (totalFrames - 1), 1, totalFrames);
1480
+ requestAnimationFrame(()=>{
1481
+ if (currentFrame >= totalFrames) {
1482
+ this.playerState = PlayerState.Paused;
1483
+ return;
1484
+ }
1485
+ this.playerState = PlayerState.Playing;
1486
+ this._lottieInstance?.goToAndStop(currentFrame, true);
1487
+ });
1475
1488
  }
1476
1489
  _handleWindowBlur({ type }) {
1477
1490
  if (this.dontFreezeOnBlur) {
@@ -1540,7 +1553,7 @@ const notImplemented = 'Method is not implemented';
1540
1553
  if (!this.hover || !this._lottieInstance || isTouch()) {
1541
1554
  return;
1542
1555
  }
1543
- if (this.mouseout === 'reverse') {
1556
+ if (this.mouseout === MouseOut.Reverse) {
1544
1557
  this._lottieInstance.setDirection(1);
1545
1558
  }
1546
1559
  if (this.playerState === PlayerState.Completed) {
@@ -1559,16 +1572,16 @@ const notImplemented = 'Method is not implemented';
1559
1572
  return;
1560
1573
  }
1561
1574
  switch(this.mouseout){
1562
- case 'void':
1575
+ case MouseOut.Void:
1563
1576
  {
1564
1577
  break;
1565
1578
  }
1566
- case 'pause':
1579
+ case MouseOut.Pause:
1567
1580
  {
1568
1581
  this.pause();
1569
1582
  break;
1570
1583
  }
1571
- case 'reverse':
1584
+ case MouseOut.Reverse:
1572
1585
  {
1573
1586
  // const { direction = 1 } =
1574
1587
  // this._multiAnimationSettings.length > 0 ?
@@ -1737,4 +1750,4 @@ if (!isServer) {
1737
1750
  customElements.define(tagName, DotLottiePlayerLight);
1738
1751
  }
1739
1752
 
1740
- export { PlayerState, DotLottiePlayerLight as default, tagName };
1753
+ export { MouseOut, PlayerState, DotLottiePlayerLight as default, tagName };
package/dist/svg.d.ts CHANGED
@@ -35,6 +35,12 @@ declare class DotLottiePlayerLight extends DotLottiePlayerBase {
35
35
  }): AnimationConfiguration<RendererType.SVG>;
36
36
  }
37
37
 
38
+ declare enum MouseOut {
39
+ Pause = "pause",
40
+ Reverse = "reverse",
41
+ Stop = "stop",
42
+ Void = "void"
43
+ }
38
44
  declare enum PlayerState {
39
45
  Completed = "completed",
40
46
  Destroyed = "destroyed",
@@ -148,8 +154,8 @@ declare abstract class DotLottiePlayerBase extends PropertyCallbackElement {
148
154
  get loop(): Loop;
149
155
  set mode(value: PlayMode);
150
156
  get mode(): PlayMode;
151
- set mouseout(value: 'void' | 'stop' | 'pause' | 'reverse');
152
- get mouseout(): "void" | "stop" | "pause" | "reverse";
157
+ set mouseout(value: MouseOut);
158
+ get mouseout(): MouseOut;
153
159
  set objectfit(value: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down');
154
160
  get objectfit(): "contain" | "cover" | "fill" | "none" | "scale-down";
155
161
  set once(value: boolean);
@@ -276,4 +282,4 @@ declare class DotLottiePlayerSVG extends DotLottiePlayerBase {
276
282
  }): AnimationConfiguration<RendererType.SVG>;
277
283
  }
278
284
 
279
- export { PlayerState, DotLottiePlayerSVG as default, tagName };
285
+ export { MouseOut, PlayerState, DotLottiePlayerSVG as default, tagName };
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';
@@ -145,6 +145,13 @@ var ObjectFit = /*#__PURE__*/ function(ObjectFit) {
145
145
  ObjectFit["ScaleDown"] = "scale-down";
146
146
  return ObjectFit;
147
147
  }({});
148
+ var MouseOut = /*#__PURE__*/ function(MouseOut) {
149
+ MouseOut["Pause"] = "pause";
150
+ MouseOut["Reverse"] = "reverse";
151
+ MouseOut["Stop"] = "stop";
152
+ MouseOut["Void"] = "void";
153
+ return MouseOut;
154
+ }({});
148
155
  var PlayerState = /*#__PURE__*/ function(PlayerState) {
149
156
  PlayerState["Completed"] = "completed";
150
157
  PlayerState["Destroyed"] = "destroyed";
@@ -496,15 +503,15 @@ const notImplemented = 'Method is not implemented';
496
503
  get mouseout() {
497
504
  const val = this.getAttribute('mouseout');
498
505
  switch(val){
499
- case 'void':
500
- case 'pause':
501
- case 'reverse':
506
+ case MouseOut.Void:
507
+ case MouseOut.Pause:
508
+ case MouseOut.Reverse:
502
509
  {
503
510
  return val;
504
511
  }
505
512
  default:
506
513
  {
507
- return 'stop';
514
+ return MouseOut.Stop;
508
515
  }
509
516
  }
510
517
  }
@@ -1455,23 +1462,29 @@ const notImplemented = 'Method is not implemented';
1455
1462
  console.warn('DotLottie: Scroll animations might not work properly in a Server Side Rendering context. Try to wrap this in a client component.');
1456
1463
  return;
1457
1464
  }
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
- });
1465
+ if (!this._playerState.visible) {
1466
+ return;
1474
1467
  }
1468
+ if (this._playerState.scrollTimeout) {
1469
+ clearTimeout(this._playerState.scrollTimeout);
1470
+ }
1471
+ this._playerState.scrollTimeout = setTimeout(()=>{
1472
+ this.playerState = PlayerState.Paused;
1473
+ }, 400);
1474
+ const { totalFrames } = this._lottieInstance;
1475
+ let scrollPosition = scrollY - this._playerState.scrollY;
1476
+ if (scrollY <= this._playerState.scrollY) {
1477
+ scrollPosition = this._playerState.scrollY - scrollY;
1478
+ }
1479
+ const scrollProgress = scrollPosition / innerHeight, currentFrame = clamp(scrollProgress * (totalFrames - 1), 1, totalFrames);
1480
+ requestAnimationFrame(()=>{
1481
+ if (currentFrame >= totalFrames) {
1482
+ this.playerState = PlayerState.Paused;
1483
+ return;
1484
+ }
1485
+ this.playerState = PlayerState.Playing;
1486
+ this._lottieInstance?.goToAndStop(currentFrame, true);
1487
+ });
1475
1488
  }
1476
1489
  _handleWindowBlur({ type }) {
1477
1490
  if (this.dontFreezeOnBlur) {
@@ -1540,7 +1553,7 @@ const notImplemented = 'Method is not implemented';
1540
1553
  if (!this.hover || !this._lottieInstance || isTouch()) {
1541
1554
  return;
1542
1555
  }
1543
- if (this.mouseout === 'reverse') {
1556
+ if (this.mouseout === MouseOut.Reverse) {
1544
1557
  this._lottieInstance.setDirection(1);
1545
1558
  }
1546
1559
  if (this.playerState === PlayerState.Completed) {
@@ -1559,16 +1572,16 @@ const notImplemented = 'Method is not implemented';
1559
1572
  return;
1560
1573
  }
1561
1574
  switch(this.mouseout){
1562
- case 'void':
1575
+ case MouseOut.Void:
1563
1576
  {
1564
1577
  break;
1565
1578
  }
1566
- case 'pause':
1579
+ case MouseOut.Pause:
1567
1580
  {
1568
1581
  this.pause();
1569
1582
  break;
1570
1583
  }
1571
- case 'reverse':
1584
+ case MouseOut.Reverse:
1572
1585
  {
1573
1586
  // const { direction = 1 } =
1574
1587
  // this._multiAnimationSettings.length > 0 ?
@@ -1737,4 +1750,4 @@ if (!isServer) {
1737
1750
  customElements.define(tagName, DotLottiePlayerSVG);
1738
1751
  }
1739
1752
 
1740
- export { PlayerState, DotLottiePlayerSVG as default, tagName };
1753
+ export { MouseOut, PlayerState, DotLottiePlayerSVG as default, tagName };