animejs 4.2.0-beta.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 (147) hide show
  1. package/README.md +6 -1
  2. package/dist/bundles/anime.esm.js +543 -304
  3. package/dist/bundles/anime.esm.min.js +2 -2
  4. package/dist/bundles/anime.umd.js +544 -305
  5. package/dist/bundles/anime.umd.min.js +2 -2
  6. package/dist/modules/animatable/animatable.cjs +4 -4
  7. package/dist/modules/animatable/animatable.js +3 -3
  8. package/dist/modules/animatable/index.cjs +1 -1
  9. package/dist/modules/animatable/index.js +1 -1
  10. package/dist/modules/animation/additive.cjs +1 -1
  11. package/dist/modules/animation/additive.js +1 -1
  12. package/dist/modules/animation/animation.cjs +28 -17
  13. package/dist/modules/animation/animation.d.ts +8 -5
  14. package/dist/modules/animation/animation.js +27 -16
  15. package/dist/modules/animation/composition.cjs +1 -1
  16. package/dist/modules/animation/composition.js +1 -1
  17. package/dist/modules/animation/index.cjs +1 -1
  18. package/dist/modules/animation/index.js +1 -1
  19. package/dist/modules/core/clock.cjs +1 -1
  20. package/dist/modules/core/clock.js +1 -1
  21. package/dist/modules/core/colors.cjs +1 -1
  22. package/dist/modules/core/colors.js +1 -1
  23. package/dist/modules/core/consts.cjs +7 -2
  24. package/dist/modules/core/consts.d.ts +2 -0
  25. package/dist/modules/core/consts.js +6 -3
  26. package/dist/modules/core/globals.cjs +3 -2
  27. package/dist/modules/core/globals.js +3 -2
  28. package/dist/modules/core/helpers.cjs +1 -1
  29. package/dist/modules/core/helpers.js +1 -1
  30. package/dist/modules/core/render.cjs +4 -2
  31. package/dist/modules/core/render.js +4 -2
  32. package/dist/modules/core/styles.cjs +8 -8
  33. package/dist/modules/core/styles.js +10 -10
  34. package/dist/modules/core/targets.cjs +1 -1
  35. package/dist/modules/core/targets.js +1 -1
  36. package/dist/modules/core/transforms.cjs +1 -1
  37. package/dist/modules/core/transforms.js +1 -1
  38. package/dist/modules/core/units.cjs +1 -1
  39. package/dist/modules/core/units.js +1 -1
  40. package/dist/modules/core/values.cjs +17 -6
  41. package/dist/modules/core/values.js +19 -8
  42. package/dist/modules/draggable/draggable.cjs +32 -19
  43. package/dist/modules/draggable/draggable.d.ts +3 -1
  44. package/dist/modules/draggable/draggable.js +28 -15
  45. package/dist/modules/draggable/index.cjs +1 -1
  46. package/dist/modules/draggable/index.js +1 -1
  47. package/dist/modules/easings/{cubic-bezier.cjs → cubic-bezier/index.cjs} +4 -4
  48. package/dist/modules/easings/{cubic-bezier.d.ts → cubic-bezier/index.d.ts} +1 -1
  49. package/dist/modules/easings/{cubic-bezier.js → cubic-bezier/index.js} +4 -4
  50. package/dist/modules/easings/eases/index.cjs +14 -0
  51. package/dist/modules/easings/eases/index.d.ts +1 -0
  52. package/dist/modules/easings/eases/index.js +8 -0
  53. package/dist/modules/easings/{eases.cjs → eases/parser.cjs} +69 -27
  54. package/dist/modules/easings/{eases.d.ts → eases/parser.d.ts} +31 -17
  55. package/dist/modules/easings/{eases.js → eases/parser.js} +60 -21
  56. package/dist/modules/easings/index.cjs +15 -13
  57. package/dist/modules/easings/index.d.ts +6 -6
  58. package/dist/modules/easings/index.js +7 -7
  59. package/dist/modules/easings/{irregular.cjs → irregular/index.cjs} +5 -5
  60. package/dist/modules/easings/{irregular.d.ts → irregular/index.d.ts} +1 -1
  61. package/dist/modules/easings/{irregular.js → irregular/index.js} +4 -4
  62. package/dist/modules/easings/{linear.cjs → linear/index.cjs} +4 -4
  63. package/dist/modules/easings/{linear.d.ts → linear/index.d.ts} +1 -1
  64. package/dist/modules/easings/{linear.js → linear/index.js} +4 -4
  65. package/dist/modules/easings/none.cjs +1 -1
  66. package/dist/modules/easings/none.js +1 -1
  67. package/dist/modules/easings/spring/index.cjs +255 -0
  68. package/dist/modules/{spring/spring.d.ts → easings/spring/index.d.ts} +21 -5
  69. package/dist/modules/easings/spring/index.js +251 -0
  70. package/dist/modules/easings/{steps.cjs → steps/index.cjs} +3 -3
  71. package/dist/modules/easings/{steps.d.ts → steps/index.d.ts} +1 -1
  72. package/dist/modules/easings/{steps.js → steps/index.js} +3 -3
  73. package/dist/modules/engine/engine.cjs +1 -1
  74. package/dist/modules/engine/engine.js +1 -1
  75. package/dist/modules/engine/index.cjs +1 -1
  76. package/dist/modules/engine/index.js +1 -1
  77. package/dist/modules/events/index.cjs +1 -1
  78. package/dist/modules/events/index.js +1 -1
  79. package/dist/modules/events/scroll.cjs +17 -9
  80. package/dist/modules/events/scroll.d.ts +4 -0
  81. package/dist/modules/events/scroll.js +16 -8
  82. package/dist/modules/index.cjs +15 -16
  83. package/dist/modules/index.d.ts +0 -1
  84. package/dist/modules/index.js +7 -8
  85. package/dist/modules/scope/index.cjs +1 -1
  86. package/dist/modules/scope/index.js +1 -1
  87. package/dist/modules/scope/scope.cjs +1 -1
  88. package/dist/modules/scope/scope.js +1 -1
  89. package/dist/modules/svg/drawable.cjs +1 -1
  90. package/dist/modules/svg/drawable.js +1 -1
  91. package/dist/modules/svg/helpers.cjs +1 -1
  92. package/dist/modules/svg/helpers.js +1 -1
  93. package/dist/modules/svg/index.cjs +1 -1
  94. package/dist/modules/svg/index.js +1 -1
  95. package/dist/modules/svg/morphto.cjs +12 -2
  96. package/dist/modules/svg/morphto.js +12 -2
  97. package/dist/modules/svg/motionpath.cjs +18 -11
  98. package/dist/modules/svg/motionpath.d.ts +1 -1
  99. package/dist/modules/svg/motionpath.js +18 -11
  100. package/dist/modules/text/index.cjs +1 -1
  101. package/dist/modules/text/index.js +1 -1
  102. package/dist/modules/text/split.cjs +1 -1
  103. package/dist/modules/text/split.js +1 -1
  104. package/dist/modules/timeline/index.cjs +1 -1
  105. package/dist/modules/timeline/index.js +1 -1
  106. package/dist/modules/timeline/position.cjs +1 -1
  107. package/dist/modules/timeline/position.js +1 -1
  108. package/dist/modules/timeline/timeline.cjs +11 -7
  109. package/dist/modules/timeline/timeline.d.ts +8 -3
  110. package/dist/modules/timeline/timeline.js +10 -6
  111. package/dist/modules/timer/index.cjs +1 -1
  112. package/dist/modules/timer/index.js +1 -1
  113. package/dist/modules/timer/timer.cjs +17 -14
  114. package/dist/modules/timer/timer.d.ts +12 -7
  115. package/dist/modules/timer/timer.js +17 -14
  116. package/dist/modules/types/index.d.ts +35 -14
  117. package/dist/modules/utils/chainable.cjs +1 -1
  118. package/dist/modules/utils/chainable.js +1 -1
  119. package/dist/modules/utils/index.cjs +1 -1
  120. package/dist/modules/utils/index.js +1 -1
  121. package/dist/modules/utils/number.cjs +1 -1
  122. package/dist/modules/utils/number.js +1 -1
  123. package/dist/modules/utils/random.cjs +1 -1
  124. package/dist/modules/utils/random.js +1 -1
  125. package/dist/modules/utils/stagger.cjs +4 -4
  126. package/dist/modules/utils/stagger.js +3 -3
  127. package/dist/modules/utils/target.cjs +1 -1
  128. package/dist/modules/utils/target.js +1 -1
  129. package/dist/modules/utils/time.cjs +1 -1
  130. package/dist/modules/utils/time.js +1 -1
  131. package/dist/modules/waapi/composition.cjs +11 -5
  132. package/dist/modules/waapi/composition.d.ts +1 -1
  133. package/dist/modules/waapi/composition.js +11 -5
  134. package/dist/modules/waapi/index.cjs +1 -1
  135. package/dist/modules/waapi/index.js +1 -1
  136. package/dist/modules/waapi/waapi.cjs +58 -36
  137. package/dist/modules/waapi/waapi.d.ts +12 -7
  138. package/dist/modules/waapi/waapi.js +59 -37
  139. package/package.json +48 -13
  140. package/dist/modules/easings/parser.cjs +0 -59
  141. package/dist/modules/easings/parser.d.ts +0 -21
  142. package/dist/modules/easings/parser.js +0 -55
  143. package/dist/modules/spring/index.cjs +0 -15
  144. package/dist/modules/spring/index.d.ts +0 -1
  145. package/dist/modules/spring/index.js +0 -8
  146. package/dist/modules/spring/spring.cjs +0 -133
  147. package/dist/modules/spring/spring.js +0 -130
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - animation - CJS
3
- * @version v4.2.0
3
+ * @version v4.2.1
4
4
  * @license MIT
