animejs 4.1.2 → 4.2.0-beta.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 (191) hide show
  1. package/README.md +18 -8
  2. package/{lib → dist/bundles}/anime.esm.js +6549 -6265
  3. package/dist/bundles/anime.esm.min.js +7 -0
  4. package/dist/bundles/anime.umd.js +8621 -0
  5. package/dist/bundles/anime.umd.min.js +7 -0
  6. package/dist/modules/animatable/animatable.cjs +150 -0
  7. package/dist/modules/animatable/animatable.d.ts +28 -0
  8. package/dist/modules/animatable/animatable.js +147 -0
  9. package/dist/modules/animatable/index.cjs +15 -0
  10. package/dist/modules/animatable/index.d.ts +1 -0
  11. package/dist/modules/animatable/index.js +8 -0
  12. package/dist/modules/animation/additive.cjs +82 -0
  13. package/dist/modules/animation/additive.d.ts +15 -0
  14. package/dist/modules/animation/additive.js +79 -0
  15. package/dist/modules/animation/animation.cjs +660 -0
  16. package/dist/modules/animation/animation.d.ts +47 -0
  17. package/dist/modules/animation/animation.js +657 -0
  18. package/dist/modules/animation/composition.cjs +383 -0
  19. package/dist/modules/animation/composition.d.ts +10 -0
  20. package/dist/modules/animation/composition.js +377 -0
  21. package/dist/modules/animation/index.cjs +15 -0
  22. package/dist/modules/animation/index.d.ts +1 -0
  23. package/dist/modules/animation/index.js +8 -0
  24. package/dist/modules/core/clock.cjs +110 -0
  25. package/dist/modules/core/clock.d.ts +51 -0
  26. package/dist/modules/core/clock.js +108 -0
  27. package/dist/modules/core/colors.cjs +102 -0
  28. package/dist/modules/core/colors.d.ts +2 -0
  29. package/dist/modules/core/colors.js +100 -0
  30. package/dist/modules/core/consts.cjs +154 -0
  31. package/dist/modules/core/consts.d.ts +59 -0
  32. package/dist/modules/core/consts.js +121 -0
  33. package/dist/modules/core/globals.cjs +77 -0
  34. package/dist/modules/core/globals.d.ts +29 -0
  35. package/dist/modules/core/globals.js +72 -0
  36. package/dist/modules/core/helpers.cjs +304 -0
  37. package/dist/modules/core/helpers.d.ts +43 -0
  38. package/dist/modules/core/helpers.js +261 -0
  39. package/dist/modules/core/render.cjs +389 -0
  40. package/dist/modules/core/render.d.ts +4 -0
  41. package/dist/modules/core/render.js +386 -0
  42. package/dist/modules/core/styles.cjs +116 -0
  43. package/dist/modules/core/styles.d.ts +5 -0
  44. package/dist/modules/core/styles.js +113 -0
  45. package/dist/modules/core/targets.cjs +136 -0
  46. package/dist/modules/core/targets.d.ts +118 -0
  47. package/dist/modules/core/targets.js +132 -0
  48. package/dist/modules/core/transforms.cjs +49 -0
  49. package/dist/modules/core/transforms.d.ts +2 -0
  50. package/dist/modules/core/transforms.js +47 -0
  51. package/dist/modules/core/units.cjs +67 -0
  52. package/dist/modules/core/units.d.ts +3 -0
  53. package/dist/modules/core/units.js +65 -0
  54. package/dist/modules/core/values.cjs +215 -0
  55. package/dist/modules/core/values.d.ts +14 -0
  56. package/dist/modules/core/values.js +205 -0
  57. package/dist/modules/draggable/draggable.cjs +1226 -0
  58. package/dist/modules/draggable/draggable.d.ts +272 -0
  59. package/dist/modules/draggable/draggable.js +1223 -0
  60. package/dist/modules/draggable/index.cjs +15 -0
  61. package/dist/modules/draggable/index.d.ts +1 -0
  62. package/dist/modules/draggable/index.js +8 -0
  63. package/dist/modules/easings/cubic-bezier.cjs +64 -0
  64. package/dist/modules/easings/cubic-bezier.d.ts +2 -0
  65. package/dist/modules/easings/cubic-bezier.js +62 -0
  66. package/dist/modules/easings/eases.cjs +149 -0
  67. package/dist/modules/easings/eases.d.ts +111 -0
  68. package/dist/modules/easings/eases.js +146 -0
  69. package/dist/modules/easings/index.cjs +24 -0
  70. package/dist/modules/easings/index.d.ts +6 -0
  71. package/dist/modules/easings/index.js +13 -0
  72. package/dist/modules/easings/irregular.cjs +41 -0
  73. package/dist/modules/easings/irregular.d.ts +2 -0
  74. package/dist/modules/easings/irregular.js +39 -0
  75. package/dist/modules/easings/linear.cjs +59 -0
  76. package/dist/modules/easings/linear.d.ts +2 -0
  77. package/dist/modules/easings/linear.js +57 -0
  78. package/dist/modules/easings/none.cjs +19 -0
  79. package/dist/modules/easings/none.d.ts +8 -0
  80. package/dist/modules/easings/none.js +17 -0
  81. package/dist/modules/easings/parser.cjs +59 -0
  82. package/dist/modules/easings/parser.d.ts +21 -0
  83. package/dist/modules/easings/parser.js +55 -0
  84. package/dist/modules/easings/steps.cjs +30 -0
  85. package/dist/modules/easings/steps.d.ts +2 -0
  86. package/dist/modules/easings/steps.js +28 -0
  87. package/dist/modules/engine/engine.cjs +168 -0
  88. package/dist/modules/engine/engine.d.ts +21 -0
  89. package/dist/modules/engine/engine.js +166 -0
  90. package/dist/modules/engine/index.cjs +14 -0
  91. package/dist/modules/engine/index.d.ts +1 -0
  92. package/dist/modules/engine/index.js +8 -0
  93. package/dist/modules/events/index.cjs +16 -0
  94. package/dist/modules/events/index.d.ts +1 -0
  95. package/dist/modules/events/index.js +8 -0
  96. package/dist/modules/events/scroll.cjs +936 -0
  97. package/dist/modules/events/scroll.d.ts +189 -0
  98. package/dist/modules/events/scroll.js +932 -0
  99. package/dist/modules/index.cjs +103 -0
  100. package/dist/modules/index.d.ts +19 -0
  101. package/dist/modules/index.js +42 -0
  102. package/dist/modules/scope/index.cjs +15 -0
  103. package/dist/modules/scope/index.d.ts +1 -0
  104. package/dist/modules/scope/index.js +8 -0
  105. package/dist/modules/scope/scope.cjs +254 -0
  106. package/dist/modules/scope/scope.d.ts +115 -0
  107. package/dist/modules/scope/scope.js +251 -0
  108. package/dist/modules/spring/index.cjs +15 -0
  109. package/dist/modules/spring/index.d.ts +1 -0
  110. package/dist/modules/spring/index.js +8 -0
  111. package/dist/modules/spring/spring.cjs +133 -0
  112. package/dist/modules/spring/spring.d.ts +37 -0
  113. package/dist/modules/spring/spring.js +130 -0
  114. package/dist/modules/svg/drawable.cjs +119 -0
  115. package/dist/modules/svg/drawable.d.ts +3 -0
  116. package/dist/modules/svg/drawable.js +117 -0
  117. package/dist/modules/svg/helpers.cjs +30 -0
  118. package/dist/modules/svg/helpers.d.ts +2 -0
  119. package/dist/modules/svg/helpers.js +28 -0
  120. package/dist/modules/svg/index.cjs +18 -0
  121. package/dist/modules/svg/index.d.ts +3 -0
  122. package/dist/modules/svg/index.js +10 -0
  123. package/dist/modules/svg/morphto.cjs +58 -0
  124. package/dist/modules/svg/morphto.d.ts +3 -0
  125. package/dist/modules/svg/morphto.js +56 -0
  126. package/dist/modules/svg/motionpath.cjs +79 -0
  127. package/dist/modules/svg/motionpath.d.ts +7 -0
  128. package/dist/modules/svg/motionpath.js +77 -0
  129. package/dist/modules/text/index.cjs +16 -0
  130. package/dist/modules/text/index.d.ts +1 -0
  131. package/dist/modules/text/index.js +8 -0
  132. package/dist/modules/text/split.cjs +488 -0
  133. package/dist/modules/text/split.d.ts +62 -0
  134. package/dist/modules/text/split.js +484 -0
  135. package/dist/modules/timeline/index.cjs +15 -0
  136. package/dist/modules/timeline/index.d.ts +1 -0
  137. package/dist/modules/timeline/index.js +8 -0
  138. package/dist/modules/timeline/position.cjs +72 -0
  139. package/dist/modules/timeline/position.d.ts +3 -0
  140. package/dist/modules/timeline/position.js +70 -0
  141. package/dist/modules/timeline/timeline.cjs +312 -0
  142. package/dist/modules/timeline/timeline.d.ts +163 -0
  143. package/dist/modules/timeline/timeline.js +309 -0
  144. package/dist/modules/timer/index.cjs +15 -0
  145. package/dist/modules/timer/index.d.ts +1 -0
  146. package/dist/modules/timer/index.js +8 -0
  147. package/dist/modules/timer/timer.cjs +491 -0
  148. package/dist/modules/timer/timer.d.ts +141 -0
  149. package/dist/modules/timer/timer.js +488 -0
  150. package/dist/modules/types/index.d.ts +387 -0
  151. package/dist/modules/utils/chainable.cjs +190 -0
  152. package/dist/modules/utils/chainable.d.ts +135 -0
  153. package/dist/modules/utils/chainable.js +177 -0
  154. package/dist/modules/utils/index.cjs +43 -0
  155. package/dist/modules/utils/index.d.ts +5 -0
  156. package/dist/modules/utils/index.js +14 -0
  157. package/dist/modules/utils/number.cjs +97 -0
  158. package/dist/modules/utils/number.d.ts +9 -0
  159. package/dist/modules/utils/number.js +85 -0
  160. package/dist/modules/utils/random.cjs +77 -0
  161. package/dist/modules/utils/random.d.ts +22 -0
  162. package/dist/modules/utils/random.js +72 -0
  163. package/dist/modules/utils/stagger.cjs +122 -0
  164. package/dist/modules/utils/stagger.d.ts +30 -0
  165. package/dist/modules/utils/stagger.js +120 -0
  166. package/dist/modules/utils/target.cjs +130 -0
  167. package/dist/modules/utils/target.d.ts +126 -0
  168. package/dist/modules/utils/target.js +125 -0
  169. package/dist/modules/utils/time.cjs +57 -0
  170. package/dist/modules/utils/time.d.ts +5 -0
  171. package/dist/modules/utils/time.js +54 -0
  172. package/dist/modules/waapi/composition.cjs +89 -0
  173. package/dist/modules/waapi/composition.d.ts +4 -0
  174. package/dist/modules/waapi/composition.js +86 -0
  175. package/dist/modules/waapi/index.cjs +15 -0
  176. package/dist/modules/waapi/index.d.ts +1 -0
  177. package/dist/modules/waapi/index.js +8 -0
  178. package/dist/modules/waapi/waapi.cjs +473 -0
  179. package/dist/modules/waapi/waapi.d.ts +114 -0
  180. package/dist/modules/waapi/waapi.js +470 -0
  181. package/package.json +130 -33
  182. package/lib/anime.cjs +0 -9
  183. package/lib/anime.esm.min.js +0 -9
  184. package/lib/anime.iife.js +0 -9
  185. package/lib/anime.iife.min.js +0 -9
  186. package/lib/anime.min.cjs +0 -9
  187. package/lib/anime.umd.js +0 -9
  188. package/lib/anime.umd.min.js +0 -9
  189. package/lib/gui/index.js +0 -6341
  190. package/types/index.d.ts +0 -1081
  191. package/types/index.js +0 -7407
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Anime.js - utils - ESM
3
+ * @version v4.2.0
4
+ * @license MIT
5
+ * @copyright 2025 - Julian Garnier
6
+ */
7
+
8
+ /**
9
+ * Generate a random number between optional min and max (inclusive) and decimal precision
10
+ *
11
+ * @callback RandomNumberGenerator
12
+ * @param {Number} [min=0] - The minimum value (inclusive)
13
+ * @param {Number} [max=1] - The maximum value (inclusive)
14
+ * @param {Number} [decimalLength=0] - Number of decimal places to round to
15
+ * @return {Number} A random number between min and max
16
+ */
17
+
18
+ /**
19
+ * Generates a random number between min and max (inclusive) with optional decimal precision
20
+ *
21
+ * @type {RandomNumberGenerator}
22
+ */
23
+ const random = (min = 0, max = 1, decimalLength = 0) => {
24
+ const m = 10 ** decimalLength;
25
+ return Math.floor((Math.random() * (max - min + (1 / m)) + min) * m) / m;
26
+ };
27
+
28
+ let _seed = 0;
29
+
30
+ /**
31
+ * Creates a seeded pseudorandom number generator function
32
+ *
33
+ * @param {Number} [seed] - The seed value for the random number generator
34
+ * @param {Number} [seededMin=0] - The minimum default value (inclusive) of the returned function
35
+ * @param {Number} [seededMax=1] - The maximum default value (inclusive) of the returned function
36
+ * @param {Number} [seededDecimalLength=0] - Default number of decimal places to round to of the returned function
37
+ * @return {RandomNumberGenerator} A function to generate a random number between optional min and max (inclusive) and decimal precision
38
+ */
39
+ const createSeededRandom = (seed, seededMin = 0, seededMax = 1, seededDecimalLength = 0) => {
40
+ let t = seed === undefined ? _seed++ : seed;
41
+ return (min = seededMin, max = seededMax, decimalLength = seededDecimalLength) => {
42
+ t += 0x6D2B79F5;
43
+ t = Math.imul(t ^ t >>> 15, t | 1);
44
+ t ^= t + Math.imul(t ^ t >>> 7, t | 61);
45
+ const m = 10 ** decimalLength;
46
+ return Math.floor(((((t ^ t >>> 14) >>> 0) / 4294967296) * (max - min + (1 / m)) + min) * m) / m;
47
+ }
48
+ };
49
+
50
+ /**
51
+ * Picks a random element from an array or a string
52
+ *
53
+ * @template T
54
+ * @param {String|Array<T>} items - The array or string to pick from
55
+ * @return {String|T} A random element from the array or character from the string
56
+ */
57
+ const randomPick = items => items[random(0, items.length - 1)];
58
+
59
+ /**
60
+ * Shuffles an array in-place using the Fisher-Yates algorithm
61
+ * Adapted from https://bost.ocks.org/mike/shuffle/
62
+ *
63
+ * @param {Array} items - The array to shuffle (will be modified in-place)
64
+ * @return {Array} The same array reference, now shuffled
65
+ */
66
+ const shuffle = items => {
67
+ let m = items.length, t, i;
68
+ while (m) { i = random(0, --m); t = items[m]; items[m] = items[i]; items[i] = t; }
69
+ return items;
70
+ };
71
+
72
+ export { createSeededRandom, random, randomPick, shuffle };
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Anime.js - utils - CJS
3
+ * @version v4.2.0
4
+ * @license MIT
5
+ * @copyright 2025 - Julian Garnier
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ var consts = require('../core/consts.cjs');
11
+ var helpers = require('../core/helpers.cjs');
12
+ var eases = require('../easings/eases.cjs');
13
+ var position = require('../timeline/position.cjs');
14
+ var values = require('../core/values.cjs');
15
+ var targets = require('../core/targets.cjs');
16
+ var random = require('./random.cjs');
17
+
18
+ /**
19
+ * @import {
20
+ * StaggerParams,
21
+ * StaggerFunction,
22
+ * } from '../types/index.js'
23
+ */
24
+
25
+ /**
26
+ * @import {
27
+ * Spring,
28
+ * } from '../spring/spring.js'
29
+ */
30
+
31
+ /**
32
+ * @overload
33
+ * @param {Number} val
34
+ * @param {StaggerParams} [params]
35
+ * @return {StaggerFunction<Number>}
36
+ */
37
+ /**
38
+ * @overload
39
+ * @param {String} val
40
+ * @param {StaggerParams} [params]
41
+ * @return {StaggerFunction<String>}
42
+ */
43
+ /**
44
+ * @overload
45
+ * @param {[Number, Number]} val
46
+ * @param {StaggerParams} [params]
47
+ * @return {StaggerFunction<Number>}
48
+ */
49
+ /**
50
+ * @overload
51
+ * @param {[String, String]} val
52
+ * @param {StaggerParams} [params]
53
+ * @return {StaggerFunction<String>}
54
+ */
55
+ /**
56
+ * @param {Number|String|[Number, Number]|[String, String]} val The staggered value or range
57
+ * @param {StaggerParams} [params] The stagger parameters
58
+ * @return {StaggerFunction<Number|String>}
59
+ */
60
+ const stagger = (val, params = {}) => {
61
+ let values$1 = [];
62
+ let maxValue = 0;
63
+ const from = params.from;
64
+ const reversed = params.reversed;
65
+ const ease = params.ease;
66
+ const hasEasing = !helpers.isUnd(ease);
67
+ const hasSpring = hasEasing && !helpers.isUnd(/** @type {Spring} */(ease).ease);
68
+ const staggerEase = hasSpring ? /** @type {Spring} */(ease).ease : hasEasing ? eases.parseEase(ease) : null;
69
+ const grid = params.grid;
70
+ const axis = params.axis;
71
+ const customTotal = params.total;
72
+ const fromFirst = helpers.isUnd(from) || from === 0 || from === 'first';
73
+ const fromCenter = from === 'center';
74
+ const fromLast = from === 'last';
75
+ const fromRandom = from === 'random';
76
+ const isRange = helpers.isArr(val);
77
+ const useProp = params.use;
78
+ const val1 = isRange ? helpers.parseNumber(val[0]) : helpers.parseNumber(val);
79
+ const val2 = isRange ? helpers.parseNumber(val[1]) : 0;
80
+ const unitMatch = consts.unitsExecRgx.exec((isRange ? val[1] : val) + consts.emptyString);
81
+ const start = params.start || 0 + (isRange ? val1 : 0);
82
+ let fromIndex = fromFirst ? 0 : helpers.isNum(from) ? from : 0;
83
+ return (target, i, t, tl) => {
84
+ const [ registeredTarget ] = targets.registerTargets(target);
85
+ const total = helpers.isUnd(customTotal) ? t : customTotal;
86
+ const customIndex = !helpers.isUnd(useProp) ? helpers.isFnc(useProp) ? useProp(registeredTarget, i, total) : values.getOriginalAnimatableValue(registeredTarget, useProp) : false;
87
+ const staggerIndex = helpers.isNum(customIndex) || helpers.isStr(customIndex) && helpers.isNum(+customIndex) ? +customIndex : i;
88
+ if (fromCenter) fromIndex = (total - 1) / 2;
89
+ if (fromLast) fromIndex = total - 1;
90
+ if (!values$1.length) {
91
+ for (let index = 0; index < total; index++) {
92
+ if (!grid) {
93
+ values$1.push(helpers.abs(fromIndex - index));
94
+ } 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);
105
+ }
106
+ maxValue = helpers.max(...values$1);
107
+ }
108
+ if (staggerEase) values$1 = values$1.map(val => staggerEase(val / maxValue) * maxValue);
109
+ if (reversed) values$1 = values$1.map(val => axis ? (val < 0) ? val * -1 : -val : helpers.abs(maxValue - val));
110
+ if (fromRandom) values$1 = random.shuffle(values$1);
111
+ }
112
+ const spacing = isRange ? (val2 - val1) / maxValue : val1;
113
+ const offset = tl ? position.parseTimelinePosition(tl, helpers.isUnd(params.start) ? tl.iterationDuration : start) : /** @type {Number} */(start);
114
+ /** @type {String|Number} */
115
+ let output = offset + ((spacing * helpers.round(values$1[staggerIndex], 2)) || 0);
116
+ if (params.modifier) output = params.modifier(output);
117
+ if (unitMatch) output = `${output}${unitMatch[2]}`;
118
+ return output;
119
+ }
120
+ };
121
+
122
+ exports.stagger = stagger;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @overload
3
+ * @param {Number} val
4
+ * @param {StaggerParams} [params]
5
+ * @return {StaggerFunction<Number>}
6
+ */
7
+ export function stagger(val: number, params?: StaggerParams): StaggerFunction<number>;
8
+ /**
9
+ * @overload
10
+ * @param {String} val
11
+ * @param {StaggerParams} [params]
12
+ * @return {StaggerFunction<String>}
13
+ */
14
+ export function stagger(val: string, params?: StaggerParams): StaggerFunction<string>;
15
+ /**
16
+ * @overload
17
+ * @param {[Number, Number]} val
18
+ * @param {StaggerParams} [params]
19
+ * @return {StaggerFunction<Number>}
20
+ */
21
+ export function stagger(val: [number, number], params?: StaggerParams): StaggerFunction<number>;
22
+ /**
23
+ * @overload
24
+ * @param {[String, String]} val
25
+ * @param {StaggerParams} [params]
26
+ * @return {StaggerFunction<String>}
27
+ */
28
+ export function stagger(val: [string, string], params?: StaggerParams): StaggerFunction<string>;
29
+ import type { StaggerParams } from '../types/index.js';
30
+ import type { StaggerFunction } from '../types/index.js';
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Anime.js - utils - ESM
3
+ * @version v4.2.0
4
+ * @license MIT
5
+ * @copyright 2025 - Julian Garnier
6
+ */
7
+
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';
10
+ import { parseEase } from '../easings/eases.js';
11
+ import { parseTimelinePosition } from '../timeline/position.js';
12
+ import { getOriginalAnimatableValue } from '../core/values.js';
13
+ import { registerTargets } from '../core/targets.js';
14
+ import { shuffle } from './random.js';
15
+
16
+ /**
17
+ * @import {
18
+ * StaggerParams,
19
+ * StaggerFunction,
20
+ * } from '../types/index.js'
21
+ */
22
+
23
+ /**
24
+ * @import {
25
+ * Spring,
26
+ * } from '../spring/spring.js'
27
+ */
28
+
29
+ /**
30
+ * @overload
31
+ * @param {Number} val
32
+ * @param {StaggerParams} [params]
33
+ * @return {StaggerFunction<Number>}
34
+ */
35
+ /**
36
+ * @overload
37
+ * @param {String} val
38
+ * @param {StaggerParams} [params]
39
+ * @return {StaggerFunction<String>}
40
+ */
41
+ /**
42
+ * @overload
43
+ * @param {[Number, Number]} val
44
+ * @param {StaggerParams} [params]
45
+ * @return {StaggerFunction<Number>}
46
+ */
47
+ /**
48
+ * @overload
49
+ * @param {[String, String]} val
50
+ * @param {StaggerParams} [params]
51
+ * @return {StaggerFunction<String>}
52
+ */
53
+ /**
54
+ * @param {Number|String|[Number, Number]|[String, String]} val The staggered value or range
55
+ * @param {StaggerParams} [params] The stagger parameters
56
+ * @return {StaggerFunction<Number|String>}
57
+ */
58
+ const stagger = (val, params = {}) => {
59
+ let values = [];
60
+ let maxValue = 0;
61
+ const from = params.from;
62
+ const reversed = params.reversed;
63
+ const ease = params.ease;
64
+ const hasEasing = !isUnd(ease);
65
+ const hasSpring = hasEasing && !isUnd(/** @type {Spring} */(ease).ease);
66
+ const staggerEase = hasSpring ? /** @type {Spring} */(ease).ease : hasEasing ? parseEase(ease) : null;
67
+ const grid = params.grid;
68
+ const axis = params.axis;
69
+ const customTotal = params.total;
70
+ const fromFirst = isUnd(from) || from === 0 || from === 'first';
71
+ const fromCenter = from === 'center';
72
+ const fromLast = from === 'last';
73
+ const fromRandom = from === 'random';
74
+ const isRange = isArr(val);
75
+ const useProp = params.use;
76
+ const val1 = isRange ? parseNumber(val[0]) : parseNumber(val);
77
+ const val2 = isRange ? parseNumber(val[1]) : 0;
78
+ const unitMatch = unitsExecRgx.exec((isRange ? val[1] : val) + emptyString);
79
+ const start = params.start || 0 + (isRange ? val1 : 0);
80
+ let fromIndex = fromFirst ? 0 : isNum(from) ? from : 0;
81
+ return (target, i, t, tl) => {
82
+ const [ registeredTarget ] = registerTargets(target);
83
+ const total = isUnd(customTotal) ? t : customTotal;
84
+ const customIndex = !isUnd(useProp) ? isFnc(useProp) ? useProp(registeredTarget, i, total) : getOriginalAnimatableValue(registeredTarget, useProp) : false;
85
+ const staggerIndex = isNum(customIndex) || isStr(customIndex) && isNum(+customIndex) ? +customIndex : i;
86
+ if (fromCenter) fromIndex = (total - 1) / 2;
87
+ if (fromLast) fromIndex = total - 1;
88
+ if (!values.length) {
89
+ for (let index = 0; index < total; index++) {
90
+ if (!grid) {
91
+ values.push(abs(fromIndex - index));
92
+ } 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);
103
+ }
104
+ maxValue = max(...values);
105
+ }
106
+ if (staggerEase) values = values.map(val => staggerEase(val / maxValue) * maxValue);
107
+ if (reversed) values = values.map(val => axis ? (val < 0) ? val * -1 : -val : abs(maxValue - val));
108
+ if (fromRandom) values = shuffle(values);
109
+ }
110
+ const spacing = isRange ? (val2 - val1) / maxValue : val1;
111
+ const offset = tl ? parseTimelinePosition(tl, isUnd(params.start) ? tl.iterationDuration : start) : /** @type {Number} */(start);
112
+ /** @type {String|Number} */
113
+ let output = offset + ((spacing * round(values[staggerIndex], 2)) || 0);
114
+ if (params.modifier) output = params.modifier(output);
115
+ if (unitMatch) output = `${output}${unitMatch[2]}`;
116
+ return output;
117
+ }
118
+ };
119
+
120
+ export { stagger };
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Anime.js - utils - CJS
3
+ * @version v4.2.0
4
+ * @license MIT
5
+ * @copyright 2025 - Julian Garnier
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ var globals = require('../core/globals.cjs');
11
+ var consts = require('../core/consts.cjs');
12
+ var helpers = require('../core/helpers.cjs');
13
+ var targets = require('../core/targets.cjs');
14
+ var styles = require('../core/styles.cjs');
15
+ var values = require('../core/values.cjs');
16
+ var units = require('../core/units.cjs');
17
+ var composition = require('../waapi/composition.cjs');
18
+ var composition$1 = require('../animation/composition.cjs');
19
+ var animation = require('../animation/animation.cjs');
20
+
21
+ /**
22
+ * @import {
23
+ * Renderable,
24
+ * DOMTargetSelector,
25
+ * JSTargetsParam,
26
+ * DOMTargetsParam,
27
+ * TargetsParam,
28
+ * DOMTarget,
29
+ * AnimationParams,
30
+ * TargetsArray,
31
+ * } from '../types/index.js'
32
+ */
33
+
34
+ /**
35
+ * @import {
36
+ * WAAPIAnimation
37
+ * } from '../waapi/waapi.js'
38
+ */
39
+
40
+ /**
41
+ * @overload
42
+ * @param {DOMTargetSelector} targetSelector
43
+ * @param {String} propName
44
+ * @return {String}
45
+ *
46
+ * @overload
47
+ * @param {JSTargetsParam} targetSelector
48
+ * @param {String} propName
49
+ * @return {Number|String}
50
+ *
51
+ * @overload
52
+ * @param {DOMTargetsParam} targetSelector
53
+ * @param {String} propName
54
+ * @param {String} unit
55
+ * @return {String}
56
+ *
57
+ * @overload
58
+ * @param {TargetsParam} targetSelector
59
+ * @param {String} propName
60
+ * @param {Boolean} unit
61
+ * @return {Number}
62
+ *
63
+ * @param {TargetsParam} targetSelector
64
+ * @param {String} propName
65
+ * @param {String|Boolean} [unit]
66
+ */
67
+ function get(targetSelector, propName, unit) {
68
+ const targets$1 = targets.registerTargets(targetSelector);
69
+ if (!targets$1.length) return;
70
+ const [ target ] = targets$1;
71
+ const tweenType = values.getTweenType(target, propName);
72
+ const normalizePropName = styles.sanitizePropertyName(propName, target, tweenType);
73
+ let originalValue = values.getOriginalAnimatableValue(target, normalizePropName);
74
+ if (helpers.isUnd(unit)) {
75
+ return originalValue;
76
+ } else {
77
+ values.decomposeRawValue(originalValue, values.decomposedOriginalValue);
78
+ if (values.decomposedOriginalValue.t === consts.valueTypes.NUMBER || values.decomposedOriginalValue.t === consts.valueTypes.UNIT) {
79
+ if (unit === false) {
80
+ return values.decomposedOriginalValue.n;
81
+ } else {
82
+ const convertedValue = units.convertValueUnit(/** @type {DOMTarget} */(target), values.decomposedOriginalValue, /** @type {String} */(unit), false);
83
+ return `${helpers.round(convertedValue.n, globals.globals.precision)}${convertedValue.u}`;
84
+ }
85
+ }
86
+ }
87
+ }
88
+
89
+ /**
90
+ * @param {TargetsParam} targets
91
+ * @param {AnimationParams} parameters
92
+ * @return {JSAnimation}
93
+ */
94
+ const set = (targets, parameters) => {
95
+ if (helpers.isUnd(parameters)) return;
96
+ parameters.duration = consts.minValue;
97
+ // Do not overrides currently active tweens by default
98
+ parameters.composition = values.setValue(parameters.composition, consts.compositionTypes.none);
99
+ // Skip init() and force rendering by playing the animation
100
+ return new animation.JSAnimation(targets, parameters, null, 0, true).resume();
101
+ };
102
+
103
+ /**
104
+ * @param {TargetsParam} targets
105
+ * @param {Renderable|WAAPIAnimation} [renderable]
106
+ * @param {String} [propertyName]
107
+ * @return {TargetsArray}
108
+ */
109
+ const remove = (targets$1, renderable, propertyName) => {
110
+ const targetsArray = targets.parseTargets(targets$1);
111
+ for (let i = 0, l = targetsArray.length; i < l; i++) {
112
+ composition.removeWAAPIAnimation(
113
+ /** @type {DOMTarget} */(targetsArray[i]),
114
+ propertyName,
115
+ renderable && /** @type {WAAPIAnimation} */(renderable).controlAnimation && /** @type {WAAPIAnimation} */(renderable),
116
+ );
117
+ }
118
+ composition$1.removeTargetsFromRenderable(
119
+ targetsArray,
120
+ /** @type {Renderable} */(renderable),
121
+ propertyName
122
+ );
123
+ return targetsArray;
124
+ };
125
+
126
+ exports.$ = targets.registerTargets;
127
+ exports.cleanInlineStyles = styles.cleanInlineStyles;
128
+ exports.get = get;
129
+ exports.remove = remove;
130
+ exports.set = set;
@@ -0,0 +1,126 @@
1
+ /**
2
+ * @overload
3
+ * @param {DOMTargetSelector} targetSelector
4
+ * @param {String} propName
5
+ * @return {String}
6
+ *
7
+ * @overload
8
+ * @param {JSTargetsParam} targetSelector
9
+ * @param {String} propName
10
+ * @return {Number|String}
11
+ *
12
+ * @overload
13
+ * @param {DOMTargetsParam} targetSelector
14
+ * @param {String} propName
15
+ * @param {String} unit
16
+ * @return {String}
17
+ *
18
+ * @overload
19
+ * @param {TargetsParam} targetSelector
20
+ * @param {String} propName
21
+ * @param {Boolean} unit
22
+ * @return {Number}
23
+ *
24
+ * @param {TargetsParam} targetSelector
25
+ * @param {String} propName
26
+ * @param {String|Boolean} [unit]
27
+ */
28
+ export function get(targetSelector: DOMTargetSelector, propName: string): string;
29
+ /**
30
+ * @overload
31
+ * @param {DOMTargetSelector} targetSelector
32
+ * @param {String} propName
33
+ * @return {String}
34
+ *
35
+ * @overload
36
+ * @param {JSTargetsParam} targetSelector
37
+ * @param {String} propName
38
+ * @return {Number|String}
39
+ *
40
+ * @overload
41
+ * @param {DOMTargetsParam} targetSelector
42
+ * @param {String} propName
43
+ * @param {String} unit
44
+ * @return {String}
45
+ *
46
+ * @overload
47
+ * @param {TargetsParam} targetSelector
48
+ * @param {String} propName
49
+ * @param {Boolean} unit
50
+ * @return {Number}
51
+ *
52
+ * @param {TargetsParam} targetSelector
53
+ * @param {String} propName
54
+ * @param {String|Boolean} [unit]
55
+ */
56
+ export function get(targetSelector: JSTargetsParam, propName: string): number | string;
57
+ /**
58
+ * @overload
59
+ * @param {DOMTargetSelector} targetSelector
60
+ * @param {String} propName
61
+ * @return {String}
62
+ *
63
+ * @overload
64
+ * @param {JSTargetsParam} targetSelector
65
+ * @param {String} propName
66
+ * @return {Number|String}
67
+ *
68
+ * @overload
69
+ * @param {DOMTargetsParam} targetSelector
70
+ * @param {String} propName
71
+ * @param {String} unit
72
+ * @return {String}
73
+ *
74
+ * @overload
75
+ * @param {TargetsParam} targetSelector
76
+ * @param {String} propName
77
+ * @param {Boolean} unit
78
+ * @return {Number}
79
+ *
80
+ * @param {TargetsParam} targetSelector
81
+ * @param {String} propName
82
+ * @param {String|Boolean} [unit]
83
+ */
84
+ export function get(targetSelector: DOMTargetsParam, propName: string, unit: string): string;
85
+ /**
86
+ * @overload
87
+ * @param {DOMTargetSelector} targetSelector
88
+ * @param {String} propName
89
+ * @return {String}
90
+ *
91
+ * @overload
92
+ * @param {JSTargetsParam} targetSelector
93
+ * @param {String} propName
94
+ * @return {Number|String}
95
+ *
96
+ * @overload
97
+ * @param {DOMTargetsParam} targetSelector
98
+ * @param {String} propName
99
+ * @param {String} unit
100
+ * @return {String}
101
+ *
102
+ * @overload
103
+ * @param {TargetsParam} targetSelector
104
+ * @param {String} propName
105
+ * @param {Boolean} unit
106
+ * @return {Number}
107
+ *
108
+ * @param {TargetsParam} targetSelector
109
+ * @param {String} propName
110
+ * @param {String|Boolean} [unit]
111
+ */
112
+ export function get(targetSelector: TargetsParam, propName: string, unit: boolean): number;
113
+ export { registerTargets as $ };
114
+ export function set(targets: TargetsParam, parameters: AnimationParams): JSAnimation;
115
+ export function remove(targets: TargetsParam, renderable?: Renderable | WAAPIAnimation, propertyName?: string): TargetsArray;
116
+ export { cleanInlineStyles } from "../core/styles.js";
117
+ import type { DOMTargetSelector } from '../types/index.js';
118
+ import type { JSTargetsParam } from '../types/index.js';
119
+ import type { DOMTargetsParam } from '../types/index.js';
120
+ import type { TargetsParam } from '../types/index.js';
121
+ import { registerTargets } from '../core/targets.js';
122
+ import type { AnimationParams } from '../types/index.js';
123
+ import { JSAnimation } from '../animation/animation.js';
124
+ import type { Renderable } from '../types/index.js';
125
+ import type { WAAPIAnimation } from '../waapi/waapi.js';
126
+ import type { TargetsArray } from '../types/index.js';