animejs 4.3.6 → 4.4.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 (142) hide show
  1. package/README.md +6 -9
  2. package/dist/bundles/anime.esm.js +973 -391
  3. package/dist/bundles/anime.esm.min.js +2 -2
  4. package/dist/bundles/anime.umd.js +977 -390
  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 +7 -34
  32. package/dist/modules/core/render.js +8 -35
  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,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - utils - CJS
3
- * @version v4.3.6
3
+ * @version v4.4.1
4
4
  * @license MIT
5
5
  * @copyright 2026 - Julian Garnier
6
6
  */
@@ -19,6 +19,7 @@ var random = require('./random.cjs');
19
19
  * @import {
20
20
  * StaggerParams,
21
21
  * StaggerFunction,
22
+ * JSTarget,
22
23
  * } from '../types/index.js'
23
24
  */
24
25
 
@@ -34,24 +35,28 @@ var random = require('./random.cjs');
34
35
  * @param {StaggerParams} [params]
35
36
  * @return {StaggerFunction<Number>}
36
37
  */
38
+
37
39
  /**
38
40
  * @overload
39
41
  * @param {String} val
40
42
  * @param {StaggerParams} [params]
41
43
  * @return {StaggerFunction<String>}
42
44
  */
45
+
43
46
  /**
44
47
  * @overload
45
48
  * @param {[Number, Number]} val
46
49
  * @param {StaggerParams} [params]
47
50
  * @return {StaggerFunction<Number>}
48
51
  */
52
+
49
53
  /**
50
54
  * @overload
51
55
  * @param {[String, String]} val
52
56
  * @param {StaggerParams} [params]
53
57
  * @return {StaggerFunction<String>}
54
58
  */
59
+
55
60
  /**
56
61
  * @param {Number|String|[Number, Number]|[String, String]} val The staggered value or range
57
62
  * @param {StaggerParams} [params] The stagger parameters
@@ -60,6 +65,7 @@ var random = require('./random.cjs');
60
65
  const stagger = (val, params = {}) => {
61
66
  let values$1 = [];
62
67
  let maxValue = 0;
68
+ let cachedOffset;
63
69
  const from = params.from;
64
70
  const reversed = params.reversed;
65
71
  const ease = params.ease;
@@ -67,12 +73,14 @@ const stagger = (val, params = {}) => {
67
73
  const hasSpring = hasEasing && !helpers.isUnd(/** @type {Spring} */(ease).ease);
68
74
  const staggerEase = hasSpring ? /** @type {Spring} */(ease).ease : hasEasing ? parser.parseEase(ease) : null;
69
75
  const grid = params.grid;
76
+ const autoGrid = grid === true;
70
77
  const axis = params.axis;
71
78
  const customTotal = params.total;
72
79
  const fromFirst = helpers.isUnd(from) || from === 0 || from === 'first';
73
80
  const fromCenter = from === 'center';
74
81
  const fromLast = from === 'last';
75
82
  const fromRandom = from === 'random';
83
+ const fromArr = helpers.isArr(from);
76
84
  const isRange = helpers.isArr(val);
77
85
  const useProp = params.use;
78
86
  const val1 = isRange ? helpers.parseNumber(val[0]) : helpers.parseNumber(val);
