animejs 4.2.0 → 4.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.
Files changed (127) hide show
  1. package/dist/bundles/anime.esm.js +98 -47
  2. package/dist/bundles/anime.esm.min.js +2 -2
  3. package/dist/bundles/anime.umd.js +98 -47
  4. package/dist/bundles/anime.umd.min.js +2 -2
  5. package/dist/modules/animatable/animatable.cjs +2 -2
  6. package/dist/modules/animatable/animatable.js +2 -2
  7. package/dist/modules/animatable/index.cjs +1 -1
  8. package/dist/modules/animatable/index.js +1 -1
  9. package/dist/modules/animation/additive.cjs +1 -1
  10. package/dist/modules/animation/additive.js +1 -1
  11. package/dist/modules/animation/animation.cjs +7 -3
  12. package/dist/modules/animation/animation.d.ts +8 -3
  13. package/dist/modules/animation/animation.js +7 -3
  14. package/dist/modules/animation/composition.cjs +1 -1
  15. package/dist/modules/animation/composition.js +1 -1
  16. package/dist/modules/animation/index.cjs +1 -1
  17. package/dist/modules/animation/index.js +1 -1
  18. package/dist/modules/core/clock.cjs +1 -1
  19. package/dist/modules/core/clock.js +1 -1
  20. package/dist/modules/core/colors.cjs +1 -1
  21. package/dist/modules/core/colors.js +1 -1
  22. package/dist/modules/core/consts.cjs +1 -1
  23. package/dist/modules/core/consts.js +1 -1
  24. package/dist/modules/core/globals.cjs +2 -2
  25. package/dist/modules/core/globals.js +2 -2
  26. package/dist/modules/core/helpers.cjs +1 -1
  27. package/dist/modules/core/helpers.js +1 -1
  28. package/dist/modules/core/render.cjs +1 -1
  29. package/dist/modules/core/render.js +1 -1
  30. package/dist/modules/core/styles.cjs +1 -1
  31. package/dist/modules/core/styles.js +1 -1
  32. package/dist/modules/core/targets.cjs +1 -1
  33. package/dist/modules/core/targets.js +1 -1
  34. package/dist/modules/core/transforms.cjs +1 -1
  35. package/dist/modules/core/transforms.js +1 -1
  36. package/dist/modules/core/units.cjs +1 -1
  37. package/dist/modules/core/units.js +1 -1
  38. package/dist/modules/core/values.cjs +1 -1
  39. package/dist/modules/core/values.js +1 -1
  40. package/dist/modules/draggable/draggable.cjs +17 -4
  41. package/dist/modules/draggable/draggable.d.ts +2 -0
  42. package/dist/modules/draggable/draggable.js +18 -5
  43. package/dist/modules/draggable/index.cjs +1 -1
  44. package/dist/modules/draggable/index.js +1 -1
  45. package/dist/modules/easings/cubic-bezier/index.cjs +1 -1
  46. package/dist/modules/easings/cubic-bezier/index.js +1 -1
  47. package/dist/modules/easings/eases/index.cjs +1 -1
  48. package/dist/modules/easings/eases/index.js +1 -1
  49. package/dist/modules/easings/eases/parser.cjs +1 -1
  50. package/dist/modules/easings/eases/parser.js +1 -1
  51. package/dist/modules/easings/index.cjs +1 -1
  52. package/dist/modules/easings/index.js +1 -1
  53. package/dist/modules/easings/irregular/index.cjs +1 -1
  54. package/dist/modules/easings/irregular/index.js +1 -1
  55. package/dist/modules/easings/linear/index.cjs +1 -1
  56. package/dist/modules/easings/linear/index.js +1 -1
  57. package/dist/modules/easings/none.cjs +1 -1
  58. package/dist/modules/easings/none.js +1 -1
  59. package/dist/modules/easings/spring/index.cjs +1 -1
  60. package/dist/modules/easings/spring/index.js +1 -1
  61. package/dist/modules/easings/steps/index.cjs +1 -1
  62. package/dist/modules/easings/steps/index.js +1 -1
  63. package/dist/modules/engine/engine.cjs +1 -1
  64. package/dist/modules/engine/engine.js +1 -1
  65. package/dist/modules/engine/index.cjs +1 -1
  66. package/dist/modules/engine/index.js +1 -1
  67. package/dist/modules/events/index.cjs +1 -1
  68. package/dist/modules/events/index.js +1 -1
  69. package/dist/modules/events/scroll.cjs +7 -3
  70. package/dist/modules/events/scroll.d.ts +2 -0
  71. package/dist/modules/events/scroll.js +7 -3
  72. package/dist/modules/index.cjs +1 -1
  73. package/dist/modules/index.js +1 -1
  74. package/dist/modules/scope/index.cjs +1 -1
  75. package/dist/modules/scope/index.js +1 -1
  76. package/dist/modules/scope/scope.cjs +1 -1
  77. package/dist/modules/scope/scope.js +1 -1
  78. package/dist/modules/svg/drawable.cjs +1 -1
  79. package/dist/modules/svg/drawable.js +1 -1
  80. package/dist/modules/svg/helpers.cjs +1 -1
  81. package/dist/modules/svg/helpers.js +1 -1
  82. package/dist/modules/svg/index.cjs +1 -1
  83. package/dist/modules/svg/index.js +1 -1
  84. package/dist/modules/svg/morphto.cjs +12 -2
  85. package/dist/modules/svg/morphto.js +12 -2
  86. package/dist/modules/svg/motionpath.cjs +18 -11
  87. package/dist/modules/svg/motionpath.d.ts +1 -1
  88. package/dist/modules/svg/motionpath.js +18 -11
  89. package/dist/modules/text/index.cjs +1 -1
  90. package/dist/modules/text/index.js +1 -1
  91. package/dist/modules/text/split.cjs +1 -1
  92. package/dist/modules/text/split.js +1 -1
  93. package/dist/modules/timeline/index.cjs +1 -1
  94. package/dist/modules/timeline/index.js +1 -1
  95. package/dist/modules/timeline/position.cjs +1 -1
  96. package/dist/modules/timeline/position.js +1 -1
  97. package/dist/modules/timeline/timeline.cjs +9 -5
  98. package/dist/modules/timeline/timeline.d.ts +8 -3
  99. package/dist/modules/timeline/timeline.js +9 -5
  100. package/dist/modules/timer/index.cjs +1 -1
  101. package/dist/modules/timer/index.js +1 -1
  102. package/dist/modules/timer/timer.cjs +17 -14
  103. package/dist/modules/timer/timer.d.ts +12 -7
  104. package/dist/modules/timer/timer.js +17 -14
  105. package/dist/modules/types/index.d.ts +7 -3
  106. package/dist/modules/utils/chainable.cjs +1 -1
  107. package/dist/modules/utils/chainable.js +1 -1
  108. package/dist/modules/utils/index.cjs +1 -1
  109. package/dist/modules/utils/index.js +1 -1
  110. package/dist/modules/utils/number.cjs +1 -1
  111. package/dist/modules/utils/number.js +1 -1
  112. package/dist/modules/utils/random.cjs +1 -1
  113. package/dist/modules/utils/random.js +1 -1
  114. package/dist/modules/utils/stagger.cjs +1 -1
  115. package/dist/modules/utils/stagger.js +1 -1
  116. package/dist/modules/utils/target.cjs +1 -1
  117. package/dist/modules/utils/target.js +1 -1
  118. package/dist/modules/utils/time.cjs +1 -1
  119. package/dist/modules/utils/time.js +1 -1
  120. package/dist/modules/waapi/composition.cjs +1 -1
  121. package/dist/modules/waapi/composition.js +1 -1
  122. package/dist/modules/waapi/index.cjs +1 -1
  123. package/dist/modules/waapi/index.js +1 -1
  124. package/dist/modules/waapi/waapi.cjs +8 -5
  125. package/dist/modules/waapi/waapi.d.ts +8 -5
  126. package/dist/modules/waapi/waapi.js +8 -5
  127. package/package.json +3 -4
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - ESM bundle
3
- * @version v4.2.0
3
+ * @version v4.2.1
4
4
  * @license MIT
