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,117 @@
1
+ /**
2
+ * Anime.js - svg - ESM
3
+ * @version v4.2.0
4
+ * @license MIT
5
+ * @copyright 2025 - Julian Garnier
6
+ */
7
+
8
+ import { proxyTargetSymbol, K } from '../core/consts.js';
9
+ import { isFnc, sqrt } from '../core/helpers.js';
10
+ import { parseTargets } from '../core/targets.js';
11
+
12
+ /**
13
+ * @import {
14
+ * TargetsParam,
15
+ * DrawableSVGGeometry,
16
+ * } from '../types/index.js'
17
+ */
18
+
19
+ /**
20
+ * @param {SVGGeometryElement} [$el]
21
+ * @return {Number}
22
+ */
23
+ const getScaleFactor = $el => {
24
+ let scaleFactor = 1;
25
+ if ($el && $el.getCTM) {
26
+ const ctm = $el.getCTM();
27
+ if (ctm) {
28
+ const scaleX = sqrt(ctm.a * ctm.a + ctm.b * ctm.b);
29
+ const scaleY = sqrt(ctm.c * ctm.c + ctm.d * ctm.d);
30
+ scaleFactor = (scaleX + scaleY) / 2;
31
+ }
32
+ }
33
+ return scaleFactor;
34
+ };
35
+
36
+ /**
37
+ * Creates a proxy that wraps an SVGGeometryElement and adds drawing functionality.
38
+ * @param {SVGGeometryElement} $el - The SVG element to transform into a drawable
39
+ * @param {number} start - Starting position (0-1)
40
+ * @param {number} end - Ending position (0-1)
41
+ * @return {DrawableSVGGeometry} - Returns a proxy that preserves the original element's type with additional 'draw' attribute functionality
42
+ */
43
+ const createDrawableProxy = ($el, start, end) => {
44
+ const pathLength = K;
45
+ const computedStyles = getComputedStyle($el);
46
+ const strokeLineCap = computedStyles.strokeLinecap;
47
+ // @ts-ignore
48
+ const $scalled = computedStyles.vectorEffect === 'non-scaling-stroke' ? $el : null;
49
+ let currentCap = strokeLineCap;
50
+
51
+ const proxy = new Proxy($el, {
52
+ get(target, property) {
53
+ const value = target[property];
54
+ if (property === proxyTargetSymbol) return target;
55
+ if (property === 'setAttribute') {
56
+ return (...args) => {
57
+ if (args[0] === 'draw') {
58
+ const value = args[1];
59
+ const values = value.split(' ');
60
+ const v1 = +values[0];
61
+ const v2 = +values[1];
62
+ // TOTO: Benchmark if performing two slices is more performant than one split
63
+ // const spaceIndex = value.indexOf(' ');
64
+ // const v1 = round(+value.slice(0, spaceIndex), precision);
65
+ // const v2 = round(+value.slice(spaceIndex + 1), precision);
66
+ const scaleFactor = getScaleFactor($scalled);
67
+ const os = v1 * -pathLength * scaleFactor;
68
+ const d1 = (v2 * pathLength * scaleFactor) + os;
69
+ const d2 = (pathLength * scaleFactor +
70
+ ((v1 === 0 && v2 === 1) || (v1 === 1 && v2 === 0) ? 0 : 10 * scaleFactor) - d1);
71
+ if (strokeLineCap !== 'butt') {
72
+ const newCap = v1 === v2 ? 'butt' : strokeLineCap;
73
+ if (currentCap !== newCap) {
74
+ target.style.strokeLinecap = `${newCap}`;
75
+ currentCap = newCap;
76
+ }
77
+ }
78
+ target.setAttribute('stroke-dashoffset', `${os}`);
79
+ target.setAttribute('stroke-dasharray', `${d1} ${d2}`);
80
+ }
81
+ return Reflect.apply(value, target, args);
82
+ };
83
+ }
84
+
85
+ if (isFnc(value)) {
86
+ return (...args) => Reflect.apply(value, target, args);
87
+ } else {
88
+ return value;
89
+ }
90
+ }
91
+ });
92
+
93
+ if ($el.getAttribute('pathLength') !== `${pathLength}`) {
94
+ $el.setAttribute('pathLength', `${pathLength}`);
95
+ proxy.setAttribute('draw', `${start} ${end}`);
96
+ }
97
+
98
+ return /** @type {DrawableSVGGeometry} */(proxy);
99
+ };
100
+
101
+ /**
102
+ * Creates drawable proxies for multiple SVG elements.
103
+ * @param {TargetsParam} selector - CSS selector, SVG element, or array of elements and selectors
104
+ * @param {number} [start=0] - Starting position (0-1)
105
+ * @param {number} [end=0] - Ending position (0-1)
106
+ * @return {Array<DrawableSVGGeometry>} - Array of proxied elements with drawing functionality
107
+ */
108
+ const createDrawable = (selector, start = 0, end = 0) => {
109
+ const els = parseTargets(selector);
110
+ return els.map($el => createDrawableProxy(
111
+ /** @type {SVGGeometryElement} */($el),
112
+ start,
113
+ end
114
+ ));
115
+ };
116
+
117
+ export { createDrawable };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Anime.js - svg - 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 targets = require('../core/targets.cjs');
12
+
13
+ /**
14
+ * @import {
15
+ * TargetsParam,
16
+ * } from '../types/index.js'
17
+ */
18
+
19
+ /**
20
+ * @param {TargetsParam} path
21
+ * @return {SVGGeometryElement|void}
22
+ */
23
+ const getPath = path => {
24
+ const parsedTargets = targets.parseTargets(path);
25
+ const $parsedSvg = /** @type {SVGGeometryElement} */(parsedTargets[0]);
26
+ if (!$parsedSvg || !helpers.isSvg($parsedSvg)) return console.warn(`${path} is not a valid SVGGeometryElement`);
27
+ return $parsedSvg;
28
+ };
29
+
30
+ exports.getPath = getPath;
@@ -0,0 +1,2 @@
1
+ export function getPath(path: TargetsParam): SVGGeometryElement | void;
2
+ import type { TargetsParam } from '../types/index.js';
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Anime.js - svg - ESM
3
+ * @version v4.2.0
4
+ * @license MIT
5
+ * @copyright 2025 - Julian Garnier
6
+ */
7
+
8
+ import { isSvg } from '../core/helpers.js';
9
+ import { parseTargets } from '../core/targets.js';
10
+
11
+ /**
12
+ * @import {
13
+ * TargetsParam,
14
+ * } from '../types/index.js'
15
+ */
16
+
17
+ /**
18
+ * @param {TargetsParam} path
19
+ * @return {SVGGeometryElement|void}
20
+ */
21
+ const getPath = path => {
22
+ const parsedTargets = parseTargets(path);
23
+ const $parsedSvg = /** @type {SVGGeometryElement} */(parsedTargets[0]);
24
+ if (!$parsedSvg || !isSvg($parsedSvg)) return console.warn(`${path} is not a valid SVGGeometryElement`);
25
+ return $parsedSvg;
26
+ };
27
+
28
+ export { getPath };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Anime.js - svg - CJS
3
+ * @version v4.2.0
4
+ * @license MIT
5
+ * @copyright 2025 - Julian Garnier
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ var motionpath = require('./motionpath.cjs');
11
+ var drawable = require('./drawable.cjs');
12
+ var morphto = require('./morphto.cjs');
13
+
14
+
15
+
16
+ exports.createMotionPath = motionpath.createMotionPath;
17
+ exports.createDrawable = drawable.createDrawable;
18
+ exports.morphTo = morphto.morphTo;
@@ -0,0 +1,3 @@
1
+ export { createMotionPath } from "./motionpath.js";
2
+ export { createDrawable } from "./drawable.js";
3
+ export { morphTo } from "./morphto.js";
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Anime.js - svg - ESM
3
+ * @version v4.2.0
4
+ * @license MIT
5
+ * @copyright 2025 - Julian Garnier
6
+ */
7
+
8
+ export { createMotionPath } from './motionpath.js';
9
+ export { createDrawable } from './drawable.js';
10
+ export { morphTo } from './morphto.js';
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Anime.js - svg - 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$1 = require('../core/helpers.cjs');
12
+ var helpers = require('./helpers.cjs');
13
+
14
+ /**
15
+ * @import {
16
+ * TargetsParam,
17
+ * FunctionValue
18
+ * } from '../types/index.js'
19
+ */
20
+
21
+ /**
22
+ * @param {TargetsParam} path2
23
+ * @param {Number} [precision]
24
+ * @return {FunctionValue}
25
+ */
26
+ const morphTo = (path2, precision = .33) => ($path1) => {
27
+ const $path2 = /** @type {SVGGeometryElement} */(helpers.getPath(path2));
28
+ if (!$path2) return;
29
+ const isPath = $path1.tagName === 'path';
30
+ const separator = isPath ? ' ' : ',';
31
+ const previousPoints = $path1[consts.morphPointsSymbol];
32
+ if (previousPoints) $path1.setAttribute(isPath ? 'd' : 'points', previousPoints);
33
+
34
+ let v1 = '', v2 = '';
35
+
36
+ if (!precision) {
37
+ v1 = $path1.getAttribute(isPath ? 'd' : 'points');
38
+ v2 = $path2.getAttribute(isPath ? 'd' : 'points');
39
+ } else {
40
+ const length1 = /** @type {SVGGeometryElement} */($path1).getTotalLength();
41
+ const length2 = $path2.getTotalLength();
42
+ const maxPoints = Math.max(Math.ceil(length1 * precision), Math.ceil(length2 * precision));
43
+ for (let i = 0; i < maxPoints; i++) {
44
+ const t = i / (maxPoints - 1);
45
+ const pointOnPath1 = /** @type {SVGGeometryElement} */($path1).getPointAtLength(length1 * t);
46
+ const pointOnPath2 = $path2.getPointAtLength(length2 * t);
47
+ const prefix = isPath ? (i === 0 ? 'M' : 'L') : '';
48
+ v1 += prefix + helpers$1.round(pointOnPath1.x, 3) + separator + pointOnPath1.y + ' ';
49
+ v2 += prefix + helpers$1.round(pointOnPath2.x, 3) + separator + pointOnPath2.y + ' ';
50
+ }
51
+ }
52
+
53
+ $path1[consts.morphPointsSymbol] = v2;
54
+
55
+ return [v1, v2];
56
+ };
57
+
58
+ exports.morphTo = morphTo;
@@ -0,0 +1,3 @@
1
+ export function morphTo(path2: TargetsParam, precision?: number): FunctionValue;
2
+ import type { TargetsParam } from '../types/index.js';
3
+ import type { FunctionValue } from '../types/index.js';
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Anime.js - svg - ESM
3
+ * @version v4.2.0
4
+ * @license MIT
5
+ * @copyright 2025 - Julian Garnier
6
+ */
7
+
8
+ import { morphPointsSymbol } from '../core/consts.js';
9
+ import { round } from '../core/helpers.js';
10
+ import { getPath } from './helpers.js';
11
+
12
+ /**
13
+ * @import {
14
+ * TargetsParam,
15
+ * FunctionValue
16
+ * } from '../types/index.js'
17
+ */
18
+
19
+ /**
20
+ * @param {TargetsParam} path2
21
+ * @param {Number} [precision]
22
+ * @return {FunctionValue}
23
+ */
24
+ const morphTo = (path2, precision = .33) => ($path1) => {
25
+ const $path2 = /** @type {SVGGeometryElement} */(getPath(path2));
26
+ if (!$path2) return;
27
+ const isPath = $path1.tagName === 'path';
28
+ const separator = isPath ? ' ' : ',';
29
+ const previousPoints = $path1[morphPointsSymbol];
30
+ if (previousPoints) $path1.setAttribute(isPath ? 'd' : 'points', previousPoints);
31
+
32
+ let v1 = '', v2 = '';
33
+
34
+ if (!precision) {
35
+ v1 = $path1.getAttribute(isPath ? 'd' : 'points');
36
+ v2 = $path2.getAttribute(isPath ? 'd' : 'points');
37
+ } else {
38
+ const length1 = /** @type {SVGGeometryElement} */($path1).getTotalLength();
39
+ const length2 = $path2.getTotalLength();
40
+ const maxPoints = Math.max(Math.ceil(length1 * precision), Math.ceil(length2 * precision));
41
+ for (let i = 0; i < maxPoints; i++) {
42
+ const t = i / (maxPoints - 1);
43
+ const pointOnPath1 = /** @type {SVGGeometryElement} */($path1).getPointAtLength(length1 * t);
44
+ const pointOnPath2 = $path2.getPointAtLength(length2 * t);
45
+ const prefix = isPath ? (i === 0 ? 'M' : 'L') : '';
46
+ v1 += prefix + round(pointOnPath1.x, 3) + separator + pointOnPath1.y + ' ';
47
+ v2 += prefix + round(pointOnPath2.x, 3) + separator + pointOnPath2.y + ' ';
48
+ }
49
+ }
50
+
51
+ $path1[morphPointsSymbol] = v2;
52
+
53
+ return [v1, v2];
54
+ };
55
+
56
+ export { morphTo };
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Anime.js - svg - 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$1 = require('../core/helpers.cjs');
12
+ var helpers = require('./helpers.cjs');
13
+
14
+ /**
15
+ * @import {
16
+ * TargetsParam,
17
+ * FunctionValue,
18
+ * TweenObjectValue,
19
+ * TweenModifier,
20
+ * } from '../types/index.js'
21
+ */
22
+
23
+ // Motion path animation
24
+
25
+ /**
26
+ * @param {SVGGeometryElement} $path
27
+ * @param {Number} progress
28
+ * @param {Number}lookup
29
+ * @return {DOMPoint}
30
+ */
31
+ const getPathPoint = ($path, progress, lookup = 0) => {
32
+ return $path.getPointAtLength(progress + lookup >= 1 ? progress + lookup : 0);
33
+ };
34
+
35
+ /**
36
+ * @param {SVGGeometryElement} $path
37
+ * @param {String} pathProperty
38
+ * @return {FunctionValue}
39
+ */
40
+ const getPathProgess = ($path, pathProperty) => {
41
+ return $el => {
42
+ const totalLength = +($path.getTotalLength());
43
+ const inSvg = $el[consts.isSvgSymbol];
44
+ const ctm = $path.getCTM();
45
+ /** @type {TweenObjectValue} */
46
+ return {
47
+ from: 0,
48
+ to: totalLength,
49
+ /** @type {TweenModifier} */
50
+ modifier: progress => {
51
+ if (pathProperty === 'a') {
52
+ const p0 = getPathPoint($path, progress, -1);
53
+ const p1 = getPathPoint($path, progress, 1);
54
+ return helpers$1.atan2(p1.y - p0.y, p1.x - p0.x) * 180 / helpers$1.PI;
55
+ } else {
56
+ const p = getPathPoint($path, progress, 0);
57
+ return pathProperty === 'x' ?
58
+ inSvg || !ctm ? p.x : p.x * ctm.a + p.y * ctm.c + ctm.e :
59
+ inSvg || !ctm ? p.y : p.x * ctm.b + p.y * ctm.d + ctm.f
60
+ }
61
+ }
62
+ }
63
+ }
64
+ };
65
+
66
+ /**
67
+ * @param {TargetsParam} path
68
+ */
69
+ const createMotionPath = path => {
70
+ const $path = helpers.getPath(path);
71
+ if (!$path) return;
72
+ return {
73
+ translateX: getPathProgess($path, 'x'),
74
+ translateY: getPathProgess($path, 'y'),
75
+ rotate: getPathProgess($path, 'a'),
76
+ }
77
+ };
78
+
79
+ exports.createMotionPath = createMotionPath;
@@ -0,0 +1,7 @@
1
+ export function createMotionPath(path: TargetsParam): {
2
+ translateX: FunctionValue;
3
+ translateY: FunctionValue;
4
+ rotate: FunctionValue;
5
+ };
6
+ import type { TargetsParam } from '../types/index.js';
7
+ import type { FunctionValue } from '../types/index.js';
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Anime.js - svg - ESM
3
+ * @version v4.2.0
4
+ * @license MIT
5
+ * @copyright 2025 - Julian Garnier
6
+ */
7
+
8
+ import { isSvgSymbol } from '../core/consts.js';
9
+ import { atan2, PI } from '../core/helpers.js';
10
+ import { getPath } from './helpers.js';
11
+
12
+ /**
13
+ * @import {
14
+ * TargetsParam,
15
+ * FunctionValue,
16
+ * TweenObjectValue,
17
+ * TweenModifier,
18
+ * } from '../types/index.js'
19
+ */
20
+
21
+ // Motion path animation
22
+
23
+ /**
24
+ * @param {SVGGeometryElement} $path
25
+ * @param {Number} progress
26
+ * @param {Number}lookup
27
+ * @return {DOMPoint}
28
+ */
29
+ const getPathPoint = ($path, progress, lookup = 0) => {
30
+ return $path.getPointAtLength(progress + lookup >= 1 ? progress + lookup : 0);
31
+ };
32
+
33
+ /**
34
+ * @param {SVGGeometryElement} $path
35
+ * @param {String} pathProperty
36
+ * @return {FunctionValue}
37
+ */
38
+ const getPathProgess = ($path, pathProperty) => {
39
+ return $el => {
40
+ const totalLength = +($path.getTotalLength());
41
+ const inSvg = $el[isSvgSymbol];
42
+ const ctm = $path.getCTM();
43
+ /** @type {TweenObjectValue} */
44
+ return {
45
+ from: 0,
46
+ to: totalLength,
47
+ /** @type {TweenModifier} */
48
+ modifier: progress => {
49
+ if (pathProperty === 'a') {
50
+ const p0 = getPathPoint($path, progress, -1);
51
+ const p1 = getPathPoint($path, progress, 1);
52
+ return atan2(p1.y - p0.y, p1.x - p0.x) * 180 / PI;
53
+ } else {
54
+ const p = getPathPoint($path, progress, 0);
55
+ return pathProperty === 'x' ?
56
+ inSvg || !ctm ? p.x : p.x * ctm.a + p.y * ctm.c + ctm.e :
57
+ inSvg || !ctm ? p.y : p.x * ctm.b + p.y * ctm.d + ctm.f
58
+ }
59
+ }
60
+ }
61
+ }
62
+ };
63
+
64
+ /**
65
+ * @param {TargetsParam} path
66
+ */
67
+ const createMotionPath = path => {
68
+ const $path = getPath(path);
69
+ if (!$path) return;
70
+ return {
71
+ translateX: getPathProgess($path, 'x'),
72
+ translateY: getPathProgess($path, 'y'),
73
+ rotate: getPathProgess($path, 'a'),
74
+ }
75
+ };
76
+
77
+ export { createMotionPath };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Anime.js - text - CJS
3
+ * @version v4.2.0
4
+ * @license MIT
5
+ * @copyright 2025 - Julian Garnier
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ var split = require('./split.cjs');
11
+
12
+
13
+
14
+ exports.TextSplitter = split.TextSplitter;
15
+ exports.split = split.split;
16
+ exports.splitText = split.splitText;
@@ -0,0 +1 @@
1
+ export * from "./split.js";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Anime.js - text - ESM
3
+ * @version v4.2.0
4
+ * @license MIT
5
+ * @copyright 2025 - Julian Garnier
6
+ */
7
+
8
+ export { TextSplitter, split, splitText } from './split.js';