@@ -80,40 +88,129 @@ const stagger = (val, params = {}) => {
80
88
  const unitMatch = consts.unitsExecRgx.exec((isRange ? val[1] : val) + consts.emptyString);
81
89
  const start = params.start || 0 + (isRange ? val1 : 0);
82
90
  let fromIndex = fromFirst ? 0 : helpers.isNum(from) ? from : 0;
83
- return (target, i, t, tl) => {
91
+ return (target, i, t, _, tl) => {
84
92
  const [ registeredTarget ] = targets.registerTargets(target);
85
- const total = helpers.isUnd(customTotal) ? t : customTotal;
93
+ const total = helpers.isUnd(customTotal) ? t.length : customTotal;
86
94
  const customIndex = !helpers.isUnd(useProp) ? helpers.isFnc(useProp) ? useProp(registeredTarget, i, total) : values.getOriginalAnimatableValue(registeredTarget, useProp) : false;
87
95
  const staggerIndex = helpers.isNum(customIndex) || helpers.isStr(customIndex) && helpers.isNum(+customIndex) ? +customIndex : i;
88
96
  if (fromCenter) fromIndex = (total - 1) / 2;
89
97
  if (fromLast) fromIndex = total - 1;
90
98
  if (!values$1.length) {
91
- for (let index = 0; index < total; index++) {
92
- if (!grid) {
93
- values$1.push(helpers.abs(fromIndex - index));
99
+ if (autoGrid) {
100
+ let hasPositions = true;
101
+ let minPosX = Infinity;
102
+ let minPosY = Infinity;
103
+ let maxPosX = -Infinity;
104
+ let maxPosY = -Infinity;
105
+ const pxArr = [];
106
+ const pyArr = [];
107
+ for (let index = 0; index < total; index++) {
108
+ const el = t[index];
109
+ let px = 0;
110
+ let py = 0;
111
+ let found = false;
112
+ if (el && helpers.isFnc(el.getBoundingClientRect)) {
113
+ const rect = el.getBoundingClientRect();
114
+ px = rect.left + rect.width / 2;
115
+ py = rect.top + rect.height / 2;
116
+ found = true;
117
+ } else {
118
+ const obj = /** @type {JSTarget} */(el);
119
+ if (obj && helpers.isNum(obj.x) && helpers.isNum(obj.y)) {
120
+ px = obj.x;
121
+ py = obj.y;
122
+ found = true;
123
+ }
124
+ }
125
+ if (!found) {
126
+ hasPositions = false;
127
+ break;
128
+ }
129
+ pxArr.push(px);
130
+ pyArr.push(py);
131
+ if (px < minPosX) minPosX = px;
132
+ if (py < minPosY) minPosY = py;
133
+ if (px > maxPosX) maxPosX = px;
134
+ if (py > maxPosY) maxPosY = py;
135
+ }
136
+ if (hasPositions) {
137
+ let fX = pxArr[0];
138
+ let fY = pyArr[0];
139
+ if (fromArr) {
140
+ fX = minPosX + from[0] * (maxPosX - minPosX);
141
+ fY = minPosY + from[1] * (maxPosY - minPosY);
142
+ } else if (fromCenter) {
143
+ fX = (minPosX + maxPosX) / 2;
144
+ fY = (minPosY + maxPosY) / 2;
145
+ } else if (fromLast) {
146
+ fX = pxArr[total - 1];
147
+ fY = pyArr[total - 1];
148
+ } else if (helpers.isNum(from)) {
149
+ fX = pxArr[from];
150
+ fY = pyArr[from];
151
+ }
152
+ for (let index = 0; index < total; index++) {
153
+ const distanceX = fX - pxArr[index];
154
+ const distanceY = fY - pyArr[index];
155
+ let value = helpers.sqrt(distanceX * distanceX + distanceY * distanceY);
156
+ if (axis === 'x') value = -distanceX;
157
+ if (axis === 'y') value = -distanceY;
158
+ values$1.push(value);
159
+ }
160
+ let minDist = Infinity;
161
+ for (let index = 0, l = values$1.length; index < l; index++) {
162
+ const absVal = helpers.abs(values$1[index]);
163
+ if (absVal > 0 && absVal < minDist) minDist = absVal;
164
+ }
165
+ if (minDist > 0 && minDist < Infinity) {
166
+ for (let index = 0, l = values$1.length; index < l; index++) {
167
+ values$1[index] = values$1[index] / minDist;
168
+ }
169
+ }
94
170
  } else {
95
- const fromX = !fromCenter ? fromIndex % grid[0] : (grid[0] - 1) / 2;
96
- const fromY = !fromCenter ? helpers.floor(fromIndex / grid[0]) : (grid[1] - 1) / 2;
97
- const toX = index % grid[0];
98
- const toY = helpers.floor(index / grid[0]);
99
- const distanceX = fromX - toX;
100
- const distanceY = fromY - toY;
101
- let value = helpers.sqrt(distanceX * distanceX + distanceY * distanceY);
102
- if (axis === 'x') value = -distanceX;
103
- if (axis === 'y') value = -distanceY;
104
- values$1.push(value);
171
+ for (let index = 0; index < total; index++) {
172
+ values$1.push(helpers.abs(fromIndex - index));
173
+ }
174
+ }
175
+ } else {
176
+ for (let index = 0; index < total; index++) {
177
+ if (!grid) {
178
+ values$1.push(helpers.abs(fromIndex - index));
179
+ } else {
180
+ let fromX, fromY;
181
+ if (fromArr) {
182
+ fromX = from[0] * (grid[0] - 1);
183
+ fromY = from[1] * (grid[1] - 1);
184
+ } else if (fromCenter) {
185
+ fromX = (grid[0] - 1) / 2;
186
+ fromY = (grid[1] - 1) / 2;
187
+ } else {
188
+ fromX = fromIndex % grid[0];
189
+ fromY = helpers.floor(fromIndex / grid[0]);
190
+ }
191
+ const toX = index % grid[0];
192
+ const toY = helpers.floor(index / grid[0]);
193
+ const distanceX = fromX - toX;
194
+ const distanceY = fromY - toY;
195
+ let value = helpers.sqrt(distanceX * distanceX + distanceY * distanceY);
196
+ if (axis === 'x') value = -distanceX;
197
+ if (axis === 'y') value = -distanceY;
198
+ values$1.push(value);
199
+ }
105
200
  }
106
- maxValue = helpers.max(...values$1);
107
201
  }
202
+ maxValue = helpers.max(...values$1);
108
203
  if (staggerEase) values$1 = values$1.map(val => staggerEase(val / maxValue) * maxValue);
109
204
  if (reversed) values$1 = values$1.map(val => axis ? (val < 0) ? val * -1 : -val : helpers.abs(maxValue - val));
110
205
  if (fromRandom) values$1 = random.shuffle(values$1);
111
206
  }
112
207
  const spacing = isRange ? (val2 - val1) / maxValue : val1;
113
- const offset = tl ? position.parseTimelinePosition(tl, helpers.isUnd(params.start) ? tl.iterationDuration : start) : /** @type {Number} */(start);
208
+ if (helpers.isUnd(cachedOffset)) {
209
+ cachedOffset = tl ? position.parseTimelinePosition(tl, helpers.isUnd(params.start) ? tl.iterationDuration : start) : /** @type {Number} */(start);
210
+ }
114
211
  /** @type {String|Number} */
115
- let output = offset + ((spacing * helpers.round(values$1[staggerIndex], 2)) || 0);
116
- if (params.modifier) output = params.modifier(output);
212
+ let output = cachedOffset + ((spacing * helpers.round(values$1[staggerIndex], 2)) || 0);
213
+ if (params.modifier) output = params.modifier(/** @type {Number} */(output));
117
214
  if (unitMatch) output = `${output}${unitMatch[2]}`;
118
215
  return output;
119
216
  }
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * Anime.js - utils - ESM
3
- * @version v4.3.6
3
+ * @version v4.4.1
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.1
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.1
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.1
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.1
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.1
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.1
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.1
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.1
4
4
  * @license MIT
5
5
  * @copyright 2026 - Julian Garnier
6
6
  */