animejs 4.3.6 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/README.md +8 -11
  2. package/dist/bundles/anime.esm.js +1033 -421
  3. package/dist/bundles/anime.esm.min.js +2 -2
  4. package/dist/bundles/anime.umd.js +1038 -421
  5. package/dist/bundles/anime.umd.min.js +2 -2
  6. package/dist/modules/animatable/animatable.cjs +1 -1
  7. package/dist/modules/animatable/animatable.js +2 -2
  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 +38 -16
  13. package/dist/modules/animation/animation.d.ts +2 -2
  14. package/dist/modules/animation/animation.js +42 -20
  15. package/dist/modules/animation/composition.cjs +1 -1
  16. package/dist/modules/animation/composition.js +3 -3
  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 +3 -9
  24. package/dist/modules/core/consts.d.ts +1 -5
  25. package/dist/modules/core/consts.js +4 -8
  26. package/dist/modules/core/globals.cjs +16 -5
  27. package/dist/modules/core/globals.d.ts +22 -1
  28. package/dist/modules/core/globals.js +18 -6
  29. package/dist/modules/core/helpers.cjs +7 -10
  30. package/dist/modules/core/helpers.js +8 -11
  31. package/dist/modules/core/render.cjs +66 -63
  32. package/dist/modules/core/render.js +68 -65
  33. package/dist/modules/core/styles.cjs +53 -32
  34. package/dist/modules/core/styles.d.ts +1 -0
  35. package/dist/modules/core/styles.js +55 -35
  36. package/dist/modules/core/targets.cjs +1 -1
  37. package/dist/modules/core/targets.js +1 -1
  38. package/dist/modules/core/transforms.cjs +129 -13
  39. package/dist/modules/core/transforms.d.ts +1 -0
  40. package/dist/modules/core/transforms.js +130 -15
  41. package/dist/modules/core/units.cjs +1 -1
  42. package/dist/modules/core/units.js +1 -1
  43. package/dist/modules/core/values.cjs +68 -8
  44. package/dist/modules/core/values.d.ts +5 -2
  45. package/dist/modules/core/values.js +69 -11
  46. package/dist/modules/draggable/draggable.cjs +1 -1
  47. package/dist/modules/draggable/draggable.js +1 -1
  48. package/dist/modules/draggable/index.cjs +1 -1
  49. package/dist/modules/draggable/index.js +1 -1
  50. package/dist/modules/easings/cubic-bezier/index.cjs +1 -1
  51. package/dist/modules/easings/cubic-bezier/index.js +1 -1
  52. package/dist/modules/easings/eases/index.cjs +1 -1
  53. package/dist/modules/easings/eases/index.js +1 -1
  54. package/dist/modules/easings/eases/parser.cjs +1 -1
  55. package/dist/modules/easings/eases/parser.js +1 -1
  56. package/dist/modules/easings/index.cjs +1 -1
  57. package/dist/modules/easings/index.js +1 -1
  58. package/dist/modules/easings/irregular/index.cjs +1 -1
  59. package/dist/modules/easings/irregular/index.js +1 -1
  60. package/dist/modules/easings/linear/index.cjs +1 -1
  61. package/dist/modules/easings/linear/index.js +1 -1
  62. package/dist/modules/easings/none.cjs +1 -1
  63. package/dist/modules/easings/none.js +1 -1
  64. package/dist/modules/easings/spring/index.cjs +1 -1
  65. package/dist/modules/easings/spring/index.js +1 -1
  66. package/dist/modules/easings/steps/index.cjs +1 -1
  67. package/dist/modules/easings/steps/index.js +1 -1
  68. package/dist/modules/engine/engine.cjs +1 -1
  69. package/dist/modules/engine/engine.js +1 -1
  70. package/dist/modules/engine/index.cjs +1 -1
  71. package/dist/modules/engine/index.js +1 -1
  72. package/dist/modules/events/index.cjs +1 -1
  73. package/dist/modules/events/index.js +1 -1
  74. package/dist/modules/events/scroll.cjs +1 -1
  75. package/dist/modules/events/scroll.js +1 -1
  76. package/dist/modules/index.cjs +9 -1
  77. package/dist/modules/index.d.ts +1 -0
  78. package/dist/modules/index.js +4 -1
  79. package/dist/modules/layout/index.cjs +1 -1
  80. package/dist/modules/layout/index.js +1 -1
  81. package/dist/modules/layout/layout.cjs +29 -25
  82. package/dist/modules/layout/layout.d.ts +4 -3
  83. package/dist/modules/layout/layout.js +30 -26
  84. package/dist/modules/scope/index.cjs +1 -1
  85. package/dist/modules/scope/index.js +1 -1
  86. package/dist/modules/scope/scope.cjs +1 -1
  87. package/dist/modules/scope/scope.js +1 -1
  88. package/dist/modules/svg/drawable.cjs +1 -1
  89. package/dist/modules/svg/drawable.js +1 -1
  90. package/dist/modules/svg/helpers.cjs +1 -1
  91. package/dist/modules/svg/helpers.js +1 -1
  92. package/dist/modules/svg/index.cjs +1 -1
  93. package/dist/modules/svg/index.js +1 -1
  94. package/dist/modules/svg/morphto.cjs +3 -6
  95. package/dist/modules/svg/morphto.js +3 -6
  96. package/dist/modules/svg/motionpath.cjs +1 -1
  97. package/dist/modules/svg/motionpath.js +1 -1
  98. package/dist/modules/text/index.cjs +3 -1
  99. package/dist/modules/text/index.d.ts +1 -0
  100. package/dist/modules/text/index.js +2 -1
  101. package/dist/modules/text/scramble.cjs +272 -0
  102. package/dist/modules/text/scramble.d.ts +3 -0
  103. package/dist/modules/text/scramble.js +270 -0
  104. package/dist/modules/text/split.cjs +5 -5
  105. package/dist/modules/text/split.d.ts +5 -5
  106. package/dist/modules/text/split.js +5 -5
  107. package/dist/modules/timeline/index.cjs +1 -1
  108. package/dist/modules/timeline/index.js +1 -1
  109. package/dist/modules/timeline/position.cjs +1 -1
  110. package/dist/modules/timeline/position.js +1 -1
  111. package/dist/modules/timeline/timeline.cjs +36 -18
  112. package/dist/modules/timeline/timeline.d.ts +6 -5
  113. package/dist/modules/timeline/timeline.js +37 -19
  114. package/dist/modules/timer/index.cjs +1 -1
  115. package/dist/modules/timer/index.js +1 -1
  116. package/dist/modules/timer/timer.cjs +8 -12
  117. package/dist/modules/timer/timer.d.ts +2 -0
  118. package/dist/modules/timer/timer.js +9 -13
  119. package/dist/modules/types/index.d.ts +76 -8
  120. package/dist/modules/utils/chainable.cjs +8 -5
  121. package/dist/modules/utils/chainable.js +8 -5
  122. package/dist/modules/utils/index.cjs +5 -1
  123. package/dist/modules/utils/index.d.ts +1 -0
  124. package/dist/modules/utils/index.js +2 -1
  125. package/dist/modules/utils/number.cjs +1 -1
  126. package/dist/modules/utils/number.js +1 -1
  127. package/dist/modules/utils/random.cjs +1 -1
  128. package/dist/modules/utils/random.js +1 -1
  129. package/dist/modules/utils/stagger.cjs +117 -20
  130. package/dist/modules/utils/stagger.js +118 -21
  131. package/dist/modules/utils/target.cjs +1 -1
  132. package/dist/modules/utils/target.js +1 -1
  133. package/dist/modules/utils/time.cjs +5 -3
  134. package/dist/modules/utils/time.d.ts +1 -1
  135. package/dist/modules/utils/time.js +5 -3
  136. package/dist/modules/waapi/composition.cjs +1 -1
  137. package/dist/modules/waapi/composition.js +1 -1
  138. package/dist/modules/waapi/index.cjs +1 -1
  139. package/dist/modules/waapi/index.js +1 -1
  140. package/dist/modules/waapi/waapi.cjs +19 -20
  141. package/dist/modules/waapi/waapi.js +20 -21
  142. package/package.json +2 -1
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * Anime.js - utils - ESM
3
- * @version v4.3.6
3
+ * @version v4.4.0
4
4
  * @license MIT
