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 - UMD 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]
@@ -799,7 +802,7 @@
799
802
  tickThreshold: 200,
800
803
  };
801
804
 
802
- const globalVersions = { version: '4.2.0', engine: null };
805
+ const globalVersions = { version: '4.2.1', engine: null };
803
806
 
804
807
  if (isBrowser) {
805
808
  if (!win.AnimeJS) win.AnimeJS = [];
@@ -2486,7 +2489,7 @@
2486
2489
  if (timer._hasChildren) {
2487
2490
  forEachChildren(timer, reviveTimer);
2488
2491
  } else {
2489
- forEachChildren(timer, (/** @type {Tween} tween*/tween) => {
2492
+ forEachChildren(timer, (/** @type {Tween} tween */tween) => {
2490
2493
  if (tween._composition !== compositionTypes.none) {
2491
2494
  composeTween(tween, getTweenSiblings(tween.target, tween.property));
2492
2495
  }
@@ -2543,7 +2546,6 @@
2543
2546
  /** @type {Number} */(timerLoop) < 0 ? Infinity :
2544
2547
  /** @type {Number} */(timerLoop) + 1;
2545
2548
 
2546
-
2547
2549
  let offsetPosition = 0;
2548
2550
 
2549
2551
  if (parent) {
@@ -2633,7 +2635,7 @@
2633
2635
  }
2634
2636
 
2635
2637
  set cancelled(cancelled) {
2636
- cancelled ? this.cancel() : this.reset(1).play();
2638
+ cancelled ? this.cancel() : this.reset(true).play();
2637
2639
  }
2638
2640
 
2639
2641
  get currentTime() {
@@ -2698,10 +2700,10 @@
2698
2700
  }
2699
2701
 
2700
2702
  /**
2701
- * @param {Number} internalRender
2703
+ * @param {Boolean} [softReset]
2702
2704
  * @return {this}
2703
2705
  */
2704
- reset(internalRender = 0) {
2706
+ reset(softReset = false) {
2705
2707
  // If cancelled, revive the timer before rendering in order to have propertly composed tweens siblings
2706
2708
  reviveTimer(this);
2707
2709
  if (this._reversed && !this._reverse) this.reversed = false;
@@ -2710,7 +2712,7 @@
2710
2712
  // NOTE: This is only required for Timelines and might be better to move to the Timeline class?
2711
2713
  this._iterationTime = this.iterationDuration;
2712
2714
  // Set tickMode to tickModes.FORCE to force rendering
2713
- tick(this, 0, 1, internalRender, tickModes.FORCE);
2715
+ tick(this, 0, 1, ~~softReset, tickModes.FORCE);
2714
2716
  // Reset timer properties after revive / render to make sure the props are not updated again
2715
2717
  resetTimerProperties(this);
2716
2718
  // Also reset children properties
@@ -2721,16 +2723,16 @@
2721
2723
  }
2722
2724
 
2723
2725
  /**
2724
- * @param {Number} internalRender
2726
+ * @param {Boolean} internalRender
2725
2727
  * @return {this}
2726
2728
  */
2727
- init(internalRender = 0) {
2729
+ init(internalRender = false) {
2728
2730
  this.fps = this._fps;
2729
2731
  this.speed = this._speed;
2730
2732
  // Manually calling .init() on timelines should render all children intial state
2731
2733
  // Forces all children to render once then render to 0 when reseted
2732
2734
  if (!internalRender && this._hasChildren) {
2733
- tick(this, this.duration, 1, internalRender, tickModes.FORCE);
2735
+ tick(this, this.duration, 1, ~~internalRender, tickModes.FORCE);
2734
2736
  }
2735
2737
  this.reset(internalRender);
2736
2738
  // Make sure to set autoplay to false to child timers so it doesn't attempt to autoplay / link
@@ -2784,7 +2786,7 @@
2784
2786
 
2785
2787
  /** @return {this} */
2786
2788
  restart() {
2787
- return this.reset(0).resume();
2789
+ return this.reset().resume();
2788
2790
  }
2789
2791
 
2790
2792
  /**
@@ -2887,8 +2889,12 @@
2887
2889
  }
2888
2890
 
2889
2891
  /**
2890
- * @param {Callback<this>} [callback]
2891
- * @return {Promise}
2892
+ * @typedef {this & {then: null}} ResolvedTimer
2893
+ */
2894
+
2895
+ /**
2896
+ * @param {Callback<ResolvedTimer>} [callback]
2897
+ * @return Promise<this>
2892
2898
  */
2893
2899
  then(callback = noop) {
2894
2900
  const then = this.then;
@@ -2896,7 +2902,7 @@
2896
2902
  // this.then = null prevents infinite recursion if returned by an async function
2897
2903
  // https://github.com/juliangarnierorg/anime-beta/issues/26
2898
2904
  this.then = null;
2899
- callback(this);
2905
+ callback(/** @type {ResolvedTimer} */(this));
2900
2906
  this.then = then;
2901
2907
  this._resolve = noop;
2902
2908
  };
@@ -3845,8 +3851,12 @@
3845
3851
  }
3846
3852
 
3847
3853
  /**
3848
- * @param {Callback<this>} [callback]
3849
- * @return {Promise}
3854
+ * @typedef {this & {then: null}} ResolvedJSAnimation
3855
+ */
3856
+
3857
+ /**
3858
+ * @param {Callback<ResolvedJSAnimation>} [callback]
3859
+ * @return Promise<this>
3850
3860
  */
3851
3861
  then(callback) {
3852
3862
  return super.then(callback);
@@ -4117,7 +4127,7 @@
4117
4127
  const tlChild = targets ?
4118
4128
  new JSAnimation(targets,/** @type {AnimationParams} */(childParams), tl, adjustedPosition, false, index, length) :
4119
4129
  new Timer(/** @type {TimerParams} */(childParams), tl, adjustedPosition);
4120
- tlChild.init(1);
4130
+ tlChild.init(true);
4121
4131
  // TODO: Might be better to insert at a position relative to startTime?
4122
4132
  addChild(tl, tlChild);
4123
4133
  forEachChildren(tl, (/** @type {Renderable} */child) => {
@@ -4221,7 +4231,7 @@
4221
4231
  parseTimelinePosition(this,a2),
4222
4232
  );
4223
4233
  }
4224
- return this.init(1); // 1 = internalRender
4234
+ return this.init(true);
4225
4235
  }
4226
4236
  }
4227
4237
 
@@ -4330,8 +4340,12 @@
4330
4340
  }
4331
4341
 
4332
4342
  /**
4333
- * @param {Callback<this>} [callback]
4334
- * @return {Promise}
4343
+ * @typedef {this & {then: null}} ResolvedTimeline
4344
+ */
4345
+
4346
+ /**
4347
+ * @param {Callback<ResolvedTimeline>} [callback]
4348
+ * @return Promise<this>
4335
4349
  */
4336
4350
  then(callback) {
4337
4351
  return super.then(callback);
@@ -4441,7 +4455,7 @@
4441
4455
  tween._currentTime = 0;
4442
4456
  });
4443
4457
  if (!isUnd(duration)) animation.stretch(duration);
4444
- animation.reset(1).resume();
4458
+ animation.reset(true).resume();
4445
4459
  return this;
4446
4460
  }
4447
4461
  };
@@ -4902,7 +4916,7 @@
4902
4916
  }
4903
4917
 
4904
4918
  /**
4905
- * @template {Array<Number>|DOMTargetSelector|String|Number|Boolean|Function|DraggableCursorParams} T
4919
+ * @template {Array<Number>|DOMTargetSelector|String|Number|Boolean|Function|DraggableCursorParams|DraggableDragThresholdParams} T
4906
4920
  * @param {T | ((draggable: Draggable) => T)} value
4907
4921
  * @param {Draggable} draggable
4908
4922
  * @return {T}
@@ -4956,6 +4970,8 @@
4956
4970
  /** @type {Number} */
4957
4971
  this.dragSpeed = 0;
4958
4972
  /** @type {Number} */
4973
+ this.dragThreshold = 3;
4974
+ /** @type {Number} */
4959
4975
  this.maxVelocity = 0;
4960
4976
  /** @type {Number} */
4961
4977
  this.minVelocity = 0;
@@ -5373,6 +5389,16 @@
5373
5389
  if (onHover) cursorStyles.onHover = onHover;
5374
5390
  if (onGrab) cursorStyles.onGrab = onGrab;
5375
5391
  }
5392
+ const parsedDragThreshold = parseDraggableFunctionParameter(params.dragThreshold, this);
5393
+ const dragThreshold = { mouse: 3, touch: 7 };
5394
+ if (isNum(parsedDragThreshold)) {
5395
+ dragThreshold.mouse = parsedDragThreshold;
5396
+ dragThreshold.touch = parsedDragThreshold;
5397
+ } else if (parsedDragThreshold) {
5398
+ const { mouse, touch } = parsedDragThreshold;
5399
+ if (!isUnd(mouse)) dragThreshold.mouse = mouse;
5400
+ if (!isUnd(touch)) dragThreshold.touch = touch;
5401
+ }
5376
5402
  this.containerArray = isArr(container) ? container : null;
5377
5403
  this.$container = /** @type {HTMLElement} */(container && !this.containerArray ? parseTargets(/** @type {DOMTarget} */(container))[0] : doc.body);
5378
5404
  this.useWin = this.$container === doc.body;
@@ -5387,6 +5413,7 @@
5387
5413
  this.scrollSpeed = setValue(parseDraggableFunctionParameter(params.scrollSpeed, this), 1.5);
5388
5414
  this.scrollThreshold = setValue(parseDraggableFunctionParameter(params.scrollThreshold, this), 20);
5389
5415
  this.dragSpeed = setValue(parseDraggableFunctionParameter(params.dragSpeed, this), 1);
5416
+ this.dragThreshold = this.isFinePointer ? dragThreshold.mouse : dragThreshold.touch;
5390
5417
  this.minVelocity = setValue(parseDraggableFunctionParameter(params.minVelocity, this), 0);
5391
5418
  this.maxVelocity = setValue(parseDraggableFunctionParameter(params.maxVelocity, this), 50);
5392
5419
  this.velocityMultiplier = setValue(parseDraggableFunctionParameter(params.velocityMultiplier, this), 1);
@@ -5688,8 +5715,7 @@
5688
5715
  this.$trigger.addEventListener('touchend', preventDefault);
5689
5716
 
5690
5717
  // Don't check for a miminim distance move if already dragging
5691
- if (this.dragged || (!this.disabled[0] && abs(movedX) > 3) || (!this.disabled[1] && abs(movedY) > 3)) {
5692
-
5718
+ if (this.dragged || (!this.disabled[0] && abs(movedX) > this.dragThreshold) || (!this.disabled[1] && abs(movedY) > this.dragThreshold)) {
5693
5719
  this.updateTicker.resume();
5694
5720
  this.pointer[2] = this.pointer[0];
5695
5721
  this.pointer[3] = this.pointer[1];
@@ -6278,6 +6304,8 @@
6278
6304
  /** @type {Number} */
6279
6305
  this.top = 0;
6280
6306
  /** @type {Number} */
6307
+ this.scale = 1;
6308
+ /** @type {Number} */
6281
6309
  this.zIndex = 0;
6282
6310
  /** @type {Number} */
6283
6311
  this.scrollX = 0;
@@ -6389,6 +6417,7 @@
6389
6417
  height = $el.clientHeight;
6390
6418
  this.top = elRect.top;
6391
6419
  this.left = elRect.left;
6420
+ this.scale = elRect.width ? width / elRect.width : (elRect.height ? height / elRect.height : 1);
6392
6421
  }
6393
6422
  this.width = width;
6394
6423
  this.height = height;
@@ -6914,8 +6943,9 @@
6914
6943
  }
6915
6944
  }
