animejs 4.4.0 → 4.5.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 (165) hide show
  1. package/README.md +4 -5
  2. package/dist/bundles/anime.esm.js +491 -272
  3. package/dist/bundles/anime.esm.min.js +2 -2
  4. package/dist/bundles/anime.umd.js +491 -272
  5. package/dist/bundles/anime.umd.min.js +2 -2
  6. package/dist/modules/adapters/index.cjs +14 -0
  7. package/dist/modules/adapters/index.d.ts +1 -0
  8. package/dist/modules/adapters/index.js +8 -0
  9. package/dist/modules/adapters/registry.cjs +149 -0
  10. package/dist/modules/adapters/registry.d.ts +65 -0
  11. package/dist/modules/adapters/registry.js +146 -0
  12. package/dist/modules/adapters/three/adapter.cjs +26 -0
  13. package/dist/modules/adapters/three/adapter.d.ts +15 -0
  14. package/dist/modules/adapters/three/adapter.js +24 -0
  15. package/dist/modules/adapters/three/helpers.cjs +297 -0
  16. package/dist/modules/adapters/three/helpers.d.ts +89 -0
  17. package/dist/modules/adapters/three/helpers.js +280 -0
  18. package/dist/modules/adapters/three/index.cjs +20 -0
  19. package/dist/modules/adapters/three/index.d.ts +2 -0
  20. package/dist/modules/adapters/three/index.js +12 -0
  21. package/dist/modules/adapters/three/instance.cjs +368 -0
  22. package/dist/modules/adapters/three/instance.d.ts +133 -0
  23. package/dist/modules/adapters/three/instance.js +365 -0
  24. package/dist/modules/adapters/three/object3d.cjs +214 -0
  25. package/dist/modules/adapters/three/object3d.d.ts +1 -0
  26. package/dist/modules/adapters/three/object3d.js +212 -0
  27. package/dist/modules/adapters/three/resolvers.cjs +105 -0
  28. package/dist/modules/adapters/three/resolvers.d.ts +1 -0
  29. package/dist/modules/adapters/three/resolvers.js +103 -0
  30. package/dist/modules/adapters/three/uniform.cjs +41 -0
  31. package/dist/modules/adapters/three/uniform.d.ts +1 -0
  32. package/dist/modules/adapters/three/uniform.js +39 -0
  33. package/dist/modules/animatable/animatable.cjs +2 -1
  34. package/dist/modules/animatable/animatable.d.ts +2 -1
  35. package/dist/modules/animatable/animatable.js +2 -1
  36. package/dist/modules/animatable/index.cjs +1 -1
  37. package/dist/modules/animatable/index.js +1 -1
  38. package/dist/modules/animation/additive.cjs +1 -1
  39. package/dist/modules/animation/additive.js +1 -1
  40. package/dist/modules/animation/animation.cjs +43 -16
  41. package/dist/modules/animation/animation.d.ts +5 -0
  42. package/dist/modules/animation/animation.js +45 -18
  43. package/dist/modules/animation/composition.cjs +38 -35
  44. package/dist/modules/animation/composition.js +38 -35
  45. package/dist/modules/animation/index.cjs +1 -1
  46. package/dist/modules/animation/index.js +1 -1
  47. package/dist/modules/core/clock.cjs +11 -15
  48. package/dist/modules/core/clock.d.ts +0 -2
  49. package/dist/modules/core/clock.js +11 -15
  50. package/dist/modules/core/colors.cjs +1 -1
  51. package/dist/modules/core/colors.js +1 -1
  52. package/dist/modules/core/consts.cjs +15 -1
  53. package/dist/modules/core/consts.d.ts +2 -0
  54. package/dist/modules/core/consts.js +14 -2
  55. package/dist/modules/core/globals.cjs +7 -4
  56. package/dist/modules/core/globals.d.ts +8 -2
  57. package/dist/modules/core/globals.js +8 -5
  58. package/dist/modules/core/helpers.cjs +2 -2
  59. package/dist/modules/core/helpers.js +3 -3
  60. package/dist/modules/core/render.cjs +93 -73
  61. package/dist/modules/core/render.js +96 -76
  62. package/dist/modules/core/styles.cjs +16 -2
  63. package/dist/modules/core/styles.js +16 -2
  64. package/dist/modules/core/targets.cjs +11 -13
  65. package/dist/modules/core/targets.js +11 -13
  66. package/dist/modules/core/transforms.cjs +1 -1
  67. package/dist/modules/core/transforms.js +1 -1
  68. package/dist/modules/core/units.cjs +1 -1
  69. package/dist/modules/core/units.js +1 -1
  70. package/dist/modules/core/values.cjs +73 -82
  71. package/dist/modules/core/values.d.ts +1 -2
  72. package/dist/modules/core/values.js +76 -84
  73. package/dist/modules/draggable/draggable.cjs +1 -1
  74. package/dist/modules/draggable/draggable.js +1 -1
  75. package/dist/modules/draggable/index.cjs +1 -1
  76. package/dist/modules/draggable/index.js +1 -1
  77. package/dist/modules/easings/cubic-bezier/index.cjs +1 -1
  78. package/dist/modules/easings/cubic-bezier/index.js +1 -1
  79. package/dist/modules/easings/eases/index.cjs +1 -1
  80. package/dist/modules/easings/eases/index.js +1 -1
  81. package/dist/modules/easings/eases/parser.cjs +3 -3
  82. package/dist/modules/easings/eases/parser.d.ts +4 -5
  83. package/dist/modules/easings/eases/parser.js +3 -3
  84. package/dist/modules/easings/index.cjs +1 -1
  85. package/dist/modules/easings/index.js +1 -1
  86. package/dist/modules/easings/irregular/index.cjs +1 -1
  87. package/dist/modules/easings/irregular/index.js +1 -1
  88. package/dist/modules/easings/linear/index.cjs +1 -1
  89. package/dist/modules/easings/linear/index.js +1 -1
  90. package/dist/modules/easings/none.cjs +1 -1
  91. package/dist/modules/easings/none.js +1 -1
  92. package/dist/modules/easings/spring/index.cjs +1 -1
  93. package/dist/modules/easings/spring/index.js +1 -1
  94. package/dist/modules/easings/steps/index.cjs +1 -1
  95. package/dist/modules/easings/steps/index.js +1 -1
  96. package/dist/modules/engine/engine.cjs +4 -2
  97. package/dist/modules/engine/engine.js +4 -2
  98. package/dist/modules/engine/index.cjs +1 -1
  99. package/dist/modules/engine/index.js +1 -1
  100. package/dist/modules/events/index.cjs +1 -1
  101. package/dist/modules/events/index.js +1 -1
  102. package/dist/modules/events/scroll.cjs +3 -1
  103. package/dist/modules/events/scroll.js +3 -1
  104. package/dist/modules/index.cjs +1 -1
  105. package/dist/modules/index.js +1 -1
  106. package/dist/modules/layout/index.cjs +1 -1
  107. package/dist/modules/layout/index.js +1 -1
  108. package/dist/modules/layout/layout.cjs +1 -1
  109. package/dist/modules/layout/layout.js +1 -1
  110. package/dist/modules/scope/index.cjs +1 -1
  111. package/dist/modules/scope/index.js +1 -1
  112. package/dist/modules/scope/scope.cjs +1 -1
  113. package/dist/modules/scope/scope.js +1 -1
  114. package/dist/modules/svg/drawable.cjs +1 -1
  115. package/dist/modules/svg/drawable.js +1 -1
  116. package/dist/modules/svg/helpers.cjs +1 -1
  117. package/dist/modules/svg/helpers.js +1 -1
  118. package/dist/modules/svg/index.cjs +1 -1
  119. package/dist/modules/svg/index.js +1 -1
  120. package/dist/modules/svg/morphto.cjs +1 -1
  121. package/dist/modules/svg/morphto.js +1 -1
  122. package/dist/modules/svg/motionpath.cjs +1 -1
  123. package/dist/modules/svg/motionpath.js +1 -1
  124. package/dist/modules/text/index.cjs +1 -1
  125. package/dist/modules/text/index.js +1 -1
  126. package/dist/modules/text/scramble.cjs +12 -2
  127. package/dist/modules/text/scramble.d.ts +9 -1
  128. package/dist/modules/text/scramble.js +12 -2
  129. package/dist/modules/text/split.cjs +2 -1
  130. package/dist/modules/text/split.js +2 -1
  131. package/dist/modules/timeline/index.cjs +1 -1
  132. package/dist/modules/timeline/index.js +1 -1
  133. package/dist/modules/timeline/position.cjs +1 -1
  134. package/dist/modules/timeline/position.js +1 -1
  135. package/dist/modules/timeline/timeline.cjs +14 -5
  136. package/dist/modules/timeline/timeline.d.ts +3 -3
  137. package/dist/modules/timeline/timeline.js +14 -5
  138. package/dist/modules/timer/index.cjs +1 -1
  139. package/dist/modules/timer/index.js +1 -1
  140. package/dist/modules/timer/timer.cjs +1 -1
  141. package/dist/modules/timer/timer.js +1 -1
  142. package/dist/modules/types/index.d.ts +36 -11
  143. package/dist/modules/utils/chainable.cjs +1 -1
  144. package/dist/modules/utils/chainable.js +1 -1
  145. package/dist/modules/utils/index.cjs +1 -1
  146. package/dist/modules/utils/index.js +1 -1
  147. package/dist/modules/utils/number.cjs +1 -1
  148. package/dist/modules/utils/number.js +1 -1
  149. package/dist/modules/utils/random.cjs +4 -3
  150. package/dist/modules/utils/random.d.ts +1 -1
  151. package/dist/modules/utils/random.js +4 -3
  152. package/dist/modules/utils/stagger.cjs +67 -13
  153. package/dist/modules/utils/stagger.js +69 -15
  154. package/dist/modules/utils/target.cjs +4 -1
  155. package/dist/modules/utils/target.js +4 -1
  156. package/dist/modules/utils/time.cjs +6 -5
  157. package/dist/modules/utils/time.d.ts +1 -1
  158. package/dist/modules/utils/time.js +6 -5
  159. package/dist/modules/waapi/composition.cjs +1 -1
  160. package/dist/modules/waapi/composition.js +1 -1
  161. package/dist/modules/waapi/index.cjs +1 -1
  162. package/dist/modules/waapi/index.js +1 -1
  163. package/dist/modules/waapi/waapi.cjs +1 -1
  164. package/dist/modules/waapi/waapi.js +1 -1
  165. package/package.json +38 -5
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - timeline - CJS
3
- * @version v4.4.0
3
+ * @version v4.5.0
4
4
  * @license MIT