5
5
  * @copyright 2025 - Julian Garnier
6
6
  */
@@ -14,7 +14,7 @@ var targets = require('../core/targets.cjs');
14
14
  var values = require('../core/values.cjs');
15
15
  var styles = require('../core/styles.cjs');
16
16
  var units = require('../core/units.cjs');
17
- var eases = require('../easings/eases.cjs');
17
+ var parser = require('../easings/eases/parser.cjs');
18
18
  var timer = require('../timer/timer.cjs');
19
19
  var composition = require('./composition.cjs');
20
20
  var additive = require('./additive.cjs');
@@ -45,13 +45,14 @@ var additive = require('./additive.cjs');
45
45
  *
46
46
  * @import {
47
47
  * Spring,
48
- * } from '../spring/spring.js'
48
+ * } from '../easings/spring/index.js'
49
49
  */
50
50
 
51
51
  // Defines decomposed values target objects only once and mutate their properties later to avoid GC
52
52
  // TODO: Maybe move the objects creation to values.js and use the decompose function to create the base object
53
53
  const fromTargetObject = values.createDecomposedValueTargetObject();
54
54
  const toTargetObject = values.createDecomposedValueTargetObject();
55
+ const inlineStylesStore = {};
55
56
  const toFunctionStore = { func: null };
