animejs 4.2.0-beta.0 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/README.md +6 -1
  2. package/dist/bundles/anime.esm.js +543 -304
  3. package/dist/bundles/anime.esm.min.js +2 -2
  4. package/dist/bundles/anime.umd.js +544 -305
  5. package/dist/bundles/anime.umd.min.js +2 -2
  6. package/dist/modules/animatable/animatable.cjs +4 -4
  7. package/dist/modules/animatable/animatable.js +3 -3
  8. package/dist/modules/animatable/index.cjs +1 -1
  9. package/dist/modules/animatable/index.js +1 -1
  10. package/dist/modules/animation/additive.cjs +1 -1
  11. package/dist/modules/animation/additive.js +1 -1
  12. package/dist/modules/animation/animation.cjs +28 -17
  13. package/dist/modules/animation/animation.d.ts +8 -5
  14. package/dist/modules/animation/animation.js +27 -16
  15. package/dist/modules/animation/composition.cjs +1 -1
  16. package/dist/modules/animation/composition.js +1 -1
  17. package/dist/modules/animation/index.cjs +1 -1
  18. package/dist/modules/animation/index.js +1 -1
  19. package/dist/modules/core/clock.cjs +1 -1
  20. package/dist/modules/core/clock.js +1 -1
  21. package/dist/modules/core/colors.cjs +1 -1
  22. package/dist/modules/core/colors.js +1 -1
  23. package/dist/modules/core/consts.cjs +7 -2
  24. package/dist/modules/core/consts.d.ts +2 -0
  25. package/dist/modules/core/consts.js +6 -3
  26. package/dist/modules/core/globals.cjs +3 -2
  27. package/dist/modules/core/globals.js +3 -2
  28. package/dist/modules/core/helpers.cjs +1 -1
  29. package/dist/modules/core/helpers.js +1 -1
  30. package/dist/modules/core/render.cjs +4 -2
  31. package/dist/modules/core/render.js +4 -2
  32. package/dist/modules/core/styles.cjs +8 -8
  33. package/dist/modules/core/styles.js +10 -10
  34. package/dist/modules/core/targets.cjs +1 -1
  35. package/dist/modules/core/targets.js +1 -1
  36. package/dist/modules/core/transforms.cjs +1 -1
  37. package/dist/modules/core/transforms.js +1 -1
  38. package/dist/modules/core/units.cjs +1 -1
  39. package/dist/modules/core/units.js +1 -1
  40. package/dist/modules/core/values.cjs +17 -6
  41. package/dist/modules/core/values.js +19 -8
  42. package/dist/modules/draggable/draggable.cjs +32 -19
  43. package/dist/modules/draggable/draggable.d.ts +3 -1
  44. package/dist/modules/draggable/draggable.js +28 -15
  45. package/dist/modules/draggable/index.cjs +1 -1
  46. package/dist/modules/draggable/index.js +1 -1
  47. package/dist/modules/easings/{cubic-bezier.cjs → cubic-bezier/index.cjs} +4 -4
  48. package/dist/modules/easings/{cubic-bezier.d.ts → cubic-bezier/index.d.ts} +1 -1
  49. package/dist/modules/easings/{cubic-bezier.js → cubic-bezier/index.js} +4 -4
  50. package/dist/modules/easings/eases/index.cjs +14 -0
  51. package/dist/modules/easings/eases/index.d.ts +1 -0
  52. package/dist/modules/easings/eases/index.js +8 -0
  53. package/dist/modules/easings/{eases.cjs → eases/parser.cjs} +69 -27
  54. package/dist/modules/easings/{eases.d.ts → eases/parser.d.ts} +31 -17
  55. package/dist/modules/easings/{eases.js → eases/parser.js} +60 -21
  56. package/dist/modules/easings/index.cjs +15 -13
  57. package/dist/modules/easings/index.d.ts +6 -6
  58. package/dist/modules/easings/index.js +7 -7
  59. package/dist/modules/easings/{irregular.cjs → irregular/index.cjs} +5 -5
  60. package/dist/modules/easings/{irregular.d.ts → irregular/index.d.ts} +1 -1
  61. package/dist/modules/easings/{irregular.js → irregular/index.js} +4 -4
  62. package/dist/modules/easings/{linear.cjs → linear/index.cjs} +4 -4
  63. package/dist/modules/easings/{linear.d.ts → linear/index.d.ts} +1 -1
  64. package/dist/modules/easings/{linear.js → linear/index.js} +4 -4
  65. package/dist/modules/easings/none.cjs +1 -1
  66. package/dist/modules/easings/none.js +1 -1
  67. package/dist/modules/easings/spring/index.cjs +255 -0
  68. package/dist/modules/{spring/spring.d.ts → easings/spring/index.d.ts} +21 -5
  69. package/dist/modules/easings/spring/index.js +251 -0
  70. package/dist/modules/easings/{steps.cjs → steps/index.cjs} +3 -3
  71. package/dist/modules/easings/{steps.d.ts → steps/index.d.ts} +1 -1
  72. package/dist/modules/easings/{steps.js → steps/index.js} +3 -3
  73. package/dist/modules/engine/engine.cjs +1 -1
  74. package/dist/modules/engine/engine.js +1 -1
  75. package/dist/modules/engine/index.cjs +1 -1
  76. package/dist/modules/engine/index.js +1 -1
  77. package/dist/modules/events/index.cjs +1 -1
  78. package/dist/modules/events/index.js +1 -1
  79. package/dist/modules/events/scroll.cjs +17 -9
  80. package/dist/modules/events/scroll.d.ts +4 -0
  81. package/dist/modules/events/scroll.js +16 -8
  82. package/dist/modules/index.cjs +15 -16
  83. package/dist/modules/index.d.ts +0 -1
  84. package/dist/modules/index.js +7 -8
  85. package/dist/modules/scope/index.cjs +1 -1
  86. package/dist/modules/scope/index.js +1 -1
  87. package/dist/modules/scope/scope.cjs +1 -1
  88. package/dist/modules/scope/scope.js +1 -1
  89. package/dist/modules/svg/drawable.cjs +1 -1
  90. package/dist/modules/svg/drawable.js +1 -1
  91. package/dist/modules/svg/helpers.cjs +1 -1
  92. package/dist/modules/svg/helpers.js +1 -1
  93. package/dist/modules/svg/index.cjs +1 -1
  94. package/dist/modules/svg/index.js +1 -1
  95. package/dist/modules/svg/morphto.cjs +12 -2
  96. package/dist/modules/svg/morphto.js +12 -2
  97. package/dist/modules/svg/motionpath.cjs +18 -11
  98. package/dist/modules/svg/motionpath.d.ts +1 -1
  99. package/dist/modules/svg/motionpath.js +18 -11
  100. package/dist/modules/text/index.cjs +1 -1
  101. package/dist/modules/text/index.js +1 -1
  102. package/dist/modules/text/split.cjs +1 -1
  103. package/dist/modules/text/split.js +1 -1
  104. package/dist/modules/timeline/index.cjs +1 -1
  105. package/dist/modules/timeline/index.js +1 -1
  106. package/dist/modules/timeline/position.cjs +1 -1
  107. package/dist/modules/timeline/position.js +1 -1
  108. package/dist/modules/timeline/timeline.cjs +11 -7
  109. package/dist/modules/timeline/timeline.d.ts +8 -3
  110. package/dist/modules/timeline/timeline.js +10 -6
  111. package/dist/modules/timer/index.cjs +1 -1
  112. package/dist/modules/timer/index.js +1 -1
  113. package/dist/modules/timer/timer.cjs +17 -14
  114. package/dist/modules/timer/timer.d.ts +12 -7
  115. package/dist/modules/timer/timer.js +17 -14
  116. package/dist/modules/types/index.d.ts +35 -14
  117. package/dist/modules/utils/chainable.cjs +1 -1
  118. package/dist/modules/utils/chainable.js +1 -1
  119. package/dist/modules/utils/index.cjs +1 -1
  120. package/dist/modules/utils/index.js +1 -1
  121. package/dist/modules/utils/number.cjs +1 -1
  122. package/dist/modules/utils/number.js +1 -1
  123. package/dist/modules/utils/random.cjs +1 -1
  124. package/dist/modules/utils/random.js +1 -1
  125. package/dist/modules/utils/stagger.cjs +4 -4
  126. package/dist/modules/utils/stagger.js +3 -3
  127. package/dist/modules/utils/target.cjs +1 -1
  128. package/dist/modules/utils/target.js +1 -1
  129. package/dist/modules/utils/time.cjs +1 -1
  130. package/dist/modules/utils/time.js +1 -1
  131. package/dist/modules/waapi/composition.cjs +11 -5
  132. package/dist/modules/waapi/composition.d.ts +1 -1
  133. package/dist/modules/waapi/composition.js +11 -5
  134. package/dist/modules/waapi/index.cjs +1 -1
  135. package/dist/modules/waapi/index.js +1 -1
  136. package/dist/modules/waapi/waapi.cjs +58 -36
  137. package/dist/modules/waapi/waapi.d.ts +12 -7
  138. package/dist/modules/waapi/waapi.js +59 -37
  139. package/package.json +48 -13
  140. package/dist/modules/easings/parser.cjs +0 -59
  141. package/dist/modules/easings/parser.d.ts +0 -21
  142. package/dist/modules/easings/parser.js +0 -55
  143. package/dist/modules/spring/index.cjs +0 -15
  144. package/dist/modules/spring/index.d.ts +0 -1
  145. package/dist/modules/spring/index.js +0 -8
  146. package/dist/modules/spring/spring.cjs +0 -133
  147. package/dist/modules/spring/spring.js +0 -130