5
5
  * @copyright 2026 - Julian Garnier
6
6
  */
7
7
 
8
8
  import { unitsExecRgx, emptyString } from '../core/consts.js';
9
- import { isUnd, parseNumber, isFnc, abs, floor, sqrt, round, isArr, isNum, isStr, max } from '../core/helpers.js';
9
+ import { isUnd, parseNumber, isFnc, isNum, sqrt, abs, floor, max, round, isArr, isStr } from '../core/helpers.js';
10
10
  import { parseEase } from '../easings/eases/parser.js';
11
11
  import { parseTimelinePosition } from '../timeline/position.js';
12
12
  import { getOriginalAnimatableValue } from '../core/values.js';
@@ -17,6 +17,7 @@ import { shuffle } from './random.js';
17
17
  * @import {
18
18
  * StaggerParams,
19
19
  * StaggerFunction,
20
+ * JSTarget,
20
21
  * } from '../types/index.js'
21
22
  */
22
23
 
@@ -32,24 +33,28 @@ import { shuffle } from './random.js';
32
33
  * @param {StaggerParams} [params]
33
34
  * @return {StaggerFunction<Number>}
34
35
  */
36
+
35
37
  /**
36
38
  * @overload
37
39
  * @param {String} val
38
40
  * @param {StaggerParams} [params]
39
41
  * @return {StaggerFunction<String>}
40
42
  */
43
+
41
44
  /**
42
45
  * @overload
43
46
  * @param {[Number, Number]} val
44
47
  * @param {StaggerParams} [params]
45
48
  * @return {StaggerFunction<Number>}
46
49
  */
50
+
47
51
  /**
48
52
  * @overload
49
53
  * @param {[String, String]} val
50
54
  * @param {StaggerParams} [params]
51
55
  * @return {StaggerFunction<String>}
52
56
  */
57
+
53
58
  /**
54
59
  * @param {Number|String|[Number, Number]|[String, String]} val The staggered value or range
55
60
  * @param {StaggerParams} [params] The stagger parameters
@@ -58,6 +63,7 @@ import { shuffle } from './random.js';
58
63
  const stagger = (val, params = {}) => {
59
64
  let values = [];
60
65
  let maxValue = 0;
66
+ let cachedOffset;
61
67
  const from = params.from;
62
68
  const reversed = params.reversed;
63
69
  const ease = params.ease;
@@ -65,12 +71,14 @@ const stagger = (val, params = {}) => {
65
71
  const hasSpring = hasEasing && !isUnd(/** @type {Spring} */(ease).ease);