56
57
  const keyframesTargetArray = [null];
57
58
  const fastSetValuesArray = [null, null];
@@ -193,18 +194,18 @@ class JSAnimation extends timer.Timer {
193
194
 
194
195
  const animDefaults = parent ? parent.defaults : globals.globals.defaults;
195
196
  const animaPlaybackEase = values.setValue(playbackEase, animDefaults.playbackEase);
196
- const animEase = animaPlaybackEase ? eases.parseEase(animaPlaybackEase) : null;
197
+ const animEase = animaPlaybackEase ? parser.parseEase(animaPlaybackEase) : null;
197
198
  const hasSpring = !helpers.isUnd(ease) && !helpers.isUnd(/** @type {Spring} */(ease).ease);
198
199
  const tEasing = hasSpring ? /** @type {Spring} */(ease).ease : values.setValue(ease, animEase ? 'linear' : animDefaults.ease);
199
- const tDuration = hasSpring ? /** @type {Spring} */(ease).duration : values.setValue(duration, animDefaults.duration);
200
+ const tDuration = hasSpring ? /** @type {Spring} */(ease).settlingDuration : values.setValue(duration, animDefaults.duration);
200
201
  const tDelay = values.setValue(delay, animDefaults.delay);
201
202
  const tModifier = modifier || animDefaults.modifier;
202
203
  // If no composition is defined and the targets length is high (>= 1000) set the composition to 'none' (0) for faster tween creation
203
204
  const tComposition = helpers.isUnd(composition$1) && targetsLength >= consts.K ? consts.compositionTypes.none : !helpers.isUnd(composition$1) ? composition$1 : animDefaults.composition;
204
- // TODO: Do not create an empty object until we know the animation will generate inline styles
205
- const animInlineStyles = {};
206
205
  // const absoluteOffsetTime = this._offset;
207
206
  const absoluteOffsetTime = this._offset + (parent ? parent._offset : 0);
207
+ // This allows targeting the current animation in the spring onComplete callback
208
+ if (hasSpring) /** @type {Spring} */(ease).parent = this;
208
209
 
209
210
  let iterationDuration = NaN;
210
211
  let iterationDelay = NaN;
@@ -306,7 +307,7 @@ class JSAnimation extends timer.Timer {
306
307
  // Easing are treated differently and don't accept function based value to prevent having to pass a function wrapper that returns an other function all the time
307
308
  const tweenEasing = hasSpring ? /** @type {Spring} */(keyEasing).ease : keyEasing || tEasing;
308
309
  // Calculate default individual keyframe duration by dividing the tl of keyframes
309
- const tweenDuration = hasSpring ? /** @type {Spring} */(keyEasing).duration : values.getFunctionValue(values.setValue(key.duration, (l > 1 ? values.getFunctionValue(tDuration, target, ti, tl) / l : tDuration)), target, ti, tl);
310
+ const tweenDuration = hasSpring ? /** @type {Spring} */(keyEasing).settlingDuration : values.getFunctionValue(values.setValue(key.duration, (l > 1 ? values.getFunctionValue(tDuration, target, ti, tl) / l : tDuration)), target, ti, tl);
310
311
  // Default delay value should only be applied to the first tween
311
312
  const tweenDelay = values.getFunctionValue(values.setValue(key.delay, (!tweenIndex ? tDelay : 0)), target, ti, tl);
312
313
  const computedComposition = values.getFunctionValue(values.setValue(key.composition, tComposition), target, ti, tl);
@@ -356,7 +357,7 @@ class JSAnimation extends timer.Timer {
356
357
  }
357
358
  } else {
358
359
  values.decomposeRawValue(
359
- values.getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles),
360
+ values.getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore),
360
361
  values.decomposedOriginalValue
361
362
  );
362
363
  if (values.decomposedOriginalValue.t === consts.valueTypes.UNIT) {
@@ -374,7 +375,7 @@ class JSAnimation extends timer.Timer {
374
375
  } else {
375
376
  // No need to get and parse the original value if the tween is part of a timeline and has a previous sibling part of the same timeline
376
377
  values.decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
377
- values.getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles), toTargetObject);
378
+ values.getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore), toTargetObject);
378
379
  }
379
380
  }
380
381
  if (hasFromvalue) {
@@ -385,7 +386,7 @@ class JSAnimation extends timer.Timer {
385
386
  } else {
386
387
  values.decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
387
388
  // No need to get and parse the original value if the tween is part of a timeline and has a previous sibling part of the same timeline
388
- values.getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles), fromTargetObject);
389
+ values.getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore), fromTargetObject);
389
390
  }
390
391
  }
391
392
  }