6916
6945
  const rect = $target.getBoundingClientRect();
6917
- const offset = isHori ? rect.left + container.scrollX - container.left : rect.top + container.scrollY - container.top;
6918
- const targetSize = isHori ? rect.width : rect.height;
6946
+ const scale = container.scale;
6947
+ const offset = (isHori ? rect.left + container.scrollX - container.left : rect.top + container.scrollY - container.top) * scale;
6948
+ const targetSize = (isHori ? rect.width : rect.height) * scale;
6919
6949
  const containerSize = isHori ? container.width : container.height;
6920
6950
  const scrollSize = isHori ? container.scrollWidth : container.scrollHeight;
6921
6951
  const maxScroll = scrollSize - containerSize;
@@ -7629,20 +7659,24 @@
7629
7659
 
7630
7660
  /**
7631
7661
  * @param {SVGGeometryElement} $path
7662
+ * @param {Number} totalLength
7632
7663
  * @param {Number} progress
7633
7664
  * @param {Number}lookup
7634
7665
  * @return {DOMPoint}
7635
7666
  */
7636
- const getPathPoint = ($path, progress, lookup = 0) => {
7637
- return $path.getPointAtLength(progress + lookup >= 1 ? progress + lookup : 0);
7667
+ const getPathPoint = ($path, totalLength, progress, lookup = 0) => {
7668
+ const point = progress + lookup;
7669
+ const pointOnPath = (point % totalLength + totalLength) % totalLength;
7670
+ return $path.getPointAtLength(pointOnPath);
7638
7671
  };
7639
7672
 
7640
7673
  /**
7641
7674
  * @param {SVGGeometryElement} $path
7642
7675
  * @param {String} pathProperty
7676
+ * @param {Number} [offset=0]
7643
7677
  * @return {FunctionValue}
7644
7678
  */
7645
- const getPathProgess = ($path, pathProperty) => {
7679
+ const getPathProgess = ($path, pathProperty, offset = 0) => {
7646
7680
  return $el => {
7647
7681
  const totalLength = +($path.getTotalLength());
7648
7682
  const inSvg = $el[isSvgSymbol];
@@ -7653,12 +7687,14 @@
7653
7687
  to: totalLength,
7654
7688
  /** @type {TweenModifier} */
7655
7689
  modifier: progress => {
7690
+ const offsetLength = offset * totalLength;
7691
+ const newProgress = progress + offsetLength;
7656
7692
  if (pathProperty === 'a') {
7657
- const p0 = getPathPoint($path, progress, -1);
7658
- const p1 = getPathPoint($path, progress, 1);
7693
+ const p0 = getPathPoint($path, totalLength, newProgress, -1);
7694
+ const p1 = getPathPoint($path, totalLength, newProgress, 1);
7659
7695
  return atan2(p1.y - p0.y, p1.x - p0.x) * 180 / PI;
7660
7696
  } else {
7661
- const p = getPathPoint($path, progress, 0);
7697
+ const p = getPathPoint($path, totalLength, newProgress, 0);
7662
7698
  return pathProperty === 'x' ?
7663
7699
  inSvg || !ctm ? p.x : p.x * ctm.a + p.y * ctm.c + ctm.e :
7664
7700
  inSvg || !ctm ? p.y : p.x * ctm.b + p.y * ctm.d + ctm.f
@@ -7670,14 +7706,15 @@
7670
7706
 
7671
7707
  /**
7672
7708
  * @param {TargetsParam} path
7709
+ * @param {Number} [offset=0]
7673
7710
  */
7674
- const createMotionPath = path => {
7711
+ const createMotionPath = (path, offset = 0) => {
7675
7712
  const $path = getPath(path);
7676
7713
  if (!$path) return;
7677
7714
  return {
7678
- translateX: getPathProgess($path, 'x'),
7679
- translateY: getPathProgess($path, 'y'),
7680
- rotate: getPathProgess($path, 'a'),
7715
+ translateX: getPathProgess($path, 'x', offset),
7716
+ translateY: getPathProgess($path, 'y', offset),
7717
+ rotate: getPathProgess($path, 'a', offset),
7681
7718
  }
7682
7719
  };
7683
7720
 
@@ -7789,8 +7826,18 @@
7789
7826
  * @return {FunctionValue}
7790
7827
  */
7791
7828
  const morphTo = (path2, precision = .33) => ($path1) => {
7829
+ const tagName1 = ($path1.tagName || '').toLowerCase();
7830
+ if (!tagName1.match(/^(path|polygon|polyline)$/)) {
7831
+ throw new Error(`Can't morph a <${$path1.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);
7832
+ }
7792
7833
  const $path2 = /** @type {SVGGeometryElement} */(getPath(path2));
7793
- if (!$path2) return;
7834
+ if (!$path2) {
7835
+ throw new Error("Can't morph to an invalid target. 'path2' must resolve to an existing <path>, <polygon> or <polyline> SVG element.");
7836
+ }
7837
+ const tagName2 = ($path2.tagName || '').toLowerCase();
7838
+ if (!tagName2.match(/^(path|polygon|polyline)$/)) {
7839
+ throw new Error(`Can't morph a <${$path2.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);
7840
+ }
7794
7841
  const isPath = $path1.tagName === 'path';
7795
7842
  const separator = isPath ? ' ' : ',';
7796
7843
  const previousPoints = $path1[morphPointsSymbol];
@@ -8716,14 +8763,18 @@
8716
8763
  }
8717
8764
 
8718
8765
  /**
8719
- * @param {WAAPICallback} [callback]
8720
- * @return {Promise}
8766
+ * @typedef {this & {then: null}} ResolvedWAAPIAnimation
8767
+ */
8768
+
8769
+ /**
8770
+ * @param {Callback<ResolvedWAAPIAnimation>} [callback]
8771
+ * @return Promise<this>
8721
8772
  */
8722
8773
  then(callback = noop) {
8723
8774
  const then = this.then;
8724
8775
  const onResolve = () => {
8725
8776
  this.then = null;
8726
- callback(this);
8777
+ callback(/** @type {ResolvedWAAPIAnimation} */(this));
8727
8778
  this.then = then;
8728
8779
  this._resolve = noop;
8729
8780
  };