66
72
  const staggerEase = hasSpring ? /** @type {Spring} */(ease).ease : hasEasing ? parseEase(ease) : null;
67
73
  const grid = params.grid;
74
+ const autoGrid = grid === true;
68
75
  const axis = params.axis;
69
76
  const customTotal = params.total;
70
77
  const fromFirst = isUnd(from) || from === 0 || from === 'first';
71
78
  const fromCenter = from === 'center';
72
79
  const fromLast = from === 'last';
73
80
  const fromRandom = from === 'random';
81
+ const fromArr = isArr(from);
74
82
  const isRange = isArr(val);
75
83
  const useProp = params.use;
76
84
  const val1 = isRange ? parseNumber(val[0]) : parseNumber(val);
@@ -78,40 +86,129 @@ const stagger = (val, params = {}) => {
78
86
  const unitMatch = unitsExecRgx.exec((isRange ? val[1] : val) + emptyString);
79
87
  const start = params.start || 0 + (isRange ? val1 : 0);
80
88
  let fromIndex = fromFirst ? 0 : isNum(from) ? from : 0;
81
- return (target, i, t, tl) => {
89
+ return (target, i, t, _, tl) => {
82
90
  const [ registeredTarget ] = registerTargets(target);
83
- const total = isUnd(customTotal) ? t : customTotal;
91
+ const total = isUnd(customTotal) ? t.length : customTotal;
84
92
  const customIndex = !isUnd(useProp) ? isFnc(useProp) ? useProp(registeredTarget, i, total) : getOriginalAnimatableValue(registeredTarget, useProp) : false;
85
93
  const staggerIndex = isNum(customIndex) || isStr(customIndex) && isNum(+customIndex) ? +customIndex : i;
86
94
  if (fromCenter) fromIndex = (total - 1) / 2;
87
95
  if (fromLast) fromIndex = total - 1;
88
96
  if (!values.length) {
89
- for (let index = 0; index < total; index++) {
90
- if (!grid) {
91
- values.push(abs(fromIndex - index));
97
+ if (autoGrid) {
98
+ let hasPositions = true;
99
+ let minPosX = Infinity;
100
+ let minPosY = Infinity;
101
+ let maxPosX = -Infinity;
102
+ let maxPosY = -Infinity;
103
+ const pxArr = [];
104
+ const pyArr = [];
105
+ for (let index = 0; index < total; index++) {
106
+ const el = t[index];
107
+ let px = 0;
108
+ let py = 0;
109
+ let found = false;
110
+ if (el && isFnc(el.getBoundingClientRect)) {
111
+ const rect = el.getBoundingClientRect();
112
+ px = rect.left + rect.width / 2;
113
+ py = rect.top + rect.height / 2;
114
+ found = true;
115
+ } else {
116
+ const obj = /** @type {JSTarget} */(el);
117
+ if (obj && isNum(obj.x) && isNum(obj.y)) {
118
+ px = obj.x;
119
+ py = obj.y;
120
+ found = true;
121
+ }
122
+ }
123
+ if (!found) {
124
+ hasPositions = false;
125
+ break;
126
+ }
127
+ pxArr.push(px);
128
+ pyArr.push(py);
129
+ if (px < minPosX) minPosX = px;
130
+ if (py < minPosY) minPosY = py;
131
+ if (px > maxPosX) maxPosX = px;
132
+ if (py > maxPosY) maxPosY = py;
133
+ }
134
+ if (hasPositions) {
135
+ let fX = pxArr[0];
136
+ let fY = pyArr[0];
137
+ if (fromArr) {
138
+ fX = minPosX + from[0] * (maxPosX - minPosX);
139
+ fY = minPosY + from[1] * (maxPosY - minPosY);
140
+ } else if (fromCenter) {
141
+ fX = (minPosX + maxPosX) / 2;
142
+ fY = (minPosY + maxPosY) / 2;
143
+ } else if (fromLast) {
144
+ fX = pxArr[total - 1];
145
+ fY = pyArr[total - 1];
146
+ } else if (isNum(from)) {
147
+ fX = pxArr[from];
148
+ fY = pyArr[from];
149
+ }
150
+ for (let index = 0; index < total; index++) {
151
+ const distanceX = fX - pxArr[index];
152
+ const distanceY = fY - pyArr[index];
153
+ let value = sqrt(distanceX * distanceX + distanceY * distanceY);
154
+ if (axis === 'x') value = -distanceX;
155
+ if (axis === 'y') value = -distanceY;
156
+ values.push(value);
157
+ }
158
+ let minDist = Infinity;
159
+ for (let index = 0, l = values.length; index < l; index++) {
160
+ const absVal = abs(values[index]);
161
+ if (absVal > 0 && absVal < minDist) minDist = absVal;
162
+ }
163
+ if (minDist > 0 && minDist < Infinity) {
164
+ for (let index = 0, l = values.length; index < l; index++) {
165
+ values[index] = values[index] / minDist;
166
+ }
167
+ }
92
168
  } else {
93
- const fromX = !fromCenter ? fromIndex % grid[0] : (grid[0] - 1) / 2;
94
- const fromY = !fromCenter ? floor(fromIndex / grid[0]) : (grid[1] - 1) / 2;
95
- const toX = index % grid[0];
96
- const toY = floor(index / grid[0]);
97
- const distanceX = fromX - toX;
98
- const distanceY = fromY - toY;
99
- let value = sqrt(distanceX * distanceX + distanceY * distanceY);
100
- if (axis === 'x') value = -distanceX;
101
- if (axis === 'y') value = -distanceY;
102
- values.push(value);
169
+ for (let index = 0; index < total; index++) {
170
+ values.push(abs(fromIndex - index));
171
+ }
172
+ }
173
+ } else {
174
+ for (let index = 0; index < total; index++) {
175
+ if (!grid) {
176
+ values.push(abs(fromIndex - index));
177
+ } else {
178
+ let fromX, fromY;
179
+ if (fromArr) {
180
+ fromX = from[0] * (grid[0] - 1);
181
+ fromY = from[1] * (grid[1] - 1);
182
+ } else if (fromCenter) {
183
+ fromX = (grid[0] - 1) / 2;
184
+ fromY = (grid[1] - 1) / 2;
185
+ } else {
186
+ fromX = fromIndex % grid[0];
187
+ fromY = floor(fromIndex / grid[0]);
188
+ }
189
+ const toX = index % grid[0];
190
+ const toY = floor(index / grid[0]);
191
+ const distanceX = fromX - toX;
192
+ const distanceY = fromY - toY;
193
+ let value = sqrt(distanceX * distanceX + distanceY * distanceY);
194
+ if (axis === 'x') value = -distanceX;
195
+ if (axis === 'y') value = -distanceY;
196
+ values.push(value);
197
+ }
103
198
  }
104
- maxValue = max(...values);
105
199
  }
200
+ maxValue = max(...values);
106
201
  if (staggerEase) values = values.map(val => staggerEase(val / maxValue) * maxValue);
107
202
  if (reversed) values = values.map(val => axis ? (val < 0) ? val * -1 : -val : abs(maxValue - val));
108
203
  if (fromRandom) values = shuffle(values);
109
204
  }
110
205
  const spacing = isRange ? (val2 - val1) / maxValue : val1;
111
- const offset = tl ? parseTimelinePosition(tl, isUnd(params.start) ? tl.iterationDuration : start) : /** @type {Number} */(start);
206
+ if (isUnd(cachedOffset)) {
207
+ cachedOffset = tl ? parseTimelinePosition(tl, isUnd(params.start) ? tl.iterationDuration : start) : /** @type {Number} */(start);
208
+ }
112
209
  /** @type {String|Number} */
113
- let output = offset + ((spacing * round(values[staggerIndex], 2)) || 0);
114
- if (params.modifier) output = params.modifier(output);
210
+ let output = cachedOffset + ((spacing * round(values[staggerIndex], 2)) || 0);
211
+ if (params.modifier) output = params.modifier(/** @type {Number} */(output));
115
212
  if (unitMatch) output = `${output}${unitMatch[2]}`;
116
213
  return output;
117
214
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - utils - CJS
3
- * @version v4.3.6
3
+ * @version v4.4.0
4
4
  * @license MIT
5
5
  * @copyright 2026 - Julian Garnier
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - utils - ESM
3
- * @version v4.3.6
3
+ * @version v4.4.0
4
4
  * @license MIT
5
5
  * @copyright 2026 - Julian Garnier
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - utils - CJS
3
- * @version v4.3.6
3
+ * @version v4.4.0
4
4
  * @license MIT
5
5
  * @copyright 2026 - Julian Garnier
6
6
  */
@@ -28,19 +28,20 @@ const sync = (callback = consts.noop) => {
28
28
  };
29
29
 
30
30
  /**
31
- * @param {(...args: any[]) => Tickable | ((...args: any[]) => void)} constructor
31
+ * @param {(...args: any[]) => Tickable | ((...args: any[]) => void) | void} constructor
32
32
  * @return {(...args: any[]) => Tickable | ((...args: any[]) => void)}
33
33
  */
34
34
  const keepTime = constructor => {
35
35
  /** @type {Tickable} */
36
36
  let tracked;
37
37
  return (...args) => {
38
- let currentIteration, currentIterationProgress, reversed, alternate;
38
+ let currentIteration, currentIterationProgress, reversed, alternate, startTime;
39
39
  if (tracked) {
40
40
  currentIteration = tracked.currentIteration;
41
41
  currentIterationProgress = tracked.iterationProgress;
42
42
  reversed = tracked.reversed;
43
43
  alternate = tracked._alternate;
44
+ startTime = tracked._startTime;
44
45
  tracked.revert();
45
46
  }
46
47
  const cleanup = constructor(...args);
@@ -48,6 +49,7 @@ const keepTime = constructor => {
48
49
  if (!helpers.isUnd(currentIterationProgress)) {
49
50
  /** @type {Tickable} */(tracked).currentIteration = currentIteration;
50
51
  /** @type {Tickable} */(tracked).iterationProgress = (alternate ? !(currentIteration % 2) ? reversed : !reversed : reversed) ? 1 - currentIterationProgress : currentIterationProgress;
52
+ /** @type {Tickable} */(tracked)._startTime = startTime;
51
53
  }
52
54
  return cleanup || consts.noop;
53
55
  }
@@ -1,5 +1,5 @@
1
1
  export function sync(callback?: Callback<Timer>): Timer;
2
- export function keepTime(constructor: (...args: any[]) => Tickable | ((...args: any[]) => void)): (...args: any[]) => Tickable | ((...args: any[]) => void);
2
+ export function keepTime(constructor: (...args: any[]) => Tickable | ((...args: any[]) => void) | void): (...args: any[]) => Tickable | ((...args: any[]) => void);
3
3
  import { Timer } from '../timer/timer.js';
4
4
  import type { Callback } from '../types/index.js';
5
5
  import type { Tickable } from '../types/index.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - utils - ESM
3
- * @version v4.3.6
3
+ * @version v4.4.0
4
4
  * @license MIT
5
5
  * @copyright 2026 - Julian Garnier
6
6
  */
@@ -26,19 +26,20 @@ const sync = (callback = noop) => {
26
26
  };
27
27
 
28
28
  /**
29
- * @param {(...args: any[]) => Tickable | ((...args: any[]) => void)} constructor
29
+ * @param {(...args: any[]) => Tickable | ((...args: any[]) => void) | void} constructor
30
30
  * @return {(...args: any[]) => Tickable | ((...args: any[]) => void)}
31
31
  */
32
32
  const keepTime = constructor => {
33
33
  /** @type {Tickable} */
34
34
  let tracked;
35
35
  return (...args) => {
36
- let currentIteration, currentIterationProgress, reversed, alternate;
36
+ let currentIteration, currentIterationProgress, reversed, alternate, startTime;
37
37
  if (tracked) {
38
38
  currentIteration = tracked.currentIteration;
39
39
  currentIterationProgress = tracked.iterationProgress;
40
40
  reversed = tracked.reversed;
41
41
  alternate = tracked._alternate;
42
+ startTime = tracked._startTime;
42
43
  tracked.revert();
43
44
  }
44
45
  const cleanup = constructor(...args);
@@ -46,6 +47,7 @@ const keepTime = constructor => {
46
47
  if (!isUnd(currentIterationProgress)) {
47
48
  /** @type {Tickable} */(tracked).currentIteration = currentIteration;
48
49
  /** @type {Tickable} */(tracked).iterationProgress = (alternate ? !(currentIteration % 2) ? reversed : !reversed : reversed) ? 1 - currentIterationProgress : currentIterationProgress;
50
+ /** @type {Tickable} */(tracked)._startTime = startTime;
49
51
  }
50
52
  return cleanup || noop;
51
53
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - waapi - CJS
3
- * @version v4.3.6
3
+ * @version v4.4.0
4
4
  * @license MIT
5
5
  * @copyright 2026 - Julian Garnier
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - waapi - ESM
3
- * @version v4.3.6
3
+ * @version v4.4.0
4
4
  * @license MIT
5
5
  * @copyright 2026 - Julian Garnier
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - waapi - CJS
3
- * @version v4.3.6
3
+ * @version v4.4.0
4
4
  * @license MIT
5
5
  * @copyright 2026 - Julian Garnier
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - waapi - ESM
3
- * @version v4.3.6
3
+ * @version v4.4.0
4
4
  * @license MIT
5
5
  * @copyright 2026 - Julian Garnier
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - waapi - CJS
3
- * @version v4.3.6
3
+ * @version v4.4.0
4
4
  * @license MIT
5
5
  * @copyright 2026 - Julian Garnier
6
6
  */
@@ -116,12 +116,12 @@ let transformsPropertiesRegistered = null;
116
116
  * @param {WAAPIKeyframeValue} value
117
117
  * @param {DOMTarget} $el
118
118
  * @param {Number} i
119
- * @param {Number} targetsLength
119
+ * @param {DOMTargetsArray} parsedTargets
120
120
  * @return {String}
121
121
  */
122
- const normalizeTweenValue = (propName, value, $el, i, targetsLength) => {
122
+ const normalizeTweenValue = (propName, value, $el, i, parsedTargets) => {
123
123
  // Do not try to compute strings with getFunctionValue otherwise it will convert CSS variables
124
- let v = helpers.isStr(value) ? value : values.getFunctionValue(/** @type {any} */(value), $el, i, targetsLength);
124
+ let v = helpers.isStr(value) ? value : values.getFunctionValue(/** @type {any} */(value), $el, i, parsedTargets, null, null);
125
125
  if (!helpers.isNum(v)) return v;
126
126
  if (commonDefaultPXProperties.includes(propName) || helpers.stringStartsWith(propName, 'translate')) return `${v}px`;
127
127
  if (helpers.stringStartsWith(propName, 'rotate') || helpers.stringStartsWith(propName, 'skew')) return `${v}deg`;
@@ -134,18 +134,18 @@ const normalizeTweenValue = (propName, value, $el, i, targetsLength) => {
134
134
  * @param {WAAPIKeyframeValue} from
135
135
  * @param {WAAPIKeyframeValue} to
136
136
  * @param {Number} i
137
- * @param {Number} targetsLength
137
+ * @param {DOMTargetsArray} parsedTargets
138
138
  * @return {WAAPITweenValue}
139
139
  */
140
- const parseIndividualTweenValue = ($el, propName, from, to, i, targetsLength) => {
140
+ const parseIndividualTweenValue = ($el, propName, from, to, i, parsedTargets) => {
141
141
  /** @type {WAAPITweenValue} */
142
142
  let tweenValue = '0';
143
- const computedTo = !helpers.isUnd(to) ? normalizeTweenValue(propName, to, $el, i, targetsLength) : getComputedStyle($el)[propName];
143
+ const computedTo = !helpers.isUnd(to) ? normalizeTweenValue(propName, to, $el, i, parsedTargets) : getComputedStyle($el)[propName];
144
144
  if (!helpers.isUnd(from)) {
145
- const computedFrom = normalizeTweenValue(propName, from, $el, i, targetsLength);
145
+ const computedFrom = normalizeTweenValue(propName, from, $el, i, parsedTargets);
146
146
  tweenValue = [computedFrom, computedTo];
147
147
  } else {
148
- tweenValue = helpers.isArr(to) ? to.map((/** @type {any} */v) => normalizeTweenValue(propName, v, $el, i, targetsLength)) : computedTo;
148
+ tweenValue = helpers.isArr(to) ? to.map((/** @type {any} */v) => normalizeTweenValue(propName, v, $el, i, parsedTargets)) : computedTo;
149
149
  }
150
150
  return tweenValue;
151
151
  };
@@ -184,9 +184,8 @@ class WAAPIAnimation {
184
184
  }
185
185
 
186
186
  const parsedTargets = targets.registerTargets(targets$1);
187
- const targetsLength = parsedTargets.length;
188
187
 
189
- if (!targetsLength) {
188
+ if (!parsedTargets.length) {
190
189
  console.warn(`No target found. Make sure the element you're trying to animate is accessible before creating your animation.`);
191
190
  }
192
191
 
@@ -242,7 +241,7 @@ class WAAPIAnimation {
242
241
 
243
242
  const easeToParse = values.setValue(params.ease, globals.globals.defaults.ease);
244
243
 
245
- const easeFunctionResult = values.getFunctionValue(easeToParse, $el, i, targetsLength);
244
+ const easeFunctionResult = values.getFunctionValue(easeToParse, $el, i, parsedTargets, null, null);
246
245
  const keyEasing = helpers.isFnc(easeFunctionResult) || helpers.isStr(easeFunctionResult) ? easeFunctionResult : easeToParse;
247
246
 
248
247
  const spring = /** @type {Spring} */(easeToParse).ease && easeToParse;
@@ -250,9 +249,9 @@ class WAAPIAnimation {
250
249
  const easing = parseWAAPIEasing(keyEasing);
251
250
 
252
251
  /** @type {Number} */
253
- const duration = (spring ? /** @type {Spring} */(spring).settlingDuration : values.getFunctionValue(values.setValue(params.duration, globals.globals.defaults.duration), $el, i, targetsLength)) * timeScale;
252
+ const duration = (spring ? /** @type {Spring} */(spring).settlingDuration : values.getFunctionValue(values.setValue(params.duration, globals.globals.defaults.duration), $el, i, parsedTargets, null, null)) * timeScale;
254
253
  /** @type {Number} */
255
- const delay = values.getFunctionValue(values.setValue(params.delay, globals.globals.defaults.delay), $el, i, targetsLength) * timeScale;
254
+ const delay = values.getFunctionValue(values.setValue(params.delay, globals.globals.defaults.delay), $el, i, parsedTargets, null, null) * timeScale;
256
255
  /** @type {CompositeOperation} */
257
256
  const composite = /** @type {CompositeOperation} */(values.setValue(params.composition, 'replace'));
258
257
 
@@ -278,19 +277,19 @@ class WAAPIAnimation {
278
277
  const to = /** @type {WAAPITweenOptions} */(tweenOptions).to;
279
278
  const from = /** @type {WAAPITweenOptions} */(tweenOptions).from;
280
279
  /** @type {Number} */
281
- tweenParams.duration = (tweenOptionsSpring ? /** @type {Spring} */(tweenOptionsSpring).settlingDuration : values.getFunctionValue(values.setValue(tweenOptions.duration, duration), $el, i, targetsLength)) * timeScale;
280
+ tweenParams.duration = (tweenOptionsSpring ? /** @type {Spring} */(tweenOptionsSpring).settlingDuration : values.getFunctionValue(values.setValue(tweenOptions.duration, duration), $el, i, parsedTargets, null, null)) * timeScale;
282
281
  /** @type {Number} */
283
- tweenParams.delay = values.getFunctionValue(values.setValue(tweenOptions.delay, delay), $el, i, targetsLength) * timeScale;
282
+ tweenParams.delay = values.getFunctionValue(values.setValue(tweenOptions.delay, delay), $el, i, parsedTargets, null, null) * timeScale;
284
283
  /** @type {CompositeOperation} */
285
284
  tweenParams.composite = /** @type {CompositeOperation} */(values.setValue(tweenOptions.composition, composite));
286
285
  /** @type {String} */
287
286
  tweenParams.easing = parseWAAPIEasing(tweenOptionsEase);
288
- parsedPropertyValue = parseIndividualTweenValue($el, name, from, to, i, targetsLength);
287
+ parsedPropertyValue = parseIndividualTweenValue($el, name, from, to, i, parsedTargets);
289
288
  if (individualTransformProperty) {
290
289
  keyframes[`--${individualTransformProperty}`] = parsedPropertyValue;
291
290
  cachedTransforms[individualTransformProperty] = parsedPropertyValue;
292
291
  } else {
293
- keyframes[name] = parseIndividualTweenValue($el, name, from, to, i, targetsLength);
292
+ keyframes[name] = parseIndividualTweenValue($el, name, from, to, i, parsedTargets);
294
293
  }
295
294
  composition.addWAAPIAnimation(this, $el, name, keyframes, tweenParams);
296
295
  if (!helpers.isUnd(from)) {
@@ -303,8 +302,8 @@ class WAAPIAnimation {
303
302
  }
304
303
  } else {
305
304
  parsedPropertyValue = helpers.isArr(propertyValue) ?
306
- propertyValue.map((/** @type {any} */v) => normalizeTweenValue(name, v, $el, i, targetsLength)) :
307
- normalizeTweenValue(name, /** @type {any} */(propertyValue), $el, i, targetsLength);
305
+ propertyValue.map((/** @type {any} */v) => normalizeTweenValue(name, v, $el, i, parsedTargets)) :
306
+ normalizeTweenValue(name, /** @type {any} */(propertyValue), $el, i, parsedTargets);
308
307
  if (individualTransformProperty) {
309
308
  keyframes[`--${individualTransformProperty}`] = parsedPropertyValue;
310
309
  cachedTransforms[individualTransformProperty] = parsedPropertyValue;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - waapi - ESM
3
- * @version v4.3.6
3
+ * @version v4.4.0
4
4
  * @license MIT
5
5
  * @copyright 2026 - Julian Garnier
6
6
  */
@@ -9,7 +9,7 @@ import { isNil, isUnd, stringStartsWith, isKey, isObj, isArr, isStr, toLowerCase
9
9
  import { scope, globals } from '../core/globals.js';
10
10
  import { registerTargets } from '../core/targets.js';
11
11
  import { setValue, getFunctionValue } from '../core/values.js';
12
- import { isBrowser, validTransforms, noop, transformsSymbol, shortTransforms, transformsFragmentStrings, emptyString, K } from '../core/consts.js';
12
+ import { isBrowser, validTransforms, K, noop, transformsSymbol, shortTransforms, transformsFragmentStrings, emptyString } from '../core/consts.js';
13
13
  import { none } from '../easings/none.js';
14
14
  import { parseEaseString } from '../easings/eases/parser.js';
15
15
  import { addWAAPIAnimation } from './composition.js';
@@ -114,12 +114,12 @@ let transformsPropertiesRegistered = null;
114
114
  * @param {WAAPIKeyframeValue} value
115
115
  * @param {DOMTarget} $el
116
116
  * @param {Number} i
117
- * @param {Number} targetsLength
117
+ * @param {DOMTargetsArray} parsedTargets
118
118
  * @return {String}
119
119
  */
120
- const normalizeTweenValue = (propName, value, $el, i, targetsLength) => {
120
+ const normalizeTweenValue = (propName, value, $el, i, parsedTargets) => {
121
121
  // Do not try to compute strings with getFunctionValue otherwise it will convert CSS variables
122
- let v = isStr(value) ? value : getFunctionValue(/** @type {any} */(value), $el, i, targetsLength);
122
+ let v = isStr(value) ? value : getFunctionValue(/** @type {any} */(value), $el, i, parsedTargets, null, null);
123
123
  if (!isNum(v)) return v;
124
124
  if (commonDefaultPXProperties.includes(propName) || stringStartsWith(propName, 'translate')) return `${v}px`;
125
125
  if (stringStartsWith(propName, 'rotate') || stringStartsWith(propName, 'skew')) return `${v}deg`;
@@ -132,18 +132,18 @@ const normalizeTweenValue = (propName, value, $el, i, targetsLength) => {
132
132
  * @param {WAAPIKeyframeValue} from
133
133
  * @param {WAAPIKeyframeValue} to
134
134
  * @param {Number} i
135
- * @param {Number} targetsLength
135
+ * @param {DOMTargetsArray} parsedTargets
136
136
  * @return {WAAPITweenValue}
137
137
  */
138
- const parseIndividualTweenValue = ($el, propName, from, to, i, targetsLength) => {
138
+ const parseIndividualTweenValue = ($el, propName, from, to, i, parsedTargets) => {
139
139
  /** @type {WAAPITweenValue} */
140
140
  let tweenValue = '0';
141
- const computedTo = !isUnd(to) ? normalizeTweenValue(propName, to, $el, i, targetsLength) : getComputedStyle($el)[propName];
141
+ const computedTo = !isUnd(to) ? normalizeTweenValue(propName, to, $el, i, parsedTargets) : getComputedStyle($el)[propName];
142
142
  if (!isUnd(from)) {
143
- const computedFrom = normalizeTweenValue(propName, from, $el, i, targetsLength);
143
+ const computedFrom = normalizeTweenValue(propName, from, $el, i, parsedTargets);
144
144
  tweenValue = [computedFrom, computedTo];
145
145
  } else {
146
- tweenValue = isArr(to) ? to.map((/** @type {any} */v) => normalizeTweenValue(propName, v, $el, i, targetsLength)) : computedTo;
146
+ tweenValue = isArr(to) ? to.map((/** @type {any} */v) => normalizeTweenValue(propName, v, $el, i, parsedTargets)) : computedTo;
147
147
  }
148
148
  return tweenValue;
149
149
  };
@@ -182,9 +182,8 @@ class WAAPIAnimation {
182
182
  }
183
183
 
184
184
  const parsedTargets = registerTargets(targets);
185
- const targetsLength = parsedTargets.length;
186
185
 
187
- if (!targetsLength) {
186
+ if (!parsedTargets.length) {
188
187
  console.warn(`No target found. Make sure the element you're trying to animate is accessible before creating your animation.`);
189
188
  }
190
189
 
@@ -240,7 +239,7 @@ class WAAPIAnimation {
240
239
 
241
240
  const easeToParse = setValue(params.ease, globals.defaults.ease);
242
241
 
243
- const easeFunctionResult = getFunctionValue(easeToParse, $el, i, targetsLength);
242
+ const easeFunctionResult = getFunctionValue(easeToParse, $el, i, parsedTargets, null, null);
244
243
  const keyEasing = isFnc(easeFunctionResult) || isStr(easeFunctionResult) ? easeFunctionResult : easeToParse;
245
244
 
246
245
  const spring = /** @type {Spring} */(easeToParse).ease && easeToParse;
@@ -248,9 +247,9 @@ class WAAPIAnimation {
248
247
  const easing = parseWAAPIEasing(keyEasing);
249
248
 
250
249
  /** @type {Number} */
251
- const duration = (spring ? /** @type {Spring} */(spring).settlingDuration : getFunctionValue(setValue(params.duration, globals.defaults.duration), $el, i, targetsLength)) * timeScale;
250
+ const duration = (spring ? /** @type {Spring} */(spring).settlingDuration : getFunctionValue(setValue(params.duration, globals.defaults.duration), $el, i, parsedTargets, null, null)) * timeScale;
252
251
  /** @type {Number} */
253
- const delay = getFunctionValue(setValue(params.delay, globals.defaults.delay), $el, i, targetsLength) * timeScale;
252
+ const delay = getFunctionValue(setValue(params.delay, globals.defaults.delay), $el, i, parsedTargets, null, null) * timeScale;
254
253
  /** @type {CompositeOperation} */
255
254
  const composite = /** @type {CompositeOperation} */(setValue(params.composition, 'replace'));
256
255
 
@@ -276,19 +275,19 @@ class WAAPIAnimation {
276
275
  const to = /** @type {WAAPITweenOptions} */(tweenOptions).to;
277
276
  const from = /** @type {WAAPITweenOptions} */(tweenOptions).from;
278
277
  /** @type {Number} */
279
- tweenParams.duration = (tweenOptionsSpring ? /** @type {Spring} */(tweenOptionsSpring).settlingDuration : getFunctionValue(setValue(tweenOptions.duration, duration), $el, i, targetsLength)) * timeScale;
278
+ tweenParams.duration = (tweenOptionsSpring ? /** @type {Spring} */(tweenOptionsSpring).settlingDuration : getFunctionValue(setValue(tweenOptions.duration, duration), $el, i, parsedTargets, null, null)) * timeScale;
280
279
  /** @type {Number} */
281
- tweenParams.delay = getFunctionValue(setValue(tweenOptions.delay, delay), $el, i, targetsLength) * timeScale;
280
+ tweenParams.delay = getFunctionValue(setValue(tweenOptions.delay, delay), $el, i, parsedTargets, null, null) * timeScale;
282
281
  /** @type {CompositeOperation} */
283
282
  tweenParams.composite = /** @type {CompositeOperation} */(setValue(tweenOptions.composition, composite));
284
283
  /** @type {String} */
285
284
  tweenParams.easing = parseWAAPIEasing(tweenOptionsEase);
286
- parsedPropertyValue = parseIndividualTweenValue($el, name, from, to, i, targetsLength);
285
+ parsedPropertyValue = parseIndividualTweenValue($el, name, from, to, i, parsedTargets);
287
286
  if (individualTransformProperty) {
288
287
  keyframes[`--${individualTransformProperty}`] = parsedPropertyValue;
289
288
  cachedTransforms[individualTransformProperty] = parsedPropertyValue;
290
289
  } else {
291
- keyframes[name] = parseIndividualTweenValue($el, name, from, to, i, targetsLength);
290
+ keyframes[name] = parseIndividualTweenValue($el, name, from, to, i, parsedTargets);
292
291
  }
293
292
  addWAAPIAnimation(this, $el, name, keyframes, tweenParams);
294
293
  if (!isUnd(from)) {
@@ -301,8 +300,8 @@ class WAAPIAnimation {
301
300
  }
302
301
  } else {
303
302
  parsedPropertyValue = isArr(propertyValue) ?
304
- propertyValue.map((/** @type {any} */v) => normalizeTweenValue(name, v, $el, i, targetsLength)) :
305
- normalizeTweenValue(name, /** @type {any} */(propertyValue), $el, i, targetsLength);
303
+ propertyValue.map((/** @type {any} */v) => normalizeTweenValue(name, v, $el, i, parsedTargets)) :
304
+ normalizeTweenValue(name, /** @type {any} */(propertyValue), $el, i, parsedTargets);
306
305
  if (individualTransformProperty) {
307
306
  keyframes[`--${individualTransformProperty}`] = parsedPropertyValue;
308
307
  cachedTransforms[individualTransformProperty] = parsedPropertyValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "animejs",
3
- "version": "4.3.6",
3
+ "version": "4.4.0",
4
4
  "description": "JavaScript animation engine",
5
5
  "homepage": "https://animejs.com",
6
6
  "author": "Julian Garnier <julian@animejs.com>",
@@ -187,6 +187,7 @@
187
187
  "nodemon": "^3.1.10",
188
188
  "rollup": "^4.9.1",
189
189
  "three": "^0.160.0",
190
+ "tweaks": "^0.3.4",
190
191
  "typescript": "^5.9.2"
191
192
  },
192
193
  "scripts": {