5
5
  * @copyright 2026 - Julian Garnier
6
6
  */
@@ -34,6 +34,7 @@ var position = require('./position.cjs');
34
34
  * TimelinePosition,
35
35
  * StaggerFunction,
36
36
  * TargetsArray,
37
+ * TweakRegister,
37
38
  * } from '../types/index.js'
38
39
  */
39
40
 
@@ -43,8 +44,6 @@ var position = require('./position.cjs');
43
44
  * } from '../waapi/waapi.js'
44
45
  */
45
46
 
46
- /** @import {TweakRegister} from 'tweaks' */
47
-
48
47
  /**
49
48
  * @param {Timeline} tl
50
49
  * @return {Number}
@@ -237,13 +236,21 @@ class Timeline extends timer.Timer {
237
236
  if (!helpers.isUnd(synced) && !helpers.isUnd(/** @type {WAAPIAnimation} */(synced).persist)) {
238
237
  /** @type {WAAPIAnimation} */(synced).persist = true;
239
238
  }
240
- return this.add(synced, { currentTime: [0, duration], duration, delay: 0, ease: 'linear', playbackEase: 'linear' }, position);
239
+ const editor = globals.globals.editor;
240
+ const childHook = editor && editor.addTimelineChild;
241
+ if (editor && editor.addTimelineSync) {
242
+ position = editor.addTimelineSync(synced, position, this.id);
243
+ editor.addTimelineChild = null; // Suppress the per-child hook for the internal .add, sync already registered.
244
+ }
245
+ const result = this.add(synced, { currentTime: [0, duration], duration, delay: 0, ease: 'linear', playbackEase: 'linear' }, position);
246
+ if (editor) editor.addTimelineChild = childHook;
247
+ return result;
241
248
  }