5
5
  * @copyright 2025 - Julian Garnier
6
6
  */
@@ -385,10 +385,6 @@
385
385
  * @typedef {WAAPITweenValue|WAAPIFunctionValue|Array<String|Number|WAAPIFunctionValue>} WAAPIKeyframeValue
386
386
  */
387
387
 
388
- /**
389
- * @typedef {Callback<WAAPIAnimation>} WAAPICallback
390
- */
391
-
392
388
  /**
393
389
  * @typedef {Object} WAAPITweenOptions
394
390
  * @property {WAAPIKeyframeValue} [to]
@@ -411,11 +407,11 @@
411
407
  * @property {WAAPIEasingParam} [ease]
412
408
  * @property {CompositeOperation} [composition]
413
409
  * @property {Boolean} [persist]
414
- * @property {WAAPICallback} [onComplete]
410
+ * @property {Callback<WAAPIAnimation>} [onComplete]
415
411
  */
416
412
 
417
413
  /**
418
- * @typedef {Record<String, WAAPIKeyframeValue | WAAPIAnimationOptions | Boolean | ScrollObserver | WAAPICallback | WAAPIEasingParam | WAAPITweenOptions> & WAAPIAnimationOptions} WAAPIAnimationParams
414
+ * @typedef {Record<String, WAAPIKeyframeValue | WAAPIAnimationOptions | Boolean | ScrollObserver | Callback<WAAPIAnimation> | WAAPIEasingParam | WAAPITweenOptions> & WAAPIAnimationOptions} WAAPIAnimationParams
419
415
  */