@@ -1,130 +0,0 @@
1
- /**
2
- * Anime.js - spring - ESM
3
- * @version v4.2.0
4
- * @license MIT
5
- * @copyright 2025 - Julian Garnier
6
- */
7
-
8
- import { K, minValue } from '../core/consts.js';
9
- import { globals } from '../core/globals.js';
10
- import { clamp, sqrt, abs, round, exp, cos, sin } from '../core/helpers.js';
11
- import { setValue } from '../core/values.js';
12
-
13
- /**
14
- * @import {
15
- * EasingFunction,
16
- * SpringParams,
17
- * } from '../types/index.js'
18
- */
19
-
20
- /*
21
- * Spring ease solver adapted from https://webkit.org/demos/spring/spring.js
22
- * (c) 2016 Webkit - Apple Inc
23
- */
24
-
25
- const maxSpringParamValue = K * 10;
26
-
27
- class Spring {
28
- /**
29
- * @param {SpringParams} [parameters]
30
- */
31
- constructor(parameters = {}) {
32
- this.timeStep = .02; // Interval fed to the solver to calculate duration
33
- this.restThreshold = .0005; // Values below this threshold are considered resting position
34
- this.restDuration = 200; // Duration in ms used to check if the spring is resting after reaching restThreshold
35
- this.maxDuration = 60000; // The maximum allowed spring duration in ms (default 1 min)
36
- this.maxRestSteps = this.restDuration / this.timeStep / K; // How many steps allowed after reaching restThreshold before stopping the duration calculation
37
- this.maxIterations = this.maxDuration / this.timeStep / K; // Calculate the maximum iterations allowed based on maxDuration
38
- this.m = clamp(setValue(parameters.mass, 1), 0, maxSpringParamValue);
39
- this.s = clamp(setValue(parameters.stiffness, 100), 1, maxSpringParamValue);
40
- this.d = clamp(setValue(parameters.damping, 10), .1, maxSpringParamValue);
41
- this.v = clamp(setValue(parameters.velocity, 0), -maxSpringParamValue, maxSpringParamValue);
42
- this.w0 = 0;
43
- this.zeta = 0;
44
- this.wd = 0;
45
- this.b = 0;
46
- this.solverDuration = 0;
47
- this.duration = 0;
48
- this.compute();
49
- /** @type {EasingFunction} */
50
- this.ease = t => t === 0 || t === 1 ? t : this.solve(t * this.solverDuration);
51
- }
52
-
53
- /** @type {EasingFunction} */
54
- solve(time) {
55
- const { zeta, w0, wd, b } = this;
56
- let t = time;
57
- if (zeta < 1) {
58
- t = exp(-t * zeta * w0) * (1 * cos(wd * t) + b * sin(wd * t));
59
- } else {
60
- t = (1 + b * t) * exp(-t * w0);
61
- }
62
- return 1 - t;
63
- }
64
-
65
- compute() {
66
- const { maxRestSteps, maxIterations, restThreshold, timeStep, m, d, s, v } = this;
67
- const w0 = this.w0 = clamp(sqrt(s / m), minValue, K);
68
- const zeta = this.zeta = d / (2 * sqrt(s * m));
69
- const wd = this.wd = zeta < 1 ? w0 * sqrt(1 - zeta * zeta) : 0;
70
- this.b = zeta < 1 ? (zeta * w0 + -v) / wd : -v + w0;
71
- let solverTime = 0;
72
- let restSteps = 0;
73
- let iterations = 0;
74
- while (restSteps < maxRestSteps && iterations < maxIterations) {
75
- if (abs(1 - this.solve(solverTime)) < restThreshold) {
76
- restSteps++;
77
- } else {
78
- restSteps = 0;
79
- }
80
- this.solverDuration = solverTime;
81
- solverTime += timeStep;
82
- iterations++;
83
- }
84
- this.duration = round(this.solverDuration * K, 0) * globals.timeScale;
85
- }
86
-
87
- get mass() {
88
- return this.m;
89
- }
90
-
91
- set mass(v) {
92
- this.m = clamp(setValue(v, 1), 0, maxSpringParamValue);
93
- this.compute();
94
- }
95
-
96
- get stiffness() {
97
- return this.s;
98
- }
99
-
100
- set stiffness(v) {
101
- this.s = clamp(setValue(v, 100), 1, maxSpringParamValue);
102
- this.compute();
103
- }
104
-
105
- get damping() {
106
- return this.d;
107
- }
108
-
109
- set damping(v) {
110
- this.d = clamp(setValue(v, 10), .1, maxSpringParamValue);
111
- this.compute();
112
- }
113
-
114
- get velocity() {
115
- return this.v;
116
- }
117
-
118
- set velocity(v) {
119
- this.v = clamp(setValue(v, 0), -maxSpringParamValue, maxSpringParamValue);
120
- this.compute();
121
- }
122
- }
123
-
124
- /**
125
- * @param {SpringParams} [parameters]
126
- * @returns {Spring}
127
- */
128
- const createSpring = (parameters) => new Spring(parameters);
129
-
130
- export { Spring, createSpring };