242
249
 
243
250
  /**
244
251
  * @param {TargetsParam} targets
245
252
  * @param {AnimationParams} parameters
246
- * @param {TimelinePosition} [position]
253
+ * @param {TimelinePosition|StaggerFunction<Number|String>|TweakRegister} [position]
247
254
  * @return {this}
248
255
  */
249
256
  set(targets, parameters, position) {
@@ -260,6 +267,7 @@ class Timeline extends timer.Timer {
260
267
  */
261
268
  call(callback, position) {
262
269
  if (helpers.isUnd(callback) || callback && !helpers.isFnc(callback)) return this;
270
+ if (globals.globals.editor && globals.globals.editor.addTimelineCall) position = globals.globals.editor.addTimelineCall(callback, position, this.id);
263
271
  return this.add({ duration: 0, delay: 0, onComplete: () => callback(this) }, position);
264
272
  }
265
273
 
@@ -271,6 +279,7 @@ class Timeline extends timer.Timer {
271
279
  */
272
280
  label(labelName, position$1) {
273
281
  if (helpers.isUnd(labelName) || labelName && !helpers.isStr(labelName)) return this;
282
+ if (globals.globals.editor && globals.globals.editor.addTimelineLabel) position$1 = globals.globals.editor.addTimelineLabel(labelName, position$1, this.id);
274
283
  this.labels[labelName] = position.parseTimelinePosition(this, position$1);
275
284
  return this;
276
285
  }
@@ -109,10 +109,10 @@ export class Timeline extends Timer {
109
109
  /**
110
110
  * @param {TargetsParam} targets
111
111
  * @param {AnimationParams} parameters
112
- * @param {TimelinePosition} [position]
112
+ * @param {TimelinePosition|StaggerFunction<Number|String>|TweakRegister} [position]
113
113
  * @return {this}
114
114
  */
115
- set(targets: TargetsParam, parameters: AnimationParams, position?: TimelinePosition): this;
115
+ set(targets: TargetsParam, parameters: AnimationParams, position?: TimelinePosition | StaggerFunction<number | string> | TweakRegister): this;
116
116
  /**
117
117
  * @param {Callback<Timer>} callback
118
118
  * @param {TimelinePosition} [position]
@@ -164,7 +164,7 @@ import type { TargetsParam } from '../types/index.js';
164
164
  import type { AnimationParams } from '../types/index.js';
165
165
  import type { TimelinePosition } from '../types/index.js';
166
166
  import type { StaggerFunction } from '../types/index.js';
167
- import type { TweakRegister } from 'tweaks';
167
+ import type { TweakRegister } from '../types/index.js';
168
168
  import type { TimerParams } from '../types/index.js';
169
169
  import type { Tickable } from '../types/index.js';
170
170
  import type { WAAPIAnimation } from '../waapi/waapi.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - timeline - ESM
3
- * @version v4.4.0
3
+ * @version v4.5.0
4
4
  * @license MIT
5
5
  * @copyright 2026 - Julian Garnier
6
6
  */
@@ -32,6 +32,7 @@ import { parseTimelinePosition } from './position.js';
32
32
  * TimelinePosition,
33
33
  * StaggerFunction,
34
34
  * TargetsArray,
35
+ * TweakRegister,
35
36
  * } from '../types/index.js'
36
37
  */
37
38
 
@@ -41,8 +42,6 @@ import { parseTimelinePosition } from './position.js';
41
42
  * } from '../waapi/waapi.js'
42
43
  */
43
44
 
44
- /** @import {TweakRegister} from 'tweaks' */
45
-
46
45
  /**
47
46
  * @param {Timeline} tl
48
47
  * @return {Number}
@@ -235,13 +234,21 @@ class Timeline extends Timer {
235
234
  if (!isUnd(synced) && !isUnd(/** @type {WAAPIAnimation} */(synced).persist)) {
236
235
  /** @type {WAAPIAnimation} */(synced).persist = true;
237
236
  }