@@ -394,7 +395,7 @@ class JSAnimation extends timer.Timer {
394
395
  if (fromTargetObject.o) {
395
396
  fromTargetObject.n = values.getRelativeValue(
396
397
  !prevSibling ? values.decomposeRawValue(
397
- values.getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles),
398
+ values.getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore),
398
399
  values.decomposedOriginalValue
399
400
  ).n : prevSibling._toNumber,
400
401
  fromTargetObject.n,
@@ -450,6 +451,10 @@ class JSAnimation extends timer.Timer {
450
451
  // Rounding is necessary here to minimize floating point errors when working in seconds
451
452
  const tweenUpdateDuration = helpers.round(+tweenDuration || consts.minValue, 12);
452
453
 
454
+ // Copy the value of the iniline style if it exist and imediatly nullify it to prevents false positive on other targets
455
+ let inlineValue = inlineStylesStore[propName];
456
+ if (!helpers.isNil(inlineValue)) inlineStylesStore[propName] = null;
457
+
453
458
  /** @type {Tween} */
454
459
  const tween = {
455
460
  parent: this,
@@ -458,7 +463,7 @@ class JSAnimation extends timer.Timer {
458
463
  target: target,
459
464
  _value: null,
460
465
  _func: toFunctionStore.func,
461
- _ease: eases.parseEase(tweenEasing),
466
+ _ease: parser.parseEase(tweenEasing),
462
467
  _fromNumbers: helpers.cloneArray(fromTargetObject.d),
463
468
  _toNumbers: helpers.cloneArray(toTargetObject.d),
464
469
  _strings: helpers.cloneArray(toTargetObject.s),
@@ -481,6 +486,7 @@ class JSAnimation extends timer.Timer {
481
486
  _isOverlapped: 0,
482
487
  _isOverridden: 0,
483
488
  _renderTransforms: 0,
489
+ _inlineValue: inlineValue,
484
490
  _prevRep: null, // For replaced tween
485
491
  _nextRep: null, // For replaced tween
486
492
  _prevAdd: null, // For additive tween
@@ -583,8 +589,6 @@ class JSAnimation extends timer.Timer {
583
589
  // this._offset += parent ? iterationDelay : 0;
584
590
  /** @type {Number} */
585
591
  this.iterationDuration = iterationDuration;
586
- /** @type {{}} */
587
- this._inlineStyles = animInlineStyles;
588
592
 
589
593
  if (!this._autoplay && shouldTriggerRender) this.onRender(this);
590
594
  }
@@ -618,6 +622,7 @@ class JSAnimation extends timer.Timer {
618
622
  if (tweenFunc) {
619
623
  const ogValue = values.getOriginalAnimatableValue(tween.target, tween.property, tween._tweenType);
620
624
  values.decomposeRawValue(ogValue, values.decomposedOriginalValue);
625
+ // TODO: Check for from / to Array based values here,
621
626
  values.decomposeRawValue(tweenFunc(), toTargetObject);
622
627
  tween._fromNumbers = helpers.cloneArray(values.decomposedOriginalValue.d);
623
628
  tween._fromNumber = values.decomposedOriginalValue.n;
@@ -627,6 +632,8 @@ class JSAnimation extends timer.Timer {
627
632
  tween._toNumber = toTargetObject.o ? values.getRelativeValue(values.decomposedOriginalValue.n, toTargetObject.n, toTargetObject.o) : toTargetObject.n;
628
633
  }
629
634
  });
635
+ // This forces setter animations to render once
636
+ if (this.duration === consts.minValue) this.restart();
630
637
  return this;
631
638
  }
632
639
 
@@ -640,8 +647,12 @@ class JSAnimation extends timer.Timer {
640
647
  }
641
648
 
642
649
  /**
643
- * @param {Callback<this>} [callback]
644
- * @return {Promise}
650
+ * @typedef {this & {then: null}} ResolvedJSAnimation
651
+ */
652
+
653
+ /**
654
+ * @param {Callback<ResolvedJSAnimation>} [callback]
655
+ * @return Promise<this>
645
656
  */
646
657
  then(callback) {
647
658
  return super.then(callback);
@@ -15,8 +15,6 @@ export class JSAnimation extends Timer {
15
15
  onRender: Callback<this>;
16
16
  /** @type {EasingFunction} */
17
17
  _ease: EasingFunction;
18
- /** @type {{}} */
19
- _inlineStyles: {};
20
18
  /**
21
19
  * @param {Number} newDuration
22
20
  * @return {this}
@@ -32,10 +30,15 @@ export class JSAnimation extends Timer {
32
30
  */
33
31
  revert(): this;
34
32
  /**
35
- * @param {Callback<this>} [callback]
36
- * @return {Promise}
33
+ * @typedef {this & {then: null}} ResolvedJSAnimation
37
34
  */
38
- then(callback?: Callback<this>): Promise<any>;
35
+ /**
36
+ * @param {Callback<ResolvedJSAnimation>} [callback]
37
+ * @return Promise<this>
38
+ */
39
+ then(callback?: Callback<this & {
40
+ then: null;
41
+ }>): Promise<any>;
39
42
  }
40
43
  export function animate(targets: TargetsParam, parameters: AnimationParams): JSAnimation;
41
44
  import { Timer } from '../timer/timer.js';
@@ -1,18 +1,18 @@
1
1
  /**
2
2
  * Anime.js - animation - ESM
3
- * @version v4.2.0
3
+ * @version v4.2.1
4
4
  * @license MIT
5
5
  * @copyright 2025 - Julian Garnier
6
6
  */
7
7
 
8
8
  import { K, compositionTypes, valueTypes, minValue, tweenTypes } from '../core/consts.js';
9
- import { mergeObjects, isUnd, isKey, isObj, round, cloneArray, addChild, forEachChildren, clampInfinity, normalizeTime, isArr, isNum } from '../core/helpers.js';
9
+ import { mergeObjects, isUnd, isKey, isObj, round, cloneArray, isNil, addChild, forEachChildren, clampInfinity, normalizeTime, isArr, isNum } from '../core/helpers.js';
10
10
  import { globals } from '../core/globals.js';
11
11
  import { registerTargets } from '../core/targets.js';
12
12
  import { setValue, getTweenType, getFunctionValue, decomposeRawValue, createDecomposedValueTargetObject, getOriginalAnimatableValue, decomposedOriginalValue, getRelativeValue, decomposeTweenValue } from '../core/values.js';
13
13
  import { sanitizePropertyName, cleanInlineStyles } from '../core/styles.js';
14
14
  import { convertValueUnit } from '../core/units.js';
15
- import { parseEase } from '../easings/eases.js';
15
+ import { parseEase } from '../easings/eases/parser.js';
16
16
  import { Timer } from '../timer/timer.js';
17
17
  import { getTweenSiblings, overrideTween, composeTween } from './composition.js';
18
18
  import { additive } from './additive.js';
@@ -43,13 +43,14 @@ import { additive } from './additive.js';
43
43
  *
44
44
  * @import {
45
45
  * Spring,
46
- * } from '../spring/spring.js'
46
+ * } from '../easings/spring/index.js'
47
47
  */
48
48
 
49
49
  // Defines decomposed values target objects only once and mutate their properties later to avoid GC
50
50
  // TODO: Maybe move the objects creation to values.js and use the decompose function to create the base object
51
51
  const fromTargetObject = createDecomposedValueTargetObject();
52
52
  const toTargetObject = createDecomposedValueTargetObject();
53
+ const inlineStylesStore = {};
53
54
  const toFunctionStore = { func: null };
54
55
  const keyframesTargetArray = [null];
55
56
  const fastSetValuesArray = [null, null];
@@ -194,15 +195,15 @@ class JSAnimation extends Timer {
194
195
  const animEase = animaPlaybackEase ? parseEase(animaPlaybackEase) : null;
195
196
  const hasSpring = !isUnd(ease) && !isUnd(/** @type {Spring} */(ease).ease);
196
197
  const tEasing = hasSpring ? /** @type {Spring} */(ease).ease : setValue(ease, animEase ? 'linear' : animDefaults.ease);
197
- const tDuration = hasSpring ? /** @type {Spring} */(ease).duration : setValue(duration, animDefaults.duration);
198
+ const tDuration = hasSpring ? /** @type {Spring} */(ease).settlingDuration : setValue(duration, animDefaults.duration);
198
199
  const tDelay = setValue(delay, animDefaults.delay);
199
200
  const tModifier = modifier || animDefaults.modifier;
200
201
  // If no composition is defined and the targets length is high (>= 1000) set the composition to 'none' (0) for faster tween creation
201
202
  const tComposition = isUnd(composition) && targetsLength >= K ? compositionTypes.none : !isUnd(composition) ? composition : animDefaults.composition;
202
- // TODO: Do not create an empty object until we know the animation will generate inline styles
203
- const animInlineStyles = {};
204
203
  // const absoluteOffsetTime = this._offset;
205
204
  const absoluteOffsetTime = this._offset + (parent ? parent._offset : 0);
205
+ // This allows targeting the current animation in the spring onComplete callback
206
+ if (hasSpring) /** @type {Spring} */(ease).parent = this;
206
207
 
207
208
  let iterationDuration = NaN;
208
209
  let iterationDelay = NaN;
@@ -304,7 +305,7 @@ class JSAnimation extends Timer {
304
305
  // Easing are treated differently and don't accept function based value to prevent having to pass a function wrapper that returns an other function all the time
305
306
  const tweenEasing = hasSpring ? /** @type {Spring} */(keyEasing).ease : keyEasing || tEasing;
306
307
  // Calculate default individual keyframe duration by dividing the tl of keyframes
307
- const tweenDuration = hasSpring ? /** @type {Spring} */(keyEasing).duration : getFunctionValue(setValue(key.duration, (l > 1 ? getFunctionValue(tDuration, target, ti, tl) / l : tDuration)), target, ti, tl);
308
+ const tweenDuration = hasSpring ? /** @type {Spring} */(keyEasing).settlingDuration : getFunctionValue(setValue(key.duration, (l > 1 ? getFunctionValue(tDuration, target, ti, tl) / l : tDuration)), target, ti, tl);
308
309
  // Default delay value should only be applied to the first tween
309
310
  const tweenDelay = getFunctionValue(setValue(key.delay, (!tweenIndex ? tDelay : 0)), target, ti, tl);
310
311
  const computedComposition = getFunctionValue(setValue(key.composition, tComposition), target, ti, tl);
@@ -354,7 +355,7 @@ class JSAnimation extends Timer {
354
355
  }
355
356
  } else {
356
357
  decomposeRawValue(
357
- getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles),
358
+ getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore),
358
359
  decomposedOriginalValue
359
360
  );
360
361
  if (decomposedOriginalValue.t === valueTypes.UNIT) {
@@ -372,7 +373,7 @@ class JSAnimation extends Timer {
372
373
  } else {
373
374
  // No need to get and parse the original value if the tween is part of a timeline and has a previous sibling part of the same timeline
374
375
  decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
375
- getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles), toTargetObject);
376
+ getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore), toTargetObject);
376
377
  }
377
378
  }
