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.
- package/README.md +6 -1
- package/dist/bundles/anime.esm.js +543 -304
- package/dist/bundles/anime.esm.min.js +2 -2
- package/dist/bundles/anime.umd.js +544 -305
- package/dist/bundles/anime.umd.min.js +2 -2
- package/dist/modules/animatable/animatable.cjs +4 -4
- package/dist/modules/animatable/animatable.js +3 -3
- package/dist/modules/animatable/index.cjs +1 -1
- package/dist/modules/animatable/index.js +1 -1
- package/dist/modules/animation/additive.cjs +1 -1
- package/dist/modules/animation/additive.js +1 -1
- package/dist/modules/animation/animation.cjs +28 -17
- package/dist/modules/animation/animation.d.ts +8 -5
- package/dist/modules/animation/animation.js +27 -16
- package/dist/modules/animation/composition.cjs +1 -1
- package/dist/modules/animation/composition.js +1 -1
- package/dist/modules/animation/index.cjs +1 -1
- package/dist/modules/animation/index.js +1 -1
- package/dist/modules/core/clock.cjs +1 -1
- package/dist/modules/core/clock.js +1 -1
- package/dist/modules/core/colors.cjs +1 -1
- package/dist/modules/core/colors.js +1 -1
- package/dist/modules/core/consts.cjs +7 -2
- package/dist/modules/core/consts.d.ts +2 -0
- package/dist/modules/core/consts.js +6 -3
- package/dist/modules/core/globals.cjs +3 -2
- package/dist/modules/core/globals.js +3 -2
- package/dist/modules/core/helpers.cjs +1 -1
- package/dist/modules/core/helpers.js +1 -1
- package/dist/modules/core/render.cjs +4 -2
- package/dist/modules/core/render.js +4 -2
- package/dist/modules/core/styles.cjs +8 -8
- package/dist/modules/core/styles.js +10 -10
- package/dist/modules/core/targets.cjs +1 -1
- package/dist/modules/core/targets.js +1 -1
- package/dist/modules/core/transforms.cjs +1 -1
- package/dist/modules/core/transforms.js +1 -1
- package/dist/modules/core/units.cjs +1 -1
- package/dist/modules/core/units.js +1 -1
- package/dist/modules/core/values.cjs +17 -6
- package/dist/modules/core/values.js +19 -8
- package/dist/modules/draggable/draggable.cjs +32 -19
- package/dist/modules/draggable/draggable.d.ts +3 -1
- package/dist/modules/draggable/draggable.js +28 -15
- package/dist/modules/draggable/index.cjs +1 -1
- package/dist/modules/draggable/index.js +1 -1
- package/dist/modules/easings/{cubic-bezier.cjs → cubic-bezier/index.cjs} +4 -4
- package/dist/modules/easings/{cubic-bezier.d.ts → cubic-bezier/index.d.ts} +1 -1
- package/dist/modules/easings/{cubic-bezier.js → cubic-bezier/index.js} +4 -4
- package/dist/modules/easings/eases/index.cjs +14 -0
- package/dist/modules/easings/eases/index.d.ts +1 -0
- package/dist/modules/easings/eases/index.js +8 -0
- package/dist/modules/easings/{eases.cjs → eases/parser.cjs} +69 -27
- package/dist/modules/easings/{eases.d.ts → eases/parser.d.ts} +31 -17
- package/dist/modules/easings/{eases.js → eases/parser.js} +60 -21
- package/dist/modules/easings/index.cjs +15 -13
- package/dist/modules/easings/index.d.ts +6 -6
- package/dist/modules/easings/index.js +7 -7
- package/dist/modules/easings/{irregular.cjs → irregular/index.cjs} +5 -5
- package/dist/modules/easings/{irregular.d.ts → irregular/index.d.ts} +1 -1
- package/dist/modules/easings/{irregular.js → irregular/index.js} +4 -4
- package/dist/modules/easings/{linear.cjs → linear/index.cjs} +4 -4
- package/dist/modules/easings/{linear.d.ts → linear/index.d.ts} +1 -1
- package/dist/modules/easings/{linear.js → linear/index.js} +4 -4
- package/dist/modules/easings/none.cjs +1 -1
- package/dist/modules/easings/none.js +1 -1
- package/dist/modules/easings/spring/index.cjs +255 -0
- package/dist/modules/{spring/spring.d.ts → easings/spring/index.d.ts} +21 -5
- package/dist/modules/easings/spring/index.js +251 -0
- package/dist/modules/easings/{steps.cjs → steps/index.cjs} +3 -3
- package/dist/modules/easings/{steps.d.ts → steps/index.d.ts} +1 -1
- package/dist/modules/easings/{steps.js → steps/index.js} +3 -3
- package/dist/modules/engine/engine.cjs +1 -1
- package/dist/modules/engine/engine.js +1 -1
- package/dist/modules/engine/index.cjs +1 -1
- package/dist/modules/engine/index.js +1 -1
- package/dist/modules/events/index.cjs +1 -1
- package/dist/modules/events/index.js +1 -1
- package/dist/modules/events/scroll.cjs +17 -9
- package/dist/modules/events/scroll.d.ts +4 -0
- package/dist/modules/events/scroll.js +16 -8
- package/dist/modules/index.cjs +15 -16
- package/dist/modules/index.d.ts +0 -1
- package/dist/modules/index.js +7 -8
- package/dist/modules/scope/index.cjs +1 -1
- package/dist/modules/scope/index.js +1 -1
- package/dist/modules/scope/scope.cjs +1 -1
- package/dist/modules/scope/scope.js +1 -1
- package/dist/modules/svg/drawable.cjs +1 -1
- package/dist/modules/svg/drawable.js +1 -1
- package/dist/modules/svg/helpers.cjs +1 -1
- package/dist/modules/svg/helpers.js +1 -1
- package/dist/modules/svg/index.cjs +1 -1
- package/dist/modules/svg/index.js +1 -1
- package/dist/modules/svg/morphto.cjs +12 -2
- package/dist/modules/svg/morphto.js +12 -2
- package/dist/modules/svg/motionpath.cjs +18 -11
- package/dist/modules/svg/motionpath.d.ts +1 -1
- package/dist/modules/svg/motionpath.js +18 -11
- package/dist/modules/text/index.cjs +1 -1
- package/dist/modules/text/index.js +1 -1
- package/dist/modules/text/split.cjs +1 -1
- package/dist/modules/text/split.js +1 -1
- package/dist/modules/timeline/index.cjs +1 -1
- package/dist/modules/timeline/index.js +1 -1
- package/dist/modules/timeline/position.cjs +1 -1
- package/dist/modules/timeline/position.js +1 -1
- package/dist/modules/timeline/timeline.cjs +11 -7
- package/dist/modules/timeline/timeline.d.ts +8 -3
- package/dist/modules/timeline/timeline.js +10 -6
- package/dist/modules/timer/index.cjs +1 -1
- package/dist/modules/timer/index.js +1 -1
- package/dist/modules/timer/timer.cjs +17 -14
- package/dist/modules/timer/timer.d.ts +12 -7
- package/dist/modules/timer/timer.js +17 -14
- package/dist/modules/types/index.d.ts +35 -14
- package/dist/modules/utils/chainable.cjs +1 -1
- package/dist/modules/utils/chainable.js +1 -1
- package/dist/modules/utils/index.cjs +1 -1
- package/dist/modules/utils/index.js +1 -1
- package/dist/modules/utils/number.cjs +1 -1
- package/dist/modules/utils/number.js +1 -1
- package/dist/modules/utils/random.cjs +1 -1
- package/dist/modules/utils/random.js +1 -1
- package/dist/modules/utils/stagger.cjs +4 -4
- package/dist/modules/utils/stagger.js +3 -3
- package/dist/modules/utils/target.cjs +1 -1
- package/dist/modules/utils/target.js +1 -1
- package/dist/modules/utils/time.cjs +1 -1
- package/dist/modules/utils/time.js +1 -1
- package/dist/modules/waapi/composition.cjs +11 -5
- package/dist/modules/waapi/composition.d.ts +1 -1
- package/dist/modules/waapi/composition.js +11 -5
- package/dist/modules/waapi/index.cjs +1 -1
- package/dist/modules/waapi/index.js +1 -1
- package/dist/modules/waapi/waapi.cjs +58 -36
- package/dist/modules/waapi/waapi.d.ts +12 -7
- package/dist/modules/waapi/waapi.js +59 -37
- package/package.json +48 -13
- package/dist/modules/easings/parser.cjs +0 -59
- package/dist/modules/easings/parser.d.ts +0 -21
- package/dist/modules/easings/parser.js +0 -55
- package/dist/modules/spring/index.cjs +0 -15
- package/dist/modules/spring/index.d.ts +0 -1
- package/dist/modules/spring/index.js +0 -8
- package/dist/modules/spring/spring.cjs +0 -133
- 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 };
|