238
- return this.add(synced, { currentTime: [0, duration], duration, delay: 0, ease: 'linear', playbackEase: 'linear' }, position);
237
+ const editor = globals.editor;
238
+ const childHook = editor && editor.addTimelineChild;
239
+ if (editor && editor.addTimelineSync) {
240
+ position = editor.addTimelineSync(synced, position, this.id);
241
+ editor.addTimelineChild = null; // Suppress the per-child hook for the internal .add, sync already registered.
242
+ }
243
+ const result = this.add(synced, { currentTime: [0, duration], duration, delay: 0, ease: 'linear', playbackEase: 'linear' }, position);
244
+ if (editor) editor.addTimelineChild = childHook;
245
+ return result;
239
246
  }
240
247
 
241
248
  /**
242
249
  * @param {TargetsParam} targets
243
250
  * @param {AnimationParams} parameters
244
- * @param {TimelinePosition} [position]
251
+ * @param {TimelinePosition|StaggerFunction<Number|String>|TweakRegister} [position]
245
252
  * @return {this}
246
253
  */
247
254
  set(targets, parameters, position) {
@@ -258,6 +265,7 @@ class Timeline extends Timer {
258
265
  */
259
266
  call(callback, position) {
260
267
  if (isUnd(callback) || callback && !isFnc(callback)) return this;
268
+ if (globals.editor && globals.editor.addTimelineCall) position = globals.editor.addTimelineCall(callback, position, this.id);
261
269
  return this.add({ duration: 0, delay: 0, onComplete: () => callback(this) }, position);
262
270
  }
263
271
 
@@ -269,6 +277,7 @@ class Timeline extends Timer {
269
277
  */
270
278
  label(labelName, position) {
271
279
  if (isUnd(labelName) || labelName && !isStr(labelName)) return this;
280
+ if (globals.editor && globals.editor.addTimelineLabel) position = globals.editor.addTimelineLabel(labelName, position, this.id);
272
281
  this.labels[labelName] = parseTimelinePosition(this, position);
273
282
  return this;
274
283
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - timer - CJS
3
- * @version v4.4.0
3
+ * @version v4.5.0
4
4
  * @license MIT
5
5
  * @copyright 2026 - Julian Garnier
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - timer - ESM
3
- * @version v4.4.0
3
+ * @version v4.5.0
4
4
  * @license MIT
5
5
  * @copyright 2026 - Julian Garnier
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - timer - CJS
3
- * @version v4.4.0
3
+ * @version v4.5.0
4
4
  * @license MIT
5
5
  * @copyright 2026 - Julian Garnier
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - timer - ESM
3
- * @version v4.4.0
3
+ * @version v4.5.0
4
4
  * @license MIT
5
5
  * @copyright 2026 - Julian Garnier
6
6
  */
@@ -27,17 +27,36 @@ export type Renderable = JSAnimation | Timeline;
27
27
  export type Tickable = Timer | Renderable;
28
28
  export type CallbackArgument = Timer & JSAnimation & Timeline;
29
29
  export type Revertible = Animatable | Tickable | WAAPIAnimation | Draggable | ScrollObserver | TextSplitter | Scope | AutoLayout;
30
+ export type TweakRegister = {
31
+ type: string;
32
+ defaultValue: any;
33
+ };
30
34
  export type StaggerFunction<T> = (target?: Target, index?: number, targets?: TargetsArray, prevTween?: Tween | null, tl?: Timeline) => T;
31
35
  export type StaggerParams = {
32
36
  start?: number | string;
33
37
  from?: number | "first" | "center" | "last" | "random" | Array<number>;
34
38
  reversed?: boolean;
35
39
  grid?: Array<number> | boolean;
36
- axis?: ("x" | "y");
37
- use?: string | ((target: Target, i: number, length: number) => number);
40
+ axis?: ("x" | "y" | "z");
41
+ use?: string | {
42
+ method(target: Target, i: number, length: number): number;
43
+ }["method"];
38
44
  total?: number;
39
45
  ease?: EasingParam;
40
46
  modifier?: TweenModifier;
47
+ /**
48
+ * Additive uniform noise on the
49
+ * computed stagger value. Number form gives flat `+/-jitter`; tuple form
50
+ * ramps the magnitude `start -> end` across the from/axis/grid ordering
51
+ * and respects `ease`.
52
+ */
53
+ jitter?: number | [number, number];
54
+ /**
55
+ * Seed for jitter draws and `from: 'random'`
56
+ * shuffling. `false` (default) uses Math.random. `true` seeds with `0`. A
57
+ * number is used directly as the seed.
58
+ */
59
+ seed?: boolean | number;
41
60
  };
42
61
  export type DOMTarget = HTMLElement | SVGElement;
43
62
  export type JSTarget = Record<string, any>;
@@ -89,7 +108,9 @@ export type SpringParams = {
89
108
  */
90
109
  onComplete?: Callback<JSAnimation>;
91
110
  };
92
- export type Callback<T> = (self: T, e?: PointerEvent) => any;
111
+ export type Callback<T> = {
112
+ method(self: T): any;
113
+ }["method"];
93
114
  export type TickableCallbacks<T extends unknown> = {
94
115
  onBegin?: Callback<T>;
95
116
  onBeforeUpdate?: Callback<T>;
@@ -115,7 +136,8 @@ export type TimerOptions = {
115
136
  priority?: number;
116
137
  };
117
138
  export type TimerParams = TimerOptions & TickableCallbacks<Timer>;
118
- export type FunctionValue = (target?: Target, index?: number, targets?: TargetsArray, prevTween?: Tween | null) => number | string | TweenObjectValue | EasingParam | Array<number | string | TweenObjectValue>;
139
+ export type FunctionValueReturn = number | string | TweenKeyValue | EasingParam | Array<number | string | TweenKeyValue>;
140
+ export type FunctionValue<T = FunctionValueReturn> = (target?: Target, index?: number, targets?: TargetsArray, prevTween?: Tween | null) => T;
119
141
  export type TweenModifier = (value: number) => number | string;
120
142
  export type ColorArray = [number, number, number, number];
121
143
  export type Tween = {
@@ -123,7 +145,7 @@ export type Tween = {
123
145
  parent: JSAnimation;
124
146
  property: string;
125
147
  target: Target;
126
- _value: string | number;
148
+ _value: string | number | any;
127
149
  _toFunc: Function | null;
128
150
  _fromFunc: Function | null;
129
151
  _ease: EasingFunction;
@@ -142,7 +164,11 @@ export type Tween = {
142
164
  _startTime: number;
143
165
  _changeDuration: number;
144
166
  _absoluteStartTime: number;
167
+ _absoluteUpdateStartTime: number;
168
+ _absoluteEndTime: number;
169
+ _hasFromValue: number;
145
170
  _tweenType: tweenTypes;
171
+ _setter: ((target: any, value: number, tween: Tween) => void) | null;
146
172
  _valueType: valueTypes;
147
173
  _composition: number;
148
174
  _isOverlapped: number;
@@ -174,11 +200,11 @@ export type TweenDecomposedValue = {
174
200
  */
175
201
  o: string;
176
202
  /**
177
- * - Array of Numbers (in case of complex value type)
203
+ * - Array of Numbers (complex / color value type)
178
204
  */
179
205
  d: Array<number>;
180
206
  /**
181
- * - Strings (in case of complex value type)
207
+ * - Strings (complex value type)
182
208
  */
183
209
  s: Array<string>;
184
210
  };
@@ -189,7 +215,7 @@ export type TweenPropertySiblings = {
189
215
  export type TweenLookups = Record<string, TweenPropertySiblings>;
190
216
  export type TweenReplaceLookups = WeakMap<Target, TweenLookups>;
191
217
  export type TweenAdditiveLookups = Map<Target, TweenLookups>;
192
- export type TweenParamValue = number | string | FunctionValue | EasingParam;
218
+ export type TweenParamValue = number | string | FunctionValue | EasingParam | TweakRegister;
193
219
  export type TweenPropValue = TweenParamValue | [TweenParamValue, TweenParamValue];
194
220
  export type TweenComposition = (string & {}) | "none" | "replace" | "blend" | compositionTypes;
195
221
  export type TweenParamsOptions = {
@@ -290,7 +316,7 @@ export type AnimatablePropertyParamsOptions = {
290
316
  modifier?: TweenModifier;
291
317
  composition?: TweenComposition;
292
318
  };
293
- export type AnimatableParams = Record<string, TweenParamValue | EasingParam | TweenModifier | TweenComposition | AnimatablePropertyParamsOptions> & AnimatablePropertyParamsOptions;
319
+ export type AnimatableParams = Record<string, TweenParamValue | EasingParam | TweenModifier | TweenComposition | AnimatablePropertyParamsOptions | Callback<JSAnimation>> & AnimatablePropertyParamsOptions & TickableCallbacks<JSAnimation> & RenderableCallbacks<JSAnimation>;
294
320
  export type ReactRef = {
295
321
  current?: HTMLElement | SVGElement | null;
296
322
  };
@@ -305,7 +331,7 @@ export type ScopeParams = {
305
331
  export type ScopedCallback<T> = (scope: Scope) => T;
306
332
  export type ScopeCleanupCallback = (scope?: Scope) => any;
307
333
  export type ScopeConstructorCallback = (scope?: Scope) => ScopeCleanupCallback | void;
308
- export type ScopeMethod = (...args: any[]) => ScopeCleanupCallback | void;
334
+ export type ScopeMethod = (...args: any[]) => any;
309
335
  export type ScrollThresholdValue = string | number;
310
336
  export type ScrollThresholdParam = {
311
337
  target?: ScrollThresholdValue;
@@ -475,6 +501,5 @@ import type { TextSplitter } from '../text/split.js';
475
501
  import type { Scope } from '../scope/scope.js';
476
502
  import type { AutoLayout } from '../layout/layout.js';
477
503
  import type { Spring } from '../easings/spring/index.js';
478
- import type { TweakRegister } from 'tweaks';
479
504
  import type { tweenTypes } from '../core/consts.js';
480
505
  import type { valueTypes } from '../core/consts.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - utils - CJS
3
- * @version v4.4.0
3
+ * @version v4.5.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.4.0
3
+ * @version v4.5.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.4.0
3
+ * @version v4.5.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.4.0
3
+ * @version v4.5.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.4.0
3
+ * @version v4.5.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.4.0
3
+ * @version v4.5.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.4.0
3
+ * @version v4.5.0
4
4
  * @license MIT
5
5
  * @copyright 2026 - Julian Garnier
6
6
  */
@@ -63,11 +63,12 @@ const randomPick = items => items[random(0, items.length - 1)];
63
63
  * Adapted from https://bost.ocks.org/mike/shuffle/
64
64
  *
65
65
  * @param {Array} items - The array to shuffle (will be modified in-place)
66
+ * @param {RandomNumberGenerator} [rnd] - Optional RNG matching the random() signature (defaults to random)
66
67
  * @return {Array} The same array reference, now shuffled
67
68
  */
68
- const shuffle = items => {
69
+ const shuffle = (items, rnd = random) => {
69
70
  let m = items.length, t, i;
70
- while (m) { i = random(0, --m); t = items[m]; items[m] = items[i]; items[i] = t; }
71
+ while (m) { i = rnd(0, --m); t = items[m]; items[m] = items[i]; items[i] = t; }
71
72
  return items;
72
73
  };
73
74
 
@@ -15,7 +15,7 @@
15
15
  export const random: RandomNumberGenerator;
16
16
  export function createSeededRandom(seed?: number, seededMin?: number, seededMax?: number, seededDecimalLength?: number): RandomNumberGenerator;
17
17
  export function randomPick<T>(items: string | Array<T>): string | T;
18
- export function shuffle(items: any[]): any[];
18
+ export function shuffle(items: any[], rnd?: RandomNumberGenerator): any[];
19
19
  /**
20
20
  * Generate a random number between optional min and max (inclusive) and decimal precision
21
21
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - utils - ESM
3
- * @version v4.4.0
3
+ * @version v4.5.0
4
4
  * @license MIT
5
5
  * @copyright 2026 - Julian Garnier
6
6
  */
@@ -61,11 +61,12 @@ const randomPick = items => items[random(0, items.length - 1)];
61
61
  * Adapted from https://bost.ocks.org/mike/shuffle/
62
62
  *
63
63
  * @param {Array} items - The array to shuffle (will be modified in-place)
64
+ * @param {RandomNumberGenerator} [rnd] - Optional RNG matching the random() signature (defaults to random)
64
65
  * @return {Array} The same array reference, now shuffled
65
66
  */
66
- const shuffle = items => {
67
+ const shuffle = (items, rnd = random) => {
67
68
  let m = items.length, t, i;
68
- while (m) { i = random(0, --m); t = items[m]; items[m] = items[i]; items[i] = t; }
69
+ while (m) { i = rnd(0, --m); t = items[m]; items[m] = items[i]; items[i] = t; }
69
70
  return items;
70
71
  };
71
72
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Anime.js - utils - CJS
3
- * @version v4.4.0
3
+ * @version v4.5.0
4
4
  * @license MIT
5
5
  * @copyright 2026 - Julian Garnier
6
6
  */
@@ -66,6 +66,7 @@ const stagger = (val, params = {}) => {
66
66
  let values$1 = [];
67
67
  let maxValue = 0;
68
68
  let cachedOffset;
69
+ let jitterSamples = null;
69
70
  const from = params.from;
70
71
  const reversed = params.reversed;
71
72
  const ease = params.ease;
@@ -87,27 +88,42 @@ const stagger = (val, params = {}) => {
87
88
  const val2 = isRange ? helpers.parseNumber(val[1]) : 0;
88
89
  const unitMatch = consts.unitsExecRgx.exec((isRange ? val[1] : val) + consts.emptyString);
89
90
  const start = params.start || 0 + (isRange ? val1 : 0);
91
+ const seed = params.seed;
92
+ const hasSeed = !helpers.isUnd(seed) && seed !== false;
93
+ const rng = hasSeed ? random.createSeededRandom(seed === true ? 0 : /** @type {Number} */(seed)) : random.random;
94
+ const jitter = params.jitter;
95
+ const hasJitter = !helpers.isUnd(jitter);
96
+ const jitterIsArr = helpers.isArr(jitter);
97
+ const jitterStart = jitterIsArr ? /** @type {[Number,Number]} */(jitter)[0] : /** @type {Number} */(jitter) || 0;
98
+ const jitterEnd = jitterIsArr ? /** @type {[Number,Number]} */(jitter)[1] : /** @type {Number} */(jitter) || 0;
90
99
  let fromIndex = fromFirst ? 0 : helpers.isNum(from) ? from : 0;
91
100
  return (target, i, t, _, tl) => {
92
101
  const [ registeredTarget ] = targets.registerTargets(target);
93
102
  const total = helpers.isUnd(customTotal) ? t.length : customTotal;
94
103
  const customIndex = !helpers.isUnd(useProp) ? helpers.isFnc(useProp) ? useProp(registeredTarget, i, total) : values.getOriginalAnimatableValue(registeredTarget, useProp) : false;
95
- const staggerIndex = helpers.isNum(customIndex) || helpers.isStr(customIndex) && helpers.isNum(+customIndex) ? +customIndex : i;
104
+ const customIdx = helpers.isNum(customIndex) || helpers.isStr(customIndex) && helpers.isNum(+customIndex) ? +customIndex : i;
105
+ // Fall back to the natural index when the resolved value lands outside [0, total) so values[staggerIndex] never reads undefined.
106
+ const staggerIndex = customIdx >= 0 && customIdx < total ? customIdx : i;
96
107
  if (fromCenter) fromIndex = (total - 1) / 2;
97
108
  if (fromLast) fromIndex = total - 1;
98
109
  if (!values$1.length) {
99
110
  if (autoGrid) {
100
111
  let hasPositions = true;
112
+ let has3D = false;
101
113
  let minPosX = Infinity;
102
114
  let minPosY = Infinity;
115
+ let minPosZ = Infinity;
103
116
  let maxPosX = -Infinity;
104
117
  let maxPosY = -Infinity;
118
+ let maxPosZ = -Infinity;
105
119
  const pxArr = [];
106
120
  const pyArr = [];
121
+ const pzArr = [];
107
122
  for (let index = 0; index < total; index++) {
108
123
  const el = t[index];
109
124
  let px = 0;
110
125
  let py = 0;
126
+ let pz = 0;
111
127
  let found = false;
112
128
  if (el && helpers.isFnc(el.getBoundingClientRect)) {
113
129
  const rect = el.getBoundingClientRect();
@@ -119,6 +135,10 @@ const stagger = (val, params = {}) => {
119
135
  if (obj && helpers.isNum(obj.x) && helpers.isNum(obj.y)) {
120
136
  px = obj.x;
121
137
  py = obj.y;
138
+ if (helpers.isNum(obj.z)) {
139
+ pz = obj.z;
140
+ has3D = true;
141
+ }
122
142
  found = true;
123
143
  }
124
144
  }
@@ -128,42 +148,52 @@ const stagger = (val, params = {}) => {
128
148
  }
129
149
  pxArr.push(px);
130
150
  pyArr.push(py);
151
+ pzArr.push(pz);
131
152
  if (px < minPosX) minPosX = px;
132
153
  if (py < minPosY) minPosY = py;
154
+ if (pz < minPosZ) minPosZ = pz;
133
155
  if (px > maxPosX) maxPosX = px;
134
156
  if (py > maxPosY) maxPosY = py;
157
+ if (pz > maxPosZ) maxPosZ = pz;
135
158
  }
136
159
  if (hasPositions) {
137
160
  let fX = pxArr[0];
138
161
  let fY = pyArr[0];
162
+ let fZ = pzArr[0];
139
163
  if (fromArr) {
140
164
  fX = minPosX + from[0] * (maxPosX - minPosX);
141
165
  fY = minPosY + from[1] * (maxPosY - minPosY);
166
+ fZ = has3D ? minPosZ + (from.length >= 3 ? from[2] : 0.5) * (maxPosZ - minPosZ) : 0;
142
167
  } else if (fromCenter) {
143
168
  fX = (minPosX + maxPosX) / 2;
144
169
  fY = (minPosY + maxPosY) / 2;
170
+ fZ = (minPosZ + maxPosZ) / 2;
145
171
  } else if (fromLast) {
146
172
  fX = pxArr[total - 1];
147
173
  fY = pyArr[total - 1];
174
+ fZ = pzArr[total - 1];
148
175
  } else if (helpers.isNum(from)) {
149
176
  fX = pxArr[from];
150
177
  fY = pyArr[from];
178
+ fZ = pzArr[from];
151
179
  }
152
180
  for (let index = 0; index < total; index++) {
153
181
  const distanceX = fX - pxArr[index];
154
182
  const distanceY = fY - pyArr[index];
155
- let value = helpers.sqrt(distanceX * distanceX + distanceY * distanceY);
183
+ const distanceZ = fZ - pzArr[index];
184
+ let value = helpers.sqrt(distanceX * distanceX + distanceY * distanceY + (has3D ? distanceZ * distanceZ : 0));
156
185
  if (axis === 'x') value = -distanceX;
157
186
  if (axis === 'y') value = -distanceY;
187
+ if (axis === 'z') value = -distanceZ;
158
188
  values$1.push(value);
159
189
  }
160
190
  let minDist = Infinity;
161
- for (let index = 0, l = values$1.length; index < l; index++) {
191
+ for (let index = 0; index < total; index++) {
162
192
  const absVal = helpers.abs(values$1[index]);
163
193
  if (absVal > 0 && absVal < minDist) minDist = absVal;
164
194
  }
165
195
  if (minDist > 0 && minDist < Infinity) {
166
- for (let index = 0, l = values$1.length; index < l; index++) {
196
+ for (let index = 0; index < total; index++) {
167
197
  values$1[index] = values$1[index] / minDist;
168
198
  }
169
199
  }
@@ -177,32 +207,51 @@ const stagger = (val, params = {}) => {
177
207
  if (!grid) {
178
208
  values$1.push(helpers.abs(fromIndex - index));
179
209
  } else {
180
- let fromX, fromY;
210
+ const dims = grid.length;
211
+ const wh = grid[0] * grid[1];
212
+ let fromX, fromY, fromZ;
181
213
  if (fromArr) {
182
214
  fromX = from[0] * (grid[0] - 1);
183
215
  fromY = from[1] * (grid[1] - 1);
216
+ fromZ = dims === 3 ? (from.length >= 3 ? from[2] : 0.5) * (grid[2] - 1) : 0;
184
217
  } else if (fromCenter) {
185
218
  fromX = (grid[0] - 1) / 2;
186
219
  fromY = (grid[1] - 1) / 2;
220
+ fromZ = dims === 3 ? (grid[2] - 1) / 2 : 0;
187
221
  } else {
188
222
  fromX = fromIndex % grid[0];
189
- fromY = helpers.floor(fromIndex / grid[0]);
223
+ fromY = helpers.floor(fromIndex / grid[0]) % grid[1];
224
+ fromZ = dims === 3 ? helpers.floor(fromIndex / wh) : 0;
190
225
  }
191
226
  const toX = index % grid[0];
192
- const toY = helpers.floor(index / grid[0]);
227
+ const toY = helpers.floor(index / grid[0]) % grid[1];
228
+ const toZ = dims === 3 ? helpers.floor(index / wh) : 0;
193
229
  const distanceX = fromX - toX;
194
230
  const distanceY = fromY - toY;
195
- let value = helpers.sqrt(distanceX * distanceX + distanceY * distanceY);
231
+ const distanceZ = fromZ - toZ;
232
+ let value = helpers.sqrt(distanceX * distanceX + distanceY * distanceY + (dims === 3 ? distanceZ * distanceZ : 0));
196
233
  if (axis === 'x') value = -distanceX;
197
234
  if (axis === 'y') value = -distanceY;
235
+ if (axis === 'z') value = -distanceZ;
198
236
  values$1.push(value);
199
237
  }
200
238
  }
201
239
  }
202
- maxValue = helpers.max(...values$1);
203
- if (staggerEase) values$1 = values$1.map(val => staggerEase(val / maxValue) * maxValue);
204
- if (reversed) values$1 = values$1.map(val => axis ? (val < 0) ? val * -1 : -val : helpers.abs(maxValue - val));
205
- if (fromRandom) values$1 = random.shuffle(values$1);
240
+ maxValue = values$1[0];
241
+ for (let k = 1; k < total; k++) if (values$1[k] > maxValue) maxValue = values$1[k];
242
+ if (staggerEase || reversed) {
243
+ for (let k = 0; k < total; k++) {
244
+ let v = values$1[k];
245
+ if (staggerEase) v = staggerEase(v / maxValue) * maxValue;
246
+ if (reversed) v = axis ? -v : helpers.abs(maxValue - v);
247
+ values$1[k] = v;
248
+ }
249
+ }
250
+ if (hasJitter) {
251
+ jitterSamples = new Array(total);
252
+ for (let k = 0; k < total; k++) jitterSamples[k] = rng(-1, 1, 4);
253
+ }
254
+ if (fromRandom) values$1 = random.shuffle(values$1, rng);
206
255
  }
207
256
  const spacing = isRange ? (val2 - val1) / maxValue : val1;
208
257
  if (helpers.isUnd(cachedOffset)) {
@@ -210,6 +259,11 @@ const stagger = (val, params = {}) => {
210
259
  }
211
260
  /** @type {String|Number} */
212
261
  let output = cachedOffset + ((spacing * helpers.round(values$1[staggerIndex], 2)) || 0);
262
+ if (hasJitter) {
263
+ const progress = maxValue ? values$1[staggerIndex] / maxValue : 0;
264
+ const mag = jitterStart + (jitterEnd - jitterStart) * progress;
265
+ output = /** @type {Number} */(output) + jitterSamples[staggerIndex] * mag;
266
+ }
213
267
  if (params.modifier) output = params.modifier(/** @type {Number} */(output));
214
268
  if (unitMatch) output = `${output}${unitMatch[2]}`;
215
269
  return output;