378
379
  if (hasFromvalue) {
@@ -383,7 +384,7 @@ class JSAnimation extends Timer {
383
384
  } else {
384
385
  decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
385
386
  // No need to get and parse the original value if the tween is part of a timeline and has a previous sibling part of the same timeline
386
- getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles), fromTargetObject);
387
+ getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore), fromTargetObject);
387
388
  }
388
389
  }
389
390
  }
@@ -392,7 +393,7 @@ class JSAnimation extends Timer {
392
393
  if (fromTargetObject.o) {
393
394
  fromTargetObject.n = getRelativeValue(
394
395
  !prevSibling ? decomposeRawValue(
395
- getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles),
396
+ getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore),
396
397
  decomposedOriginalValue
397
398
  ).n : prevSibling._toNumber,
398
399
  fromTargetObject.n,
@@ -448,6 +449,10 @@ class JSAnimation extends Timer {
448
449
  // Rounding is necessary here to minimize floating point errors when working in seconds
449
450
  const tweenUpdateDuration = round(+tweenDuration || minValue, 12);
450
451
 
452
+ // Copy the value of the iniline style if it exist and imediatly nullify it to prevents false positive on other targets
453
+ let inlineValue = inlineStylesStore[propName];
454
+ if (!isNil(inlineValue)) inlineStylesStore[propName] = null;
455
+
451
456
  /** @type {Tween} */
452
457
  const tween = {
453
458
  parent: this,
@@ -479,6 +484,7 @@ class JSAnimation extends Timer {
479
484
  _isOverlapped: 0,
480
485
  _isOverridden: 0,
481
486
  _renderTransforms: 0,
487
+ _inlineValue: inlineValue,
482
488
  _prevRep: null, // For replaced tween
483
489
  _nextRep: null, // For replaced tween
484
490
  _prevAdd: null, // For additive tween
@@ -581,8 +587,6 @@ class JSAnimation extends Timer {
581
587
  // this._offset += parent ? iterationDelay : 0;
582
588
  /** @type {Number} */
583
589
  this.iterationDuration = iterationDuration;
584
- /** @type {{}} */
585
- this._inlineStyles = animInlineStyles;
586
590
 
587
591
  if (!this._autoplay && shouldTriggerRender) this.onRender(this);
588
592
  }
@@ -616,6 +620,7 @@ class JSAnimation extends Timer {
616
620
  if (tweenFunc) {
617
621
  const ogValue = getOriginalAnimatableValue(tween.target, tween.property, tween._tweenType);
618
622
  decomposeRawValue(ogValue, decomposedOriginalValue);
623
+ // TODO: Check for from / to Array based values here,
619
624
  decomposeRawValue(tweenFunc(), toTargetObject);
620
625
  tween._fromNumbers = cloneArray(decomposedOriginalValue.d);
621
626
  tween._fromNumber = decomposedOriginalValue.n;
@@ -625,6 +630,8 @@ class JSAnimation extends Timer {
625
630
  tween._toNumber = toTargetObject.o ? getRelativeValue(decomposedOriginalValue.n, toTargetObject.n, toTargetObject.o) : toTargetObject.n;
626
631
  }
627
632
  });
633
+ // This forces setter animations to render once
634
+ if (this.duration === minValue) this.restart();
628
635
  return this;
629
636
  }
630
637
 
@@ -638,8 +645,12 @@ class JSAnimation extends Timer {
638
645
  }
639
646
 
640
647
  /**
641
- * @param {Callback<this>} [callback]
642
- * @return {Promise}
648
+ * @typedef {this & {then: null}} ResolvedJSAnimation
649
+ */
650
+
651
+ /**
652
+ * @param {Callback<ResolvedJSAnimation>} [callback]
653
+ * @return Promise<this>
643
654
  */
644
655
  then(callback) {
645
656
  return super.then(callback);
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - animation - CJS
3
- * @version v4.2.0
3
+ * @version v4.2.1
4
4
  * @license MIT
5
5
  * @copyright 2025 - Julian Garnier
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - animation - ESM
3
- * @version v4.2.0
3
+ * @version v4.2.1
4
4
  * @license MIT
5
5
  * @copyright 2025 - Julian Garnier
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - animation - CJS
3
- * @version v4.2.0
3
+ * @version v4.2.1
4
4
  * @license MIT
5
5
  * @copyright 2025 - Julian Garnier
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - animation - ESM
3
- * @version v4.2.0
3
+ * @version v4.2.1
4
4
  * @license MIT
5
5
  * @copyright 2025 - Julian Garnier
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - core - CJS
3
- * @version v4.2.0
3
+ * @version v4.2.1
4
4
  * @license MIT
5
5
  * @copyright 2025 - Julian Garnier
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - core - ESM
3
- * @version v4.2.0
3
+ * @version v4.2.1
4
4
  * @license MIT
5
5
  * @copyright 2025 - Julian Garnier
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - core - CJS
3
- * @version v4.2.0
3
+ * @version v4.2.1
4
4
  * @license MIT
5
5
  * @copyright 2025 - Julian Garnier
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - core - ESM
3
- * @version v4.2.0
3
+ * @version v4.2.1
4
4
  * @license MIT
5
5
  * @copyright 2025 - Julian Garnier
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - core - CJS
3
- * @version v4.2.0
3
+ * @version v4.2.1
4
4
  * @license MIT
5
5
  * @copyright 2025 - Julian Garnier
6
6
  */
@@ -70,6 +70,8 @@ const maxFps = 120;
70
70
  // Strings
71
71
 
72
72
  const emptyString = '';
73
+ const cssVarPrefix = 'var(';
74
+
73
75
  const shortTransforms = /*#__PURE__*/ (() => {
74
76
  const map = new Map();
75
77
  map.set('x', 'translateX');
@@ -93,9 +95,9 @@ const validTransforms = [
93
95
  'skew',
94
96
  'skewX',
95
97
  'skewY',
96
- 'perspective',
97
98
  'matrix',
98
99
  'matrix3d',
100
+ 'perspective',
99
101
  ];
100
102
 
101
103
  const transformsFragmentStrings = /*#__PURE__*/ validTransforms.reduce((a, v) => ({...a, [v]: v + '('}), {});
@@ -119,9 +121,12 @@ const unitsExecRgx = /^([-+]?\d*\.?\d+(?:e[-+]?\d+)?)([a-z]+|%)$/i;
119
121
  const lowerCaseRgx = /([a-z])([A-Z])/g;
120
122
  const transformsExecRgx = /(\w+)(\([^)]+\)+)/g; // Match inline transforms with cacl() values, returns the value wrapped in ()
121
123
  const relativeValuesExecRgx = /(\*=|\+=|-=)/;
124
+ const cssVariableMatchRgx = /var\(\s*(--[\w-]+)(?:\s*,\s*([^)]+))?\s*\)/;
122
125
 
123
126
  exports.K = K;
124
127
  exports.compositionTypes = compositionTypes;
128
+ exports.cssVarPrefix = cssVarPrefix;
129
+ exports.cssVariableMatchRgx = cssVariableMatchRgx;
125
130
  exports.digitWithExponentRgx = digitWithExponentRgx;
126
131
  exports.doc = doc;
127
132
  exports.emptyString = emptyString;
@@ -43,6 +43,7 @@ export const maxValue: 1000000000000;
43
43
  export const K: 1000;
44
44
  export const maxFps: 120;
45
45
  export const emptyString: "";
46
+ export const cssVarPrefix: "var(";
46
47
  export const shortTransforms: Map<any, any>;
47
48
  export const validTransforms: string[];
48
49
  export const transformsFragmentStrings: {};
@@ -57,3 +58,4 @@ export const unitsExecRgx: RegExp;
57
58
  export const lowerCaseRgx: RegExp;
58
59
  export const transformsExecRgx: RegExp;
59
60
  export const relativeValuesExecRgx: RegExp;
61
+ export const cssVariableMatchRgx: RegExp;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - core - ESM
3
- * @version v4.2.0
3
+ * @version v4.2.1
4
4
  * @license MIT
5
5
  * @copyright 2025 - Julian Garnier
6
6
  */
@@ -68,6 +68,8 @@ const maxFps = 120;
68
68
  // Strings
69
69
 
70
70
  const emptyString = '';
71
+ const cssVarPrefix = 'var(';
72
+
71
73
  const shortTransforms = /*#__PURE__*/ (() => {
72
74
  const map = new Map();
73
75
  map.set('x', 'translateX');
@@ -91,9 +93,9 @@ const validTransforms = [
91
93
  'skew',
92
94
  'skewX',
93
95
  'skewY',
94
- 'perspective',
95
96
  'matrix',
96
97
  'matrix3d',
98
+ 'perspective',
97
99
  ];
98
100
 
99
101
  const transformsFragmentStrings = /*#__PURE__*/ validTransforms.reduce((a, v) => ({...a, [v]: v + '('}), {});
@@ -117,5 +119,6 @@ const unitsExecRgx = /^([-+]?\d*\.?\d+(?:e[-+]?\d+)?)([a-z]+|%)$/i;
117
119
  const lowerCaseRgx = /([a-z])([A-Z])/g;
118
120
  const transformsExecRgx = /(\w+)(\([^)]+\)+)/g; // Match inline transforms with cacl() values, returns the value wrapped in ()
119
121
  const relativeValuesExecRgx = /(\*=|\+=|-=)/;
122
+ const cssVariableMatchRgx = /var\(\s*(--[\w-]+)(?:\s*,\s*([^)]+))?\s*\)/;
120
123
 
121
- export { K, compositionTypes, digitWithExponentRgx, doc, emptyString, hexTestRgx, hslExecRgx, hslaExecRgx, isBrowser, isDomSymbol, isRegisteredTargetSymbol, isSvgSymbol, lowerCaseRgx, maxFps, maxValue, minValue, morphPointsSymbol, noop, proxyTargetSymbol, relativeValuesExecRgx, rgbExecRgx, rgbaExecRgx, shortTransforms, tickModes, transformsExecRgx, transformsFragmentStrings, transformsSymbol, tweenTypes, unitsExecRgx, validTransforms, valueTypes, win };
124
+ export { K, compositionTypes, cssVarPrefix, cssVariableMatchRgx, digitWithExponentRgx, doc, emptyString, hexTestRgx, hslExecRgx, hslaExecRgx, isBrowser, isDomSymbol, isRegisteredTargetSymbol, isSvgSymbol, lowerCaseRgx, maxFps, maxValue, minValue, morphPointsSymbol, noop, proxyTargetSymbol, relativeValuesExecRgx, rgbExecRgx, rgbaExecRgx, shortTransforms, tickModes, transformsExecRgx, transformsFragmentStrings, transformsSymbol, tweenTypes, unitsExecRgx, validTransforms, valueTypes, win };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - core - CJS
3
- * @version v4.2.0
3
+ * @version v4.2.1
4
4
  * @license MIT
5
5
  * @copyright 2025 - Julian Garnier
6
6
  */
@@ -31,6 +31,7 @@ const defaults = {
31
31
  reversed: false,
32
32
  alternate: false,
33
33
  autoplay: true,
34
+ persist: false,
34
35
  duration: consts.K,
35
36
  delay: 0,
36
37
  loopDelay: 0,
@@ -64,7 +65,7 @@ const globals = {
64
65
  tickThreshold: 200,
65
66
  };
66
67
 
67
- const globalVersions = { version: '4.2.0', engine: null };
68
+ const globalVersions = { version: '4.2.1', engine: null };
68
69
 
69
70
  if (consts.isBrowser) {
70
71
  if (!consts.win.AnimeJS) consts.win.AnimeJS = [];
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - core - ESM
3
- * @version v4.2.0
3
+ * @version v4.2.1
4
4
  * @license MIT
5
5
  * @copyright 2025 - Julian Garnier
6
6
  */
@@ -29,6 +29,7 @@ const defaults = {
29
29
  reversed: false,
30
30
  alternate: false,
31
31
  autoplay: true,
32
+ persist: false,
32
33
  duration: K,
33
34
  delay: 0,
34
35
  loopDelay: 0,
@@ -62,7 +63,7 @@ const globals = {
62
63
  tickThreshold: 200,
63
64
  };
64
65
 
65
- const globalVersions = { version: '4.2.0', engine: null };
66
+ const globalVersions = { version: '4.2.1', engine: null };
66
67
 
67
68
  if (isBrowser) {
68
69
  if (!win.AnimeJS) win.AnimeJS = [];
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - core - CJS
3
- * @version v4.2.0
3
+ * @version v4.2.1
4
4
  * @license MIT
5
5
  * @copyright 2025 - Julian Garnier
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - core - ESM
3
- * @version v4.2.0
3
+ * @version v4.2.1
4
4
  * @license MIT
5
5
  * @copyright 2025 - Julian Garnier
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - core - CJS
3
- * @version v4.2.0
3
+ * @version v4.2.1
4
4
  * @license MIT
5
5
  * @copyright 2025 - Julian Garnier
6
6
  */
@@ -283,7 +283,9 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
283
283
  // Handle setters on timeline differently and allow re-trigering the onComplete callback when seeking backwards
284
284
  if (parent && isSetter) {
285
285
  if (!muteCallbacks && (
286
- (parent.began && !isRunningBackwards && tickableAbsoluteTime >= duration && !completed) ||
286
+ // (tickableAbsoluteTime > 0 instead) of (tickableAbsoluteTime >= duration) to prevent floating point precision issues
287
+ // see: https://github.com/juliangarnier/anime/issues/1088
288
+ (parent.began && !isRunningBackwards && tickableAbsoluteTime > 0 && !completed) ||
287
289
  (isRunningBackwards && tickableAbsoluteTime <= consts.minValue && completed)
288
290
  )) {
289
291
  tickable.onComplete(/** @type {CallbackArgument} */(tickable));
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - core - ESM
3
- * @version v4.2.0
3
+ * @version v4.2.1
4
4
  * @license MIT
5
5
  * @copyright 2025 - Julian Garnier
6
6
  */
@@ -281,7 +281,9 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
281
281
  // Handle setters on timeline differently and allow re-trigering the onComplete callback when seeking backwards
282
282
  if (parent && isSetter) {
283
283
  if (!muteCallbacks && (
284
- (parent.began && !isRunningBackwards && tickableAbsoluteTime >= duration && !completed) ||
284
+ // (tickableAbsoluteTime > 0 instead) of (tickableAbsoluteTime >= duration) to prevent floating point precision issues
285
+ // see: https://github.com/juliangarnier/anime/issues/1088
286
+ (parent.began && !isRunningBackwards && tickableAbsoluteTime > 0 && !completed) ||
285
287
  (isRunningBackwards && tickableAbsoluteTime <= minValue && completed)
286
288
  )) {
287
289
  tickable.onComplete(/** @type {CallbackArgument} */(tickable));