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,39 @@
1
+ /**
2
+ * Anime.js - easings - ESM
3
+ * @version v4.2.0
4
+ * @license MIT
5
+ * @copyright 2025 - Julian Garnier
6
+ */
7
+
8
+ import { clamp } from '../core/helpers.js';
9
+ import { linear } from './linear.js';
10
+
11
+ /**
12
+ * @import {
13
+ * EasingFunction,
14
+ * } from '../types/index.js'
15
+ */
16
+
17
+ /**
18
+ * Generate random steps
19
+ * @param {Number} [length] - The number of steps
20
+ * @param {Number} [randomness] - How strong the randomness is
21
+ * @return {EasingFunction}
22
+ */
23
+ const irregular = (length = 10, randomness = 1) => {
24
+ const values = [0];
25
+ const total = length - 1;
26
+ for (let i = 1; i < total; i++) {
27
+ const previousValue = values[i - 1];
28
+ const spacing = i / total;
29
+ const segmentEnd = (i + 1) / total;
30
+ const randomVariation = spacing + (segmentEnd - spacing) * Math.random();
31
+ // Mix the even spacing and random variation based on the randomness parameter
32
+ const randomValue = spacing * (1 - randomness) + randomVariation * randomness;
33
+ values.push(clamp(randomValue, previousValue, 1));
34
+ }
35
+ values.push(1);
36
+ return linear(...values);
37
+ };
38
+
39
+ export { irregular };
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Anime.js - easings - CJS
3
+ * @version v4.2.0
4
+ * @license MIT
5
+ * @copyright 2025 - Julian Garnier
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ var helpers = require('../core/helpers.cjs');
11
+ var none = require('./none.cjs');
12
+
13
+ /**
14
+ * @import {
15
+ * EasingFunction,
16
+ * } from '../types/index.js'
17
+ */
18
+
19
+ /**
20
+ * Without parameters, the linear function creates a non-eased transition.
21
+ * Parameters, if used, creates a piecewise linear easing by interpolating linearly between the specified points.
22
+ *
23
+ * @param {...(String|Number)} args - Points
24
+ * @return {EasingFunction}
25
+ */
26
+ const linear = (...args) => {
27
+ const argsLength = args.length;
28
+ if (!argsLength) return none.none;
29
+ const totalPoints = argsLength - 1;
30
+ const firstArg = args[0];
31
+ const lastArg = args[totalPoints];
32
+ const xPoints = [0];
33
+ const yPoints = [helpers.parseNumber(firstArg)];
34
+ for (let i = 1; i < totalPoints; i++) {
35
+ const arg = args[i];
36
+ const splitValue = helpers.isStr(arg) ?
37
+ /** @type {String} */(arg).trim().split(' ') :
38
+ [arg];
39
+ const value = splitValue[0];
40
+ const percent = splitValue[1];
41
+ xPoints.push(!helpers.isUnd(percent) ? helpers.parseNumber(percent) / 100 : i / totalPoints);
42
+ yPoints.push(helpers.parseNumber(value));
43
+ }
44
+ yPoints.push(helpers.parseNumber(lastArg));
45
+ xPoints.push(1);
46
+ return function easeLinear(t) {
47
+ for (let i = 1, l = xPoints.length; i < l; i++) {
48
+ const currentX = xPoints[i];
49
+ if (t <= currentX) {
50
+ const prevX = xPoints[i - 1];
51
+ const prevY = yPoints[i - 1];
52
+ return prevY + (yPoints[i] - prevY) * (t - prevX) / (currentX - prevX);
53
+ }
54
+ }
55
+ return yPoints[yPoints.length - 1];
56
+ }
57
+ };
58
+
59
+ exports.linear = linear;
@@ -0,0 +1,2 @@
1
+ export function linear(...args: (string | number)[]): EasingFunction;
2
+ import type { EasingFunction } from '../types/index.js';
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Anime.js - easings - ESM
3
+ * @version v4.2.0
4
+ * @license MIT
5
+ * @copyright 2025 - Julian Garnier
6
+ */
7
+
8
+ import { isStr, parseNumber, isUnd } from '../core/helpers.js';
9
+ import { none } from './none.js';
10
+
11
+ /**
12
+ * @import {
13
+ * EasingFunction,
14
+ * } from '../types/index.js'
15
+ */
16
+
17
+ /**
18
+ * Without parameters, the linear function creates a non-eased transition.
19
+ * Parameters, if used, creates a piecewise linear easing by interpolating linearly between the specified points.
20
+ *
21
+ * @param {...(String|Number)} args - Points
22
+ * @return {EasingFunction}
23
+ */
24
+ const linear = (...args) => {
25
+ const argsLength = args.length;
26
+ if (!argsLength) return none;
27
+ const totalPoints = argsLength - 1;
28
+ const firstArg = args[0];
29
+ const lastArg = args[totalPoints];
30
+ const xPoints = [0];
31
+ const yPoints = [parseNumber(firstArg)];
32
+ for (let i = 1; i < totalPoints; i++) {
33
+ const arg = args[i];
34
+ const splitValue = isStr(arg) ?
35
+ /** @type {String} */(arg).trim().split(' ') :
36
+ [arg];
37
+ const value = splitValue[0];
38
+ const percent = splitValue[1];
39
+ xPoints.push(!isUnd(percent) ? parseNumber(percent) / 100 : i / totalPoints);
40
+ yPoints.push(parseNumber(value));
41
+ }
42
+ yPoints.push(parseNumber(lastArg));
43
+ xPoints.push(1);
44
+ return function easeLinear(t) {
45
+ for (let i = 1, l = xPoints.length; i < l; i++) {
46
+ const currentX = xPoints[i];
47
+ if (t <= currentX) {
48
+ const prevX = xPoints[i - 1];
49
+ const prevY = yPoints[i - 1];
50
+ return prevY + (yPoints[i] - prevY) * (t - prevX) / (currentX - prevX);
51
+ }
52
+ }
53
+ return yPoints[yPoints.length - 1];
54
+ }
55
+ };
56
+
57
+ export { linear };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Anime.js - easings - CJS
3
+ * @version v4.2.0
4
+ * @license MIT
5
+ * @copyright 2025 - Julian Garnier
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ /**
11
+ * @import {
12
+ * EasingFunction,
13
+ * } from '../types/index.js'
14
+ */
15
+
16
+ /** @type {EasingFunction} */
17
+ const none = t => t;
18
+
19
+ exports.none = none;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @import {
3
+ * EasingFunction,
4
+ * } from '../types/index.js'
5
+ */
6
+ /** @type {EasingFunction} */
7
+ export const none: EasingFunction;
8
+ import type { EasingFunction } from '../types/index.js';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Anime.js - easings - ESM
3
+ * @version v4.2.0
4
+ * @license MIT
5
+ * @copyright 2025 - Julian Garnier
6
+ */
7
+
8
+ /**
9
+ * @import {
10
+ * EasingFunction,
11
+ * } from '../types/index.js'
12
+ */
13
+
14
+ /** @type {EasingFunction} */
15
+ const none = t => t;
16
+
17
+ export { none };
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Anime.js - easings - CJS
3
+ * @version v4.2.0
4
+ * @license MIT
5
+ * @copyright 2025 - Julian Garnier
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ var helpers = require('../core/helpers.cjs');
11
+ var none = require('./none.cjs');
12
+
13
+ /**
14
+ * @import {
15
+ * EasingFunction,
16
+ * PowerEasing,
17
+ * EasingFunctionWithParams,
18
+ * } from '../types/index.js'
19
+ */
20
+
21
+ /** @type {PowerEasing} */
22
+ const easeInPower = (p = 1.68) => t => helpers.pow(t, +p);
23
+
24
+ /**
25
+ * @callback EaseType
26
+ * @param {EasingFunction} Ease
27
+ * @return {EasingFunction}
28
+ */
29
+
30
+ /** @type {Record<String, EaseType>} */
31
+ const easeTypes = {
32
+ in: easeIn => t => easeIn(t),
33
+ out: easeIn => t => 1 - easeIn(1 - t),
34
+ inOut: easeIn => t => t < .5 ? easeIn(t * 2) / 2 : 1 - easeIn(t * -2 + 2) / 2,
35
+ outIn: easeIn => t => t < .5 ? (1 - easeIn(1 - t * 2)) / 2 : (easeIn(t * 2 - 1) + 1) / 2,
36
+ };
37
+
38
+ /**
39
+ * @param {String} string
40
+ * @param {Record<String, EasingFunctionWithParams|EasingFunction>} easesFunctions
41
+ * @param {Object} easesLookups
42
+ * @return {EasingFunction}
43
+ */
44
+ const parseEaseString = (string, easesFunctions, easesLookups) => {
45
+ if (easesLookups[string]) return easesLookups[string];
46
+ if (string.indexOf('(') <= -1) {
47
+ const hasParams = easeTypes[string] || string.includes('Back') || string.includes('Elastic');
48
+ const parsedFn = /** @type {EasingFunction} */(hasParams ? /** @type {EasingFunctionWithParams} */(easesFunctions[string])() : easesFunctions[string]);
49
+ return parsedFn ? easesLookups[string] = parsedFn : none.none;
50
+ } else {
51
+ const split = string.slice(0, -1).split('(');
52
+ const parsedFn = /** @type {EasingFunctionWithParams} */(easesFunctions[split[0]]);
53
+ return parsedFn ? easesLookups[string] = parsedFn(...split[1].split(',')) : none.none;
54
+ }
55
+ };
56
+
57
+ exports.easeInPower = easeInPower;
58
+ exports.easeTypes = easeTypes;
59
+ exports.parseEaseString = parseEaseString;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @import {
3
+ * EasingFunction,
4
+ * PowerEasing,
5
+ * EasingFunctionWithParams,
6
+ * } from '../types/index.js'
7
+ */
8
+ /** @type {PowerEasing} */
9
+ export const easeInPower: PowerEasing;
10
+ /**
11
+ * @callback EaseType
12
+ * @param {EasingFunction} Ease
13
+ * @return {EasingFunction}
14
+ */
15
+ /** @type {Record<String, EaseType>} */
16
+ export const easeTypes: Record<string, EaseType>;
17
+ export function parseEaseString(string: string, easesFunctions: Record<string, EasingFunctionWithParams | EasingFunction>, easesLookups: any): EasingFunction;
18
+ export type EaseType = (Ease: EasingFunction) => EasingFunction;
19
+ import type { PowerEasing } from '../types/index.js';
20
+ import type { EasingFunctionWithParams } from '../types/index.js';
21
+ import type { EasingFunction } from '../types/index.js';
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Anime.js - easings - ESM
3
+ * @version v4.2.0
4
+ * @license MIT
5
+ * @copyright 2025 - Julian Garnier
6
+ */
7
+
8
+ import { pow } from '../core/helpers.js';
9
+ import { none } from './none.js';
10
+
11
+ /**
12
+ * @import {
13
+ * EasingFunction,
14
+ * PowerEasing,
15
+ * EasingFunctionWithParams,
16
+ * } from '../types/index.js'
17
+ */
18
+
19
+ /** @type {PowerEasing} */
20
+ const easeInPower = (p = 1.68) => t => pow(t, +p);
21
+
22
+ /**
23
+ * @callback EaseType
24
+ * @param {EasingFunction} Ease
25
+ * @return {EasingFunction}
26
+ */
27
+
28
+ /** @type {Record<String, EaseType>} */
29
+ const easeTypes = {
30
+ in: easeIn => t => easeIn(t),
31
+ out: easeIn => t => 1 - easeIn(1 - t),
32
+ inOut: easeIn => t => t < .5 ? easeIn(t * 2) / 2 : 1 - easeIn(t * -2 + 2) / 2,
33
+ outIn: easeIn => t => t < .5 ? (1 - easeIn(1 - t * 2)) / 2 : (easeIn(t * 2 - 1) + 1) / 2,
34
+ };
35
+
36
+ /**
37
+ * @param {String} string
38
+ * @param {Record<String, EasingFunctionWithParams|EasingFunction>} easesFunctions
39
+ * @param {Object} easesLookups
40
+ * @return {EasingFunction}
41
+ */
42
+ const parseEaseString = (string, easesFunctions, easesLookups) => {
43
+ if (easesLookups[string]) return easesLookups[string];
44
+ if (string.indexOf('(') <= -1) {
45
+ const hasParams = easeTypes[string] || string.includes('Back') || string.includes('Elastic');
46
+ const parsedFn = /** @type {EasingFunction} */(hasParams ? /** @type {EasingFunctionWithParams} */(easesFunctions[string])() : easesFunctions[string]);
47
+ return parsedFn ? easesLookups[string] = parsedFn : none;
48
+ } else {
49
+ const split = string.slice(0, -1).split('(');
50
+ const parsedFn = /** @type {EasingFunctionWithParams} */(easesFunctions[split[0]]);
51
+ return parsedFn ? easesLookups[string] = parsedFn(...split[1].split(',')) : none;
52
+ }
53
+ };
54
+
55
+ export { easeInPower, easeTypes, parseEaseString };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Anime.js - easings - CJS
3
+ * @version v4.2.0
4
+ * @license MIT
5
+ * @copyright 2025 - Julian Garnier
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ var helpers = require('../core/helpers.cjs');
11
+
12
+ /**
13
+ * @import {
14
+ * EasingFunction,
15
+ * } from '../types/index.js'
16
+ */
17
+
18
+ /**
19
+ * Steps ease implementation https://developer.mozilla.org/fr/docs/Web/CSS/transition-timing-function
20
+ * Only covers 'end' and 'start' jumpterms
21
+ * @param {Number} steps
22
+ * @param {Boolean} [fromStart]
23
+ * @return {EasingFunction}
24
+ */
25
+ const steps = (steps = 10, fromStart) => {
26
+ const roundMethod = fromStart ? helpers.ceil : helpers.floor;
27
+ return t => roundMethod(helpers.clamp(t, 0, 1) * steps) * (1 / steps);
28
+ };
29
+
30
+ exports.steps = steps;
@@ -0,0 +1,2 @@
1
+ export function steps(steps?: number, fromStart?: boolean): EasingFunction;
2
+ import type { EasingFunction } from '../types/index.js';
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Anime.js - easings - ESM
3
+ * @version v4.2.0
4
+ * @license MIT
5
+ * @copyright 2025 - Julian Garnier
6
+ */
7
+
8
+ import { ceil, floor, clamp } from '../core/helpers.js';
9
+
10
+ /**
11
+ * @import {
12
+ * EasingFunction,
13
+ * } from '../types/index.js'
14
+ */
15
+
16
+ /**
17
+ * Steps ease implementation https://developer.mozilla.org/fr/docs/Web/CSS/transition-timing-function
18
+ * Only covers 'end' and 'start' jumpterms
19
+ * @param {Number} steps
20
+ * @param {Boolean} [fromStart]
21
+ * @return {EasingFunction}
22
+ */
23
+ const steps = (steps = 10, fromStart) => {
24
+ const roundMethod = fromStart ? ceil : floor;
25
+ return t => roundMethod(clamp(t, 0, 1) * steps) * (1 / steps);
26
+ };
27
+
28
+ export { steps };
@@ -0,0 +1,168 @@
1
+ /**
2
+ * Anime.js - engine - 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 clock = require('../core/clock.cjs');
14
+ var render = require('../core/render.cjs');
15
+ var additive = require('../animation/additive.cjs');
16
+
17
+ /**
18
+ * @import {
19
+ * DefaultsParams,
20
+ * } from '../types/index.js'
21
+ */
22
+
23
+ /**
24
+ * @import {
25
+ * Tickable,
26
+ * } from '../types/index.js'
27
+ */
28
+
29
+ const engineTickMethod = /*#__PURE__*/ (() => consts.isBrowser ? requestAnimationFrame : setImmediate)();
30
+ const engineCancelMethod = /*#__PURE__*/ (() => consts.isBrowser ? cancelAnimationFrame : clearImmediate)();
31
+
32
+ class Engine extends clock.Clock {
33
+
34
+ /** @param {Number} [initTime] */
35
+ constructor(initTime) {
36
+ super(initTime);
37
+ this.useDefaultMainLoop = true;
38
+ this.pauseOnDocumentHidden = true;
39
+ /** @type {DefaultsParams} */
40
+ this.defaults = globals.defaults;
41
+ // this.paused = isBrowser && doc.hidden ? true : false;
42
+ this.paused = true;
43
+ /** @type {Number|NodeJS.Immediate} */
44
+ this.reqId = 0;
45
+ }
46
+
47
+ update() {
48
+ const time = this._currentTime = helpers.now();
49
+ if (this.requestTick(time)) {
50
+ this.computeDeltaTime(time);
51
+ const engineSpeed = this._speed;
52
+ const engineFps = this._fps;
53
+ let activeTickable = /** @type {Tickable} */(this._head);
54
+ while (activeTickable) {
55
+ const nextTickable = activeTickable._next;
56
+ if (!activeTickable.paused) {
57
+ render.tick(
58
+ activeTickable,
59
+ (time - activeTickable._startTime) * activeTickable._speed * engineSpeed,
60
+ 0, // !muteCallbacks
61
+ 0, // !internalRender
62
+ activeTickable._fps < engineFps ? activeTickable.requestTick(time) : consts.tickModes.AUTO
63
+ );
64
+ } else {
65
+ helpers.removeChild(this, activeTickable);
66
+ this._hasChildren = !!this._tail;
67
+ activeTickable._running = false;
68
+ if (activeTickable.completed && !activeTickable._cancelled) {
69
+ activeTickable.cancel();
70
+ }
71
+ }
72
+ activeTickable = nextTickable;
73
+ }
74
+ additive.additive.update();
75
+ }
76
+ }
77
+
78
+ wake() {
79
+ if (this.useDefaultMainLoop && !this.reqId) {
80
+ // Imediatly request a tick to update engine._elapsedTime and get accurate offsetPosition calculation in timer.js
81
+ this.requestTick(helpers.now());
82
+ this.reqId = engineTickMethod(tickEngine);
83
+ }
84
+ return this;
85
+ }
86
+
87
+ pause() {
88
+ if (!this.reqId) return;
89
+ this.paused = true;
90
+ return killEngine();
91
+ }
92
+
93
+ resume() {
94
+ if (!this.paused) return;
95
+ this.paused = false;
96
+ helpers.forEachChildren(this, (/** @type {Tickable} */child) => child.resetTime());
97
+ return this.wake();
98
+ }
99
+
100
+ // Getter and setter for speed
101
+ get speed() {
102
+ return this._speed * (globals.globals.timeScale === 1 ? 1 : consts.K);
103
+ }
104
+
105
+ set speed(playbackRate) {
106
+ this._speed = playbackRate * globals.globals.timeScale;
107
+ helpers.forEachChildren(this, (/** @type {Tickable} */child) => child.speed = child._speed);
108
+ }
109
+
110
+ // Getter and setter for timeUnit
111
+ get timeUnit() {
112
+ return globals.globals.timeScale === 1 ? 'ms' : 's';
113
+ }
114
+
115
+ set timeUnit(unit) {
116
+ const secondsScale = 0.001;
117
+ const isSecond = unit === 's';
118
+ const newScale = isSecond ? secondsScale : 1;
119
+ if (globals.globals.timeScale !== newScale) {
120
+ globals.globals.timeScale = newScale;
121
+ globals.globals.tickThreshold = 200 * newScale;
122
+ const scaleFactor = isSecond ? secondsScale : consts.K;
123
+ /** @type {Number} */
124
+ (this.defaults.duration) *= scaleFactor;
125
+ this._speed *= scaleFactor;
126
+ }
127
+ }
128
+
129
+ // Getter and setter for precision
130
+ get precision() {
131
+ return globals.globals.precision;
132
+ }
133
+
134
+ set precision(precision) {
135
+ globals.globals.precision = precision;
136
+ }
137
+
138
+ }
139
+
140
+ const engine = /*#__PURE__*/(() => {
141
+ const engine = new Engine(helpers.now());
142
+ if (consts.isBrowser) {
143
+ globals.globalVersions.engine = engine;
144
+ consts.doc.addEventListener('visibilitychange', () => {
145
+ if (!engine.pauseOnDocumentHidden) return;
146
+ consts.doc.hidden ? engine.pause() : engine.resume();
147
+ });
148
+ }
149
+ return engine;
150
+ })();
151
+
152
+
153
+ const tickEngine = () => {
154
+ if (engine._head) {
155
+ engine.reqId = engineTickMethod(tickEngine);
156
+ engine.update();
157
+ } else {
158
+ engine.reqId = 0;
159
+ }
160
+ };
161
+
162
+ const killEngine = () => {
163
+ engineCancelMethod(/** @type {NodeJS.Immediate & Number} */(engine.reqId));
164
+ engine.reqId = 0;
165
+ return engine;
166
+ };
167
+
168
+ exports.engine = engine;
@@ -0,0 +1,21 @@
1
+ export const engine: Engine;
2
+ declare class Engine extends Clock {
3
+ useDefaultMainLoop: boolean;
4
+ pauseOnDocumentHidden: boolean;
5
+ /** @type {DefaultsParams} */
6
+ defaults: DefaultsParams;
7
+ paused: boolean;
8
+ /** @type {Number|NodeJS.Immediate} */
9
+ reqId: number | NodeJS.Immediate;
10
+ update(): void;
11
+ wake(): this;
12
+ pause(): Engine;
13
+ resume(): this;
14
+ set timeUnit(unit: "ms" | "s");
15
+ get timeUnit(): "ms" | "s";
16
+ set precision(precision: number);
17
+ get precision(): number;
18
+ }
19
+ import { Clock } from '../core/clock.js';
20
+ import type { DefaultsParams } from '../types/index.js';
21
+ export {};