animejs 4.2.0-beta.0 → 4.2.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.
- package/README.md +6 -1
- package/dist/bundles/anime.esm.js +448 -260
- package/dist/bundles/anime.esm.min.js +1 -1
- package/dist/bundles/anime.umd.js +449 -261
- package/dist/bundles/anime.umd.min.js +1 -1
- package/dist/modules/animatable/animatable.cjs +2 -2
- package/dist/modules/animatable/animatable.js +1 -1
- package/dist/modules/animation/animation.cjs +21 -14
- package/dist/modules/animation/animation.d.ts +0 -2
- package/dist/modules/animation/animation.js +20 -13
- package/dist/modules/core/consts.cjs +6 -1
- package/dist/modules/core/consts.d.ts +2 -0
- package/dist/modules/core/consts.js +5 -2
- package/dist/modules/core/globals.cjs +1 -0
- package/dist/modules/core/globals.js +1 -0
- package/dist/modules/core/render.cjs +3 -1
- package/dist/modules/core/render.js +3 -1
- package/dist/modules/core/styles.cjs +7 -7
- package/dist/modules/core/styles.js +9 -9
- package/dist/modules/core/values.cjs +16 -5
- package/dist/modules/core/values.js +18 -7
- package/dist/modules/draggable/draggable.cjs +16 -16
- package/dist/modules/draggable/draggable.d.ts +1 -1
- package/dist/modules/draggable/draggable.js +11 -11
- package/dist/modules/easings/{cubic-bezier.cjs → cubic-bezier/index.cjs} +3 -3
- 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} +3 -3
- package/dist/modules/easings/eases/index.cjs +14 -0
- package/dist/modules/easings/eases/index.d.ts +1 -0
- package/dist/modules/{spring → easings/eases}/index.js +2 -2
- package/dist/modules/easings/{eases.cjs → eases/parser.cjs} +68 -26
- package/dist/modules/easings/{eases.d.ts → eases/parser.d.ts} +31 -17
- package/dist/modules/easings/{eases.js → eases/parser.js} +59 -20
- package/dist/modules/easings/index.cjs +14 -12
- package/dist/modules/easings/index.d.ts +6 -6
- package/dist/modules/easings/index.js +6 -6
- package/dist/modules/easings/{irregular.cjs → irregular/index.cjs} +4 -4
- package/dist/modules/easings/{irregular.d.ts → irregular/index.d.ts} +1 -1
- package/dist/modules/easings/{irregular.js → irregular/index.js} +3 -3
- package/dist/modules/easings/{linear.cjs → linear/index.cjs} +3 -3
- package/dist/modules/easings/{linear.d.ts → linear/index.d.ts} +1 -1
- package/dist/modules/easings/{linear.js → linear/index.js} +3 -3
- 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} +2 -2
- package/dist/modules/easings/{steps.d.ts → steps/index.d.ts} +1 -1
- package/dist/modules/easings/{steps.js → steps/index.js} +2 -2
- package/dist/modules/events/scroll.cjs +10 -6
- package/dist/modules/events/scroll.d.ts +2 -0
- package/dist/modules/events/scroll.js +9 -5
- package/dist/modules/index.cjs +14 -15
- package/dist/modules/index.d.ts +0 -1
- package/dist/modules/index.js +6 -7
- package/dist/modules/timeline/timeline.cjs +2 -2
- package/dist/modules/timeline/timeline.js +1 -1
- package/dist/modules/types/index.d.ts +30 -13
- package/dist/modules/utils/stagger.cjs +3 -3
- package/dist/modules/utils/stagger.js +2 -2
- package/dist/modules/waapi/composition.cjs +10 -4
- package/dist/modules/waapi/composition.d.ts +1 -1
- package/dist/modules/waapi/composition.js +10 -4
- package/dist/modules/waapi/waapi.cjs +50 -31
- package/dist/modules/waapi/waapi.d.ts +4 -2
- package/dist/modules/waapi/waapi.js +51 -32
- package/package.json +46 -10
- 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/spring.cjs +0 -133
- package/dist/modules/spring/spring.js +0 -130
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Anime.js - spring - CJS
|
|
3
|
-
* @version v4.2.0
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright 2025 - Julian Garnier
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
'use strict';
|
|
9
|
-
|
|
10
|
-
var spring = require('./spring.cjs');
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
exports.Spring = spring.Spring;
|
|
15
|
-
exports.createSpring = spring.createSpring;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./spring.js";
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Anime.js - spring - 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 globals = require('../core/globals.cjs');
|
|
12
|
-
var helpers = require('../core/helpers.cjs');
|
|
13
|
-
var values = require('../core/values.cjs');
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @import {
|
|
17
|
-
* EasingFunction,
|
|
18
|
-
* SpringParams,
|
|
19
|
-
* } from '../types/index.js'
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/*
|
|
23
|
-
* Spring ease solver adapted from https://webkit.org/demos/spring/spring.js
|
|
24
|
-
* (c) 2016 Webkit - Apple Inc
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
const maxSpringParamValue = consts.K * 10;
|
|
28
|
-
|
|
29
|
-
class Spring {
|
|
30
|
-
/**
|
|
31
|
-
* @param {SpringParams} [parameters]
|
|
32
|
-
*/
|
|
33
|
-
constructor(parameters = {}) {
|
|
34
|
-
this.timeStep = .02; // Interval fed to the solver to calculate duration
|
|
35
|
-
this.restThreshold = .0005; // Values below this threshold are considered resting position
|
|
36
|
-
this.restDuration = 200; // Duration in ms used to check if the spring is resting after reaching restThreshold
|
|
37
|
-
this.maxDuration = 60000; // The maximum allowed spring duration in ms (default 1 min)
|
|
38
|
-
this.maxRestSteps = this.restDuration / this.timeStep / consts.K; // How many steps allowed after reaching restThreshold before stopping the duration calculation
|
|
39
|
-
this.maxIterations = this.maxDuration / this.timeStep / consts.K; // Calculate the maximum iterations allowed based on maxDuration
|
|
40
|
-
this.m = helpers.clamp(values.setValue(parameters.mass, 1), 0, maxSpringParamValue);
|
|
41
|
-
this.s = helpers.clamp(values.setValue(parameters.stiffness, 100), 1, maxSpringParamValue);
|
|
42
|
-
this.d = helpers.clamp(values.setValue(parameters.damping, 10), .1, maxSpringParamValue);
|
|
43
|
-
this.v = helpers.clamp(values.setValue(parameters.velocity, 0), -maxSpringParamValue, maxSpringParamValue);
|
|
44
|
-
this.w0 = 0;
|
|
45
|
-
this.zeta = 0;
|
|
46
|
-
this.wd = 0;
|
|
47
|
-
this.b = 0;
|
|
48
|
-
this.solverDuration = 0;
|
|
49
|
-
this.duration = 0;
|
|
50
|
-
this.compute();
|
|
51
|
-
/** @type {EasingFunction} */
|
|
52
|
-
this.ease = t => t === 0 || t === 1 ? t : this.solve(t * this.solverDuration);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** @type {EasingFunction} */
|
|
56
|
-
solve(time) {
|
|
57
|
-
const { zeta, w0, wd, b } = this;
|
|
58
|
-
let t = time;
|
|
59
|
-
if (zeta < 1) {
|
|
60
|
-
t = helpers.exp(-t * zeta * w0) * (1 * helpers.cos(wd * t) + b * helpers.sin(wd * t));
|
|
61
|
-
} else {
|
|
62
|
-
t = (1 + b * t) * helpers.exp(-t * w0);
|
|
63
|
-
}
|
|
64
|
-
return 1 - t;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
compute() {
|
|
68
|
-
const { maxRestSteps, maxIterations, restThreshold, timeStep, m, d, s, v } = this;
|
|
69
|
-
const w0 = this.w0 = helpers.clamp(helpers.sqrt(s / m), consts.minValue, consts.K);
|
|
70
|
-
const zeta = this.zeta = d / (2 * helpers.sqrt(s * m));
|
|
71
|
-
const wd = this.wd = zeta < 1 ? w0 * helpers.sqrt(1 - zeta * zeta) : 0;
|
|
72
|
-
this.b = zeta < 1 ? (zeta * w0 + -v) / wd : -v + w0;
|
|
73
|
-
let solverTime = 0;
|
|
74
|
-
let restSteps = 0;
|
|
75
|
-
let iterations = 0;
|
|
76
|
-
while (restSteps < maxRestSteps && iterations < maxIterations) {
|
|
77
|
-
if (helpers.abs(1 - this.solve(solverTime)) < restThreshold) {
|
|
78
|
-
restSteps++;
|
|
79
|
-
} else {
|
|
80
|
-
restSteps = 0;
|
|
81
|
-
}
|
|
82
|
-
this.solverDuration = solverTime;
|
|
83
|
-
solverTime += timeStep;
|
|
84
|
-
iterations++;
|
|
85
|
-
}
|
|
86
|
-
this.duration = helpers.round(this.solverDuration * consts.K, 0) * globals.globals.timeScale;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
get mass() {
|
|
90
|
-
return this.m;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
set mass(v) {
|
|
94
|
-
this.m = helpers.clamp(values.setValue(v, 1), 0, maxSpringParamValue);
|
|
95
|
-
this.compute();
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
get stiffness() {
|
|
99
|
-
return this.s;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
set stiffness(v) {
|
|
103
|
-
this.s = helpers.clamp(values.setValue(v, 100), 1, maxSpringParamValue);
|
|
104
|
-
this.compute();
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
get damping() {
|
|
108
|
-
return this.d;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
set damping(v) {
|
|
112
|
-
this.d = helpers.clamp(values.setValue(v, 10), .1, maxSpringParamValue);
|
|
113
|
-
this.compute();
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
get velocity() {
|
|
117
|
-
return this.v;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
set velocity(v) {
|
|
121
|
-
this.v = helpers.clamp(values.setValue(v, 0), -maxSpringParamValue, maxSpringParamValue);
|
|
122
|
-
this.compute();
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* @param {SpringParams} [parameters]
|
|
128
|
-
* @returns {Spring}
|
|
129
|
-
*/
|
|
130
|
-
const createSpring = (parameters) => new Spring(parameters);
|
|
131
|
-
|
|
132
|
-
exports.Spring = Spring;
|
|
133
|
-
exports.createSpring = createSpring;
|
|
@@ -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 };
|