420
416
 
421
417
  // Animatable types
@@ -558,6 +554,12 @@
558
554
  * @property {String} [onGrab]
559
555
  */
560
556
 
557
+ /**
558
+ * @typedef {Object} DraggableDragThresholdParams
559
+ * @property {Number} [mouse]
560
+ * @property {Number} [touch]
561
+ */
562
+
561
563
  /**
562
564
  * @typedef {Object} DraggableParams
563
565
  * @property {DOMTargetSelector} [trigger]
@@ -570,6 +572,7 @@
570
572
  * @property {Number|((draggable: Draggable) => Number)} [containerFriction]
571
573
  * @property {Number|((draggable: Draggable) => Number)} [releaseContainerFriction]
572
574
  * @property {Number|((draggable: Draggable) => Number)} [dragSpeed]
575
+ * @property {Number|DraggableDragThresholdParams|((draggable: Draggable) => Number|DraggableDragThresholdParams)} [dragThreshold]
573
576
  * @property {Number|((draggable: Draggable) => Number)} [scrollSpeed]
574
577
  * @property {Number|((draggable: Draggable) => Number)} [scrollThreshold]
575
578
  * @property {Number|((draggable: Draggable) => Number)} [minVelocity]
@@ -793,7 +796,7 @@ const globals = {
793
796
  tickThreshold: 200,
794
797
  };
795
798
 
796
- const globalVersions = { version: '4.2.0', engine: null };
799
+ const globalVersions = { version: '4.2.1', engine: null };
797
800
 
798
801
  if (isBrowser) {
799
802
  if (!win.AnimeJS) win.AnimeJS = [];
@@ -2480,7 +2483,7 @@ const reviveTimer = timer => {
2480
2483
  if (timer._hasChildren) {
2481
2484
  forEachChildren(timer, reviveTimer);
2482
2485
  } else {
2483
- forEachChildren(timer, (/** @type {Tween} tween*/tween) => {
2486
+ forEachChildren(timer, (/** @type {Tween} tween */tween) => {
2484
2487
  if (tween._composition !== compositionTypes.none) {
2485
2488
  composeTween(tween, getTweenSiblings(tween.target, tween.property));
2486
2489
  }
@@ -2537,7 +2540,6 @@ class Timer extends Clock {
2537
2540
  /** @type {Number} */(timerLoop) < 0 ? Infinity :
2538
2541
  /** @type {Number} */(timerLoop) + 1;
2539
2542
 
2540
-
2541
2543
  let offsetPosition = 0;
2542
2544
 
2543
2545
  if (parent) {
@@ -2627,7 +2629,7 @@ class Timer extends Clock {
2627
2629
  }
2628
2630
 
2629
2631
  set cancelled(cancelled) {
2630
- cancelled ? this.cancel() : this.reset(1).play();
2632
+ cancelled ? this.cancel() : this.reset(true).play();
2631
2633
  }
2632
2634
 
2633
2635
  get currentTime() {
@@ -2692,10 +2694,10 @@ class Timer extends Clock {
2692
2694
  }
2693
2695
 
2694
2696
  /**
2695
- * @param {Number} internalRender
2697
+ * @param {Boolean} [softReset]
2696
2698
  * @return {this}
2697
2699
  */
2698
- reset(internalRender = 0) {
2700
+ reset(softReset = false) {
2699
2701
  // If cancelled, revive the timer before rendering in order to have propertly composed tweens siblings
2700
2702
  reviveTimer(this);
2701
2703
  if (this._reversed && !this._reverse) this.reversed = false;
@@ -2704,7 +2706,7 @@ class Timer extends Clock {
2704
2706
  // NOTE: This is only required for Timelines and might be better to move to the Timeline class?
2705
2707
  this._iterationTime = this.iterationDuration;
2706
2708
  // Set tickMode to tickModes.FORCE to force rendering
2707
- tick(this, 0, 1, internalRender, tickModes.FORCE);
2709
+ tick(this, 0, 1, ~~softReset, tickModes.FORCE);
2708
2710
  // Reset timer properties after revive / render to make sure the props are not updated again
2709
2711
  resetTimerProperties(this);
2710
2712
  // Also reset children properties
@@ -2715,16 +2717,16 @@ class Timer extends Clock {
2715
2717
  }
2716
2718
 
2717
2719
  /**
2718
- * @param {Number} internalRender
2720
+ * @param {Boolean} internalRender
2719
2721
  * @return {this}
2720
2722
  */
2721
- init(internalRender = 0) {
2723
+ init(internalRender = false) {
2722
2724
  this.fps = this._fps;
2723
2725
  this.speed = this._speed;
2724
2726
  // Manually calling .init() on timelines should render all children intial state
2725
2727
  // Forces all children to render once then render to 0 when reseted
2726
2728
  if (!internalRender && this._hasChildren) {
2727
- tick(this, this.duration, 1, internalRender, tickModes.FORCE);
2729
+ tick(this, this.duration, 1, ~~internalRender, tickModes.FORCE);
2728
2730
  }
2729
2731
  this.reset(internalRender);
2730
2732
  // Make sure to set autoplay to false to child timers so it doesn't attempt to autoplay / link
@@ -2778,7 +2780,7 @@ class Timer extends Clock {
2778
2780
 
2779
2781
  /** @return {this} */
2780
2782
  restart() {
2781
- return this.reset(0).resume();
2783
+ return this.reset().resume();
2782
2784
  }
2783
2785
 
2784
2786
  /**
@@ -2881,8 +2883,12 @@ class Timer extends Clock {
2881
2883
  }
2882
2884
 
2883
2885
  /**
2884
- * @param {Callback<this>} [callback]
2885
- * @return {Promise}
2886
+ * @typedef {this & {then: null}} ResolvedTimer
2887
+ */
2888
+
2889
+ /**
2890
+ * @param {Callback<ResolvedTimer>} [callback]
2891
+ * @return Promise<this>
2886
2892
  */
2887
2893
  then(callback = noop) {
2888
2894
  const then = this.then;
@@ -2890,7 +2896,7 @@ class Timer extends Clock {
2890
2896
  // this.then = null prevents infinite recursion if returned by an async function
2891
2897
  // https://github.com/juliangarnierorg/anime-beta/issues/26
2892
2898
  this.then = null;
2893
- callback(this);
2899
+ callback(/** @type {ResolvedTimer} */(this));
2894
2900
  this.then = then;
2895
2901
  this._resolve = noop;
2896
2902
  };
@@ -3839,8 +3845,12 @@ class JSAnimation extends Timer {
3839
3845
  }
3840
3846
 
3841
3847
  /**
3842
- * @param {Callback<this>} [callback]
3843
- * @return {Promise}
3848
+ * @typedef {this & {then: null}} ResolvedJSAnimation
3849
+ */
3850
+
3851
+ /**
3852
+ * @param {Callback<ResolvedJSAnimation>} [callback]
3853
+ * @return Promise<this>
3844
3854
  */
3845
3855
  then(callback) {
3846
3856
  return super.then(callback);
@@ -4111,7 +4121,7 @@ function addTlChild(childParams, tl, timePosition, targets, index, length) {
4111
4121
  const tlChild = targets ?
4112
4122
  new JSAnimation(targets,/** @type {AnimationParams} */(childParams), tl, adjustedPosition, false, index, length) :
4113
4123
  new Timer(/** @type {TimerParams} */(childParams), tl, adjustedPosition);
4114
- tlChild.init(1);
4124
+ tlChild.init(true);
4115
4125
  // TODO: Might be better to insert at a position relative to startTime?
4116
4126
  addChild(tl, tlChild);
4117
4127
  forEachChildren(tl, (/** @type {Renderable} */child) => {
@@ -4215,7 +4225,7 @@ class Timeline extends Timer {
4215
4225
  parseTimelinePosition(this,a2),
4216
4226
  );
4217
4227
  }
4218
- return this.init(1); // 1 = internalRender
4228
+ return this.init(true);
4219
4229
  }
4220
4230
  }
4221
4231
 
@@ -4324,8 +4334,12 @@ class Timeline extends Timer {
4324
4334
  }
4325
4335
 
4326
4336
  /**
4327
- * @param {Callback<this>} [callback]
4328
- * @return {Promise}
4337
+ * @typedef {this & {then: null}} ResolvedTimeline
4338
+ */
4339
+
4340
+ /**
4341
+ * @param {Callback<ResolvedTimeline>} [callback]
4342
+ * @return Promise<this>
4329
4343
  */
4330
4344
  then(callback) {
4331
4345
  return super.then(callback);
@@ -4435,7 +4449,7 @@ class Animatable {
4435
4449
  tween._currentTime = 0;
4436
4450
  });
4437
4451
  if (!isUnd(duration)) animation.stretch(duration);
4438
- animation.reset(1).resume();
4452
+ animation.reset(true).resume();
4439
4453
  return this;
4440
4454
  }
4441
4455
  };
@@ -4896,7 +4910,7 @@ class Transforms {
4896
4910
  }
4897
4911
 
4898
4912
  /**
4899
- * @template {Array<Number>|DOMTargetSelector|String|Number|Boolean|Function|DraggableCursorParams} T
4913
+ * @template {Array<Number>|DOMTargetSelector|String|Number|Boolean|Function|DraggableCursorParams|DraggableDragThresholdParams} T
4900
4914
  * @param {T | ((draggable: Draggable) => T)} value
4901
4915
  * @param {Draggable} draggable
4902
4916
  * @return {T}
@@ -4950,6 +4964,8 @@ class Draggable {
4950
4964
  /** @type {Number} */
4951
4965
  this.dragSpeed = 0;
4952
4966
  /** @type {Number} */
4967
+ this.dragThreshold = 3;
4968
+ /** @type {Number} */
4953
4969
  this.maxVelocity = 0;
4954
4970
  /** @type {Number} */
4955
4971
  this.minVelocity = 0;
@@ -5367,6 +5383,16 @@ class Draggable {
5367
5383
  if (onHover) cursorStyles.onHover = onHover;
5368
5384
  if (onGrab) cursorStyles.onGrab = onGrab;
5369
5385
  }
5386
+ const parsedDragThreshold = parseDraggableFunctionParameter(params.dragThreshold, this);
5387
+ const dragThreshold = { mouse: 3, touch: 7 };
5388
+ if (isNum(parsedDragThreshold)) {
5389
+ dragThreshold.mouse = parsedDragThreshold;
5390
+ dragThreshold.touch = parsedDragThreshold;
5391
+ } else if (parsedDragThreshold) {
5392
+ const { mouse, touch } = parsedDragThreshold;
5393
+ if (!isUnd(mouse)) dragThreshold.mouse = mouse;
5394
+ if (!isUnd(touch)) dragThreshold.touch = touch;
5395
+ }
5370
5396
  this.containerArray = isArr(container) ? container : null;
5371
5397
  this.$container = /** @type {HTMLElement} */(container && !this.containerArray ? parseTargets(/** @type {DOMTarget} */(container))[0] : doc.body);
5372
5398
  this.useWin = this.$container === doc.body;
@@ -5381,6 +5407,7 @@ class Draggable {
5381
5407
  this.scrollSpeed = setValue(parseDraggableFunctionParameter(params.scrollSpeed, this), 1.5);
5382
5408
  this.scrollThreshold = setValue(parseDraggableFunctionParameter(params.scrollThreshold, this), 20);
5383
5409
  this.dragSpeed = setValue(parseDraggableFunctionParameter(params.dragSpeed, this), 1);
5410
+ this.dragThreshold = this.isFinePointer ? dragThreshold.mouse : dragThreshold.touch;
5384
5411
  this.minVelocity = setValue(parseDraggableFunctionParameter(params.minVelocity, this), 0);
5385
5412
  this.maxVelocity = setValue(parseDraggableFunctionParameter(params.maxVelocity, this), 50);
5386
5413
  this.velocityMultiplier = setValue(parseDraggableFunctionParameter(params.velocityMultiplier, this), 1);
@@ -5682,8 +5709,7 @@ class Draggable {
5682
5709
  this.$trigger.addEventListener('touchend', preventDefault);
5683
5710
 
5684
5711
  // Don't check for a miminim distance move if already dragging
5685
- if (this.dragged || (!this.disabled[0] && abs(movedX) > 3) || (!this.disabled[1] && abs(movedY) > 3)) {
5686
-
5712
+ if (this.dragged || (!this.disabled[0] && abs(movedX) > this.dragThreshold) || (!this.disabled[1] && abs(movedY) > this.dragThreshold)) {
5687
5713
  this.updateTicker.resume();
5688
5714
  this.pointer[2] = this.pointer[0];
5689
5715
  this.pointer[3] = this.pointer[1];
@@ -6272,6 +6298,8 @@ class ScrollContainer {
6272
6298
  /** @type {Number} */
6273
6299
  this.top = 0;
6274
6300
  /** @type {Number} */
6301
+ this.scale = 1;
6302
+ /** @type {Number} */
6275
6303
  this.zIndex = 0;
6276
6304
  /** @type {Number} */
6277
6305
  this.scrollX = 0;
@@ -6383,6 +6411,7 @@ class ScrollContainer {
6383
6411
  height = $el.clientHeight;
6384
6412
  this.top = elRect.top;
6385
6413
  this.left = elRect.left;
6414
+ this.scale = elRect.width ? width / elRect.width : (elRect.height ? height / elRect.height : 1);
6386
6415
  }
6387
6416
  this.width = width;
6388
6417
  this.height = height;
@@ -6908,8 +6937,9 @@ class ScrollObserver {
6908
6937
  }
6909
6938
  }
6910
6939
  const rect = $target.getBoundingClientRect();
6911
- const offset = isHori ? rect.left + container.scrollX - container.left : rect.top + container.scrollY - container.top;
6912
- const targetSize = isHori ? rect.width : rect.height;
6940
+ const scale = container.scale;
6941
+ const offset = (isHori ? rect.left + container.scrollX - container.left : rect.top + container.scrollY - container.top) * scale;
6942
+ const targetSize = (isHori ? rect.width : rect.height) * scale;
6913
6943
  const containerSize = isHori ? container.width : container.height;
6914
6944
  const scrollSize = isHori ? container.scrollWidth : container.scrollHeight;
6915
6945
  const maxScroll = scrollSize - containerSize;
@@ -7623,20 +7653,24 @@ const getPath = path => {
7623
7653
 
7624
7654
  /**
7625
7655
  * @param {SVGGeometryElement} $path
7656
+ * @param {Number} totalLength
7626
7657
  * @param {Number} progress
7627
7658
  * @param {Number}lookup
7628
7659
  * @return {DOMPoint}
7629
7660
  */
7630
- const getPathPoint = ($path, progress, lookup = 0) => {
7631
- return $path.getPointAtLength(progress + lookup >= 1 ? progress + lookup : 0);
7661
+ const getPathPoint = ($path, totalLength, progress, lookup = 0) => {
7662
+ const point = progress + lookup;
7663
+ const pointOnPath = (point % totalLength + totalLength) % totalLength;
7664
+ return $path.getPointAtLength(pointOnPath);
7632
7665
  };
7633
7666
 
7634
7667
  /**
7635
7668
  * @param {SVGGeometryElement} $path
7636
7669
  * @param {String} pathProperty
7670
+ * @param {Number} [offset=0]
7637
7671
  * @return {FunctionValue}
7638
7672
  */
7639
- const getPathProgess = ($path, pathProperty) => {
7673
+ const getPathProgess = ($path, pathProperty, offset = 0) => {
7640
7674
  return $el => {
7641
7675
  const totalLength = +($path.getTotalLength());
7642
7676
  const inSvg = $el[isSvgSymbol];
@@ -7647,12 +7681,14 @@ const getPathProgess = ($path, pathProperty) => {
7647
7681
  to: totalLength,
7648
7682
  /** @type {TweenModifier} */
7649
7683
  modifier: progress => {
7684
+ const offsetLength = offset * totalLength;
7685
+ const newProgress = progress + offsetLength;
7650
7686
  if (pathProperty === 'a') {
7651
- const p0 = getPathPoint($path, progress, -1);
7652
- const p1 = getPathPoint($path, progress, 1);
7687
+ const p0 = getPathPoint($path, totalLength, newProgress, -1);
7688
+ const p1 = getPathPoint($path, totalLength, newProgress, 1);
7653
7689
  return atan2(p1.y - p0.y, p1.x - p0.x) * 180 / PI;
7654
7690
  } else {
7655
- const p = getPathPoint($path, progress, 0);
7691
+ const p = getPathPoint($path, totalLength, newProgress, 0);
7656
7692
  return pathProperty === 'x' ?
7657
7693
  inSvg || !ctm ? p.x : p.x * ctm.a + p.y * ctm.c + ctm.e :
7658
7694
  inSvg || !ctm ? p.y : p.x * ctm.b + p.y * ctm.d + ctm.f
@@ -7664,14 +7700,15 @@ const getPathProgess = ($path, pathProperty) => {
7664
7700
 
7665
7701
  /**
7666
7702
  * @param {TargetsParam} path
7703
+ * @param {Number} [offset=0]
7667
7704
  */
7668
- const createMotionPath = path => {
7705
+ const createMotionPath = (path, offset = 0) => {
7669
7706
  const $path = getPath(path);
7670
7707
  if (!$path) return;
7671
7708
  return {
7672
- translateX: getPathProgess($path, 'x'),
7673
- translateY: getPathProgess($path, 'y'),
7674
- rotate: getPathProgess($path, 'a'),
7709
+ translateX: getPathProgess($path, 'x', offset),
7710
+ translateY: getPathProgess($path, 'y', offset),
7711
+ rotate: getPathProgess($path, 'a', offset),
7675
7712
  }
7676
7713
  };
7677
7714
 
@@ -7783,8 +7820,18 @@ const createDrawable = (selector, start = 0, end = 0) => {
7783
7820
  * @return {FunctionValue}
7784
7821
  */
7785
7822
  const morphTo = (path2, precision = .33) => ($path1) => {
7823
+ const tagName1 = ($path1.tagName || '').toLowerCase();
7824
+ if (!tagName1.match(/^(path|polygon|polyline)$/)) {
7825
+ throw new Error(`Can't morph a <${$path1.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);
7826
+ }
7786
7827
  const $path2 = /** @type {SVGGeometryElement} */(getPath(path2));
7787
- if (!$path2) return;
7828
+ if (!$path2) {
7829
+ throw new Error("Can't morph to an invalid target. 'path2' must resolve to an existing <path>, <polygon> or <polyline> SVG element.");
7830
+ }
7831
+ const tagName2 = ($path2.tagName || '').toLowerCase();
7832
+ if (!tagName2.match(/^(path|polygon|polyline)$/)) {
7833
+ throw new Error(`Can't morph a <${$path2.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);
7834
+ }
7788
7835
  const isPath = $path1.tagName === 'path';
7789
7836
  const separator = isPath ? ' ' : ',';
7790
7837
  const previousPoints = $path1[morphPointsSymbol];
@@ -8710,14 +8757,18 @@ class WAAPIAnimation {
8710
8757
  }
8711
8758
 
8712
8759
  /**
8713
- * @param {WAAPICallback} [callback]
8714
- * @return {Promise}
8760
+ * @typedef {this & {then: null}} ResolvedWAAPIAnimation
8761
+ */
8762
+
8763
+ /**
8764
+ * @param {Callback<ResolvedWAAPIAnimation>} [callback]
8765
+ * @return Promise<this>
8715
8766
  */
8716
8767
  then(callback = noop) {
8717
8768
  const then = this.then;
8718
8769
  const onResolve = () => {
8719
8770
  this.then = null;
8720
- callback(this);
8771
+ callback(/** @type {ResolvedWAAPIAnimation} */(this));
8721
8772
  this.then = then;
8722
8773
  this._resolve = noop;
8723
8774
  };