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,20 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - easings - CJS
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
'use strict';
|
|
9
9
|
|
|
10
|
-
var consts = require('
|
|
11
|
-
var helpers = require('
|
|
12
|
-
var
|
|
13
|
-
var none = require('./none.cjs');
|
|
14
|
-
var cubicBezier = require('./cubic-bezier.cjs');
|
|
15
|
-
var steps = require('./steps.cjs');
|
|
16
|
-
var linear = require('./linear.cjs');
|
|
17
|
-
var irregular = require('./irregular.cjs');
|
|
10
|
+
var consts = require('../../core/consts.cjs');
|
|
11
|
+
var helpers = require('../../core/helpers.cjs');
|
|
12
|
+
var none = require('../none.cjs');
|
|
18
13
|
|
|
19
14
|
/**
|
|
20
15
|
* @import {
|
|
@@ -24,9 +19,27 @@ var irregular = require('./irregular.cjs');
|
|
|
24
19
|
* BackEasing,
|
|
25
20
|
* ElasticEasing,
|
|
26
21
|
* PowerEasing,
|
|
27
|
-
* } from '
|
|
22
|
+
* } from '../../types/index.js'
|
|
28
23
|
*/
|
|
29
24
|
|
|
25
|
+
|
|
26
|
+
/** @type {PowerEasing} */
|
|
27
|
+
const easeInPower = (p = 1.68) => t => helpers.pow(t, +p);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @callback EaseType
|
|
31
|
+
* @param {EasingFunction} Ease
|
|
32
|
+
* @return {EasingFunction}
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/** @type {Record<String, EaseType>} */
|
|
36
|
+
const easeTypes = {
|
|
37
|
+
in: easeIn => t => easeIn(t),
|
|
38
|
+
out: easeIn => t => 1 - easeIn(1 - t),
|
|
39
|
+
inOut: easeIn => t => t < .5 ? easeIn(t * 2) / 2 : 1 - easeIn(t * -2 + 2) / 2,
|
|
40
|
+
outIn: easeIn => t => t < .5 ? (1 - easeIn(1 - t * 2)) / 2 : (easeIn(t * 2 - 1) + 1) / 2,
|
|
41
|
+
};
|
|
42
|
+
|
|
30
43
|
/**
|
|
31
44
|
* Easing functions adapted and simplified from https://robertpenner.com/easing/
|
|
32
45
|
* (c) 2001 Robert Penner
|
|
@@ -37,11 +50,11 @@ const doublePI = helpers.PI * 2;
|
|
|
37
50
|
|
|
38
51
|
/** @type {Record<String, EasingFunctionWithParams|EasingFunction>} */
|
|
39
52
|
const easeInFunctions = {
|
|
40
|
-
[consts.emptyString]:
|
|
41
|
-
Quad:
|
|
42
|
-
Cubic:
|
|
43
|
-
Quart:
|
|
44
|
-
Quint:
|
|
53
|
+
[consts.emptyString]: easeInPower,
|
|
54
|
+
Quad: easeInPower(2),
|
|
55
|
+
Cubic: easeInPower(3),
|
|
56
|
+
Quart: easeInPower(4),
|
|
57
|
+
Quint: easeInPower(5),
|
|
45
58
|
/** @type {EasingFunction} */
|
|
46
59
|
Sine: t => 1 - helpers.cos(t * halfPI),
|
|
47
60
|
/** @type {EasingFunction} */
|
|
@@ -55,7 +68,7 @@ const easeInFunctions = {
|
|
|
55
68
|
return 1 / helpers.pow(4, 3 - b) - 7.5625 * helpers.pow((pow2 * 3 - 2) / 22 - t, 2);
|
|
56
69
|
},
|
|
57
70
|
/** @type {BackEasing} */
|
|
58
|
-
Back: (overshoot = 1.
|
|
71
|
+
Back: (overshoot = 1.7) => t => (+overshoot + 1) * t * t * t - +overshoot * t * t,
|
|
59
72
|
/** @type {ElasticEasing} */
|
|
60
73
|
Elastic: (amplitude = 1, period = .3) => {
|
|
61
74
|
const a = helpers.clamp(+amplitude, 1, 10);
|
|
@@ -68,10 +81,8 @@ const easeInFunctions = {
|
|
|
68
81
|
|
|
69
82
|
/**
|
|
70
83
|
* @typedef {Object} EasesFunctions
|
|
71
|
-
* @property {typeof
|
|
72
|
-
* @property {typeof
|
|
73
|
-
* @property {typeof steps} steps
|
|
74
|
-
* @property {typeof cubicBezier} cubicBezier
|
|
84
|
+
* @property {typeof none} linear
|
|
85
|
+
* @property {typeof none} none
|
|
75
86
|
* @property {PowerEasing} in
|
|
76
87
|
* @property {PowerEasing} out
|
|
77
88
|
* @property {PowerEasing} inOut
|
|
@@ -119,11 +130,11 @@ const easeInFunctions = {
|
|
|
119
130
|
*/
|
|
120
131
|
|
|
121
132
|
const eases = (/*#__PURE__ */ (() => {
|
|
122
|
-
const list = { linear:
|
|
123
|
-
for (let type in
|
|
133
|
+
const list = { linear: none.none, none: none.none };
|
|
134
|
+
for (let type in easeTypes) {
|
|
124
135
|
for (let name in easeInFunctions) {
|
|
125
136
|
const easeIn = easeInFunctions[name];
|
|
126
|
-
const easeType =
|
|
137
|
+
const easeType = easeTypes[type];
|
|
127
138
|
list[type + name] = /** @type {EasingFunctionWithParams|EasingFunction} */(
|
|
128
139
|
name === consts.emptyString || name === 'Back' || name === 'Elastic' ?
|
|
129
140
|
(a, b) => easeType(/** @type {EasingFunctionWithParams} */(easeIn)(a, b)) :
|
|
@@ -135,15 +146,46 @@ const eases = (/*#__PURE__ */ (() => {
|
|
|
135
146
|
})());
|
|
136
147
|
|
|
137
148
|
/** @type {Record<String, EasingFunction>} */
|
|
138
|
-
const
|
|
149
|
+
const easesLookups = { linear: none.none, none: none.none };
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @param {String} string
|
|
153
|
+
* @return {EasingFunction}
|
|
154
|
+
*/
|
|
155
|
+
const parseEaseString = (string) => {
|
|
156
|
+
if (easesLookups[string]) return easesLookups[string];
|
|
157
|
+
if (string.indexOf('(') <= -1) {
|
|
158
|
+
const hasParams = easeTypes[string] || string.includes('Back') || string.includes('Elastic');
|
|
159
|
+
const parsedFn = /** @type {EasingFunction} */(hasParams ? /** @type {EasingFunctionWithParams} */(eases[string])() : eases[string]);
|
|
160
|
+
return parsedFn ? easesLookups[string] = parsedFn : none.none;
|
|
161
|
+
} else {
|
|
162
|
+
const split = string.slice(0, -1).split('(');
|
|
163
|
+
const parsedFn = /** @type {EasingFunctionWithParams} */(eases[split[0]]);
|
|
164
|
+
return parsedFn ? easesLookups[string] = parsedFn(...split[1].split(',')) : none.none;
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const deprecated = ['steps(', 'irregular(', 'linear(', 'cubicBezier('];
|
|
139
169
|
|
|
140
170
|
/**
|
|
141
171
|
* @param {EasingParam} ease
|
|
142
172
|
* @return {EasingFunction}
|
|
143
173
|
*/
|
|
144
|
-
const parseEase = ease =>
|
|
145
|
-
helpers.isStr(ease)
|
|
146
|
-
|
|
174
|
+
const parseEase = ease => {
|
|
175
|
+
if (helpers.isStr(ease)) {
|
|
176
|
+
for (let i = 0, l = deprecated.length; i < l; i++) {
|
|
177
|
+
if (helpers.stringStartsWith(ease, deprecated[i])) {
|
|
178
|
+
console.warn(`String syntax for \`ease: "${ease}"\` has been removed from the core and replaced by importing and passing the easing function directly: \`ease: ${ease}\``);
|
|
179
|
+
return none.none;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const easeFunc = helpers.isFnc(ease) ? ease : helpers.isStr(ease) ? parseEaseString(/** @type {String} */(ease)) : none.none;
|
|
184
|
+
return easeFunc;
|
|
185
|
+
};
|
|
147
186
|
|
|
187
|
+
exports.easeInPower = easeInPower;
|
|
188
|
+
exports.easeTypes = easeTypes;
|
|
148
189
|
exports.eases = eases;
|
|
149
190
|
exports.parseEase = parseEase;
|
|
191
|
+
exports.parseEaseString = parseEaseString;
|
|
@@ -1,8 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {
|
|
3
|
+
* EasingFunction,
|
|
4
|
+
* EasingFunctionWithParams,
|
|
5
|
+
* EasingParam,
|
|
6
|
+
* BackEasing,
|
|
7
|
+
* ElasticEasing,
|
|
8
|
+
* PowerEasing,
|
|
9
|
+
* } from '../../types/index.js'
|
|
10
|
+
*/
|
|
11
|
+
/** @type {PowerEasing} */
|
|
12
|
+
export const easeInPower: PowerEasing;
|
|
13
|
+
/**
|
|
14
|
+
* @callback EaseType
|
|
15
|
+
* @param {EasingFunction} Ease
|
|
16
|
+
* @return {EasingFunction}
|
|
17
|
+
*/
|
|
18
|
+
/** @type {Record<String, EaseType>} */
|
|
19
|
+
export const easeTypes: Record<string, EaseType>;
|
|
1
20
|
export namespace eases {
|
|
2
|
-
export let linear: typeof import("
|
|
3
|
-
export let
|
|
4
|
-
export let steps: typeof import("./steps.js").steps;
|
|
5
|
-
export let cubicBezier: typeof import("./cubic-bezier.js").cubicBezier;
|
|
21
|
+
export let linear: typeof import("../none.js").none;
|
|
22
|
+
export let none: typeof import("../none.js").none;
|
|
6
23
|
let _in: PowerEasing;
|
|
7
24
|
export { _in as in };
|
|
8
25
|
export let out: PowerEasing;
|
|
@@ -49,12 +66,12 @@ export namespace eases {
|
|
|
49
66
|
export let inOutElastic: ElasticEasing;
|
|
50
67
|
export let outInElastic: ElasticEasing;
|
|
51
68
|
}
|
|
69
|
+
export function parseEaseString(string: string): EasingFunction;
|
|
52
70
|
export function parseEase(ease: EasingParam): EasingFunction;
|
|
71
|
+
export type EaseType = (Ease: EasingFunction) => EasingFunction;
|
|
53
72
|
export type EasesFunctions = {
|
|
54
|
-
linear: typeof
|
|
55
|
-
|
|
56
|
-
steps: typeof steps;
|
|
57
|
-
cubicBezier: typeof cubicBezier;
|
|
73
|
+
linear: typeof none;
|
|
74
|
+
none: typeof none;
|
|
58
75
|
in: PowerEasing;
|
|
59
76
|
out: PowerEasing;
|
|
60
77
|
inOut: PowerEasing;
|
|
@@ -100,12 +117,9 @@ export type EasesFunctions = {
|
|
|
100
117
|
inOutElastic: ElasticEasing;
|
|
101
118
|
outInElastic: ElasticEasing;
|
|
102
119
|
};
|
|
103
|
-
import type { PowerEasing } from '
|
|
104
|
-
import type { EasingFunction } from '
|
|
105
|
-
import type { BackEasing } from '
|
|
106
|
-
import type { ElasticEasing } from '
|
|
107
|
-
import type { EasingParam } from '
|
|
108
|
-
import {
|
|
109
|
-
import { irregular as irregular_1 } from './irregular.js';
|
|
110
|
-
import { steps as steps_1 } from './steps.js';
|
|
111
|
-
import { cubicBezier as cubicBezier_1 } from './cubic-bezier.js';
|
|
120
|
+
import type { PowerEasing } from '../../types/index.js';
|
|
121
|
+
import type { EasingFunction } from '../../types/index.js';
|
|
122
|
+
import type { BackEasing } from '../../types/index.js';
|
|
123
|
+
import type { ElasticEasing } from '../../types/index.js';
|
|
124
|
+
import type { EasingParam } from '../../types/index.js';
|
|
125
|
+
import { none as none_1 } from '../none.js';
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - easings - ESM
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { emptyString, minValue } from '
|
|
9
|
-
import { pow, sin, sqrt, cos,
|
|
10
|
-
import {
|
|
11
|
-
import { none } from './none.js';
|
|
12
|
-
import { cubicBezier } from './cubic-bezier.js';
|
|
13
|
-
import { steps } from './steps.js';
|
|
14
|
-
import { linear } from './linear.js';
|
|
15
|
-
import { irregular } from './irregular.js';
|
|
8
|
+
import { emptyString, minValue } from '../../core/consts.js';
|
|
9
|
+
import { pow, sin, sqrt, cos, isStr, stringStartsWith, isFnc, clamp, asin, PI } from '../../core/helpers.js';
|
|
10
|
+
import { none } from '../none.js';
|
|
16
11
|
|
|
17
12
|
/**
|
|
18
13
|
* @import {
|
|
@@ -22,9 +17,27 @@ import { irregular } from './irregular.js';
|
|
|
22
17
|
* BackEasing,
|
|
23
18
|
* ElasticEasing,
|
|
24
19
|
* PowerEasing,
|
|
25
|
-
* } from '
|
|
20
|
+
* } from '../../types/index.js'
|
|
26
21
|
*/
|
|
27
22
|
|
|
23
|
+
|
|
24
|
+
/** @type {PowerEasing} */
|
|
25
|
+
const easeInPower = (p = 1.68) => t => pow(t, +p);
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @callback EaseType
|
|
29
|
+
* @param {EasingFunction} Ease
|
|
30
|
+
* @return {EasingFunction}
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/** @type {Record<String, EaseType>} */
|
|
34
|
+
const easeTypes = {
|
|
35
|
+
in: easeIn => t => easeIn(t),
|
|
36
|
+
out: easeIn => t => 1 - easeIn(1 - t),
|
|
37
|
+
inOut: easeIn => t => t < .5 ? easeIn(t * 2) / 2 : 1 - easeIn(t * -2 + 2) / 2,
|
|
38
|
+
outIn: easeIn => t => t < .5 ? (1 - easeIn(1 - t * 2)) / 2 : (easeIn(t * 2 - 1) + 1) / 2,
|
|
39
|
+
};
|
|
40
|
+
|
|
28
41
|
/**
|
|
29
42
|
* Easing functions adapted and simplified from https://robertpenner.com/easing/
|
|
30
43
|
* (c) 2001 Robert Penner
|
|
@@ -53,7 +66,7 @@ const easeInFunctions = {
|
|
|
53
66
|
return 1 / pow(4, 3 - b) - 7.5625 * pow((pow2 * 3 - 2) / 22 - t, 2);
|
|
54
67
|
},
|
|
55
68
|
/** @type {BackEasing} */
|
|
56
|
-
Back: (overshoot = 1.
|
|
69
|
+
Back: (overshoot = 1.7) => t => (+overshoot + 1) * t * t * t - +overshoot * t * t,
|
|
57
70
|
/** @type {ElasticEasing} */
|
|
58
71
|
Elastic: (amplitude = 1, period = .3) => {
|
|
59
72
|
const a = clamp(+amplitude, 1, 10);
|
|
@@ -66,10 +79,8 @@ const easeInFunctions = {
|
|
|
66
79
|
|
|
67
80
|
/**
|
|
68
81
|
* @typedef {Object} EasesFunctions
|
|
69
|
-
* @property {typeof
|
|
70
|
-
* @property {typeof
|
|
71
|
-
* @property {typeof steps} steps
|
|
72
|
-
* @property {typeof cubicBezier} cubicBezier
|
|
82
|
+
* @property {typeof none} linear
|
|
83
|
+
* @property {typeof none} none
|
|
73
84
|
* @property {PowerEasing} in
|
|
74
85
|
* @property {PowerEasing} out
|
|
75
86
|
* @property {PowerEasing} inOut
|
|
@@ -117,7 +128,7 @@ const easeInFunctions = {
|
|
|
117
128
|
*/
|
|
118
129
|
|
|
119
130
|
const eases = (/*#__PURE__ */ (() => {
|
|
120
|
-
const list = { linear
|
|
131
|
+
const list = { linear: none, none: none };
|
|
121
132
|
for (let type in easeTypes) {
|
|
122
133
|
for (let name in easeInFunctions) {
|
|
123
134
|
const easeIn = easeInFunctions[name];
|
|
@@ -133,14 +144,42 @@ const eases = (/*#__PURE__ */ (() => {
|
|
|
133
144
|
})());
|
|
134
145
|
|
|
135
146
|
/** @type {Record<String, EasingFunction>} */
|
|
136
|
-
const
|
|
147
|
+
const easesLookups = { linear: none, none: none };
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* @param {String} string
|
|
151
|
+
* @return {EasingFunction}
|
|
152
|
+
*/
|
|
153
|
+
const parseEaseString = (string) => {
|
|
154
|
+
if (easesLookups[string]) return easesLookups[string];
|
|
155
|
+
if (string.indexOf('(') <= -1) {
|
|
156
|
+
const hasParams = easeTypes[string] || string.includes('Back') || string.includes('Elastic');
|
|
157
|
+
const parsedFn = /** @type {EasingFunction} */(hasParams ? /** @type {EasingFunctionWithParams} */(eases[string])() : eases[string]);
|
|
158
|
+
return parsedFn ? easesLookups[string] = parsedFn : none;
|
|
159
|
+
} else {
|
|
160
|
+
const split = string.slice(0, -1).split('(');
|
|
161
|
+
const parsedFn = /** @type {EasingFunctionWithParams} */(eases[split[0]]);
|
|
162
|
+
return parsedFn ? easesLookups[string] = parsedFn(...split[1].split(',')) : none;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const deprecated = ['steps(', 'irregular(', 'linear(', 'cubicBezier('];
|
|
137
167
|
|
|
138
168
|
/**
|
|
139
169
|
* @param {EasingParam} ease
|
|
140
170
|
* @return {EasingFunction}
|
|
141
171
|
*/
|
|
142
|
-
const parseEase = ease =>
|
|
143
|
-
|
|
144
|
-
|
|
172
|
+
const parseEase = ease => {
|
|
173
|
+
if (isStr(ease)) {
|
|
174
|
+
for (let i = 0, l = deprecated.length; i < l; i++) {
|
|
175
|
+
if (stringStartsWith(ease, deprecated[i])) {
|
|
176
|
+
console.warn(`String syntax for \`ease: "${ease}"\` has been removed from the core and replaced by importing and passing the easing function directly: \`ease: ${ease}\``);
|
|
177
|
+
return none;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const easeFunc = isFnc(ease) ? ease : isStr(ease) ? parseEaseString(/** @type {String} */(ease)) : none;
|
|
182
|
+
return easeFunc;
|
|
183
|
+
};
|
|
145
184
|
|
|
146
|
-
export { eases, parseEase };
|
|
185
|
+
export { easeInPower, easeTypes, eases, parseEase, parseEaseString };
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - easings - CJS
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
'use strict';
|
|
9
9
|
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
10
|
+
var index = require('./cubic-bezier/index.cjs');
|
|
11
|
+
var index$1 = require('./steps/index.cjs');
|
|
12
|
+
var index$2 = require('./linear/index.cjs');
|
|
13
|
+
var index$3 = require('./irregular/index.cjs');
|
|
14
|
+
var index$4 = require('./spring/index.cjs');
|
|
15
|
+
var parser = require('./eases/parser.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
exports.
|
|
20
|
-
exports.
|
|
21
|
-
exports.
|
|
22
|
-
exports.
|
|
23
|
-
exports.
|
|
24
|
-
exports.
|
|
19
|
+
exports.cubicBezier = index.cubicBezier;
|
|
20
|
+
exports.steps = index$1.steps;
|
|
21
|
+
exports.linear = index$2.linear;
|
|
22
|
+
exports.irregular = index$3.irregular;
|
|
23
|
+
exports.Spring = index$4.Spring;
|
|
24
|
+
exports.createSpring = index$4.createSpring;
|
|
25
|
+
exports.spring = index$4.spring;
|
|
26
|
+
exports.eases = parser.eases;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
1
|
+
export * from "./cubic-bezier/index.js";
|
|
2
|
+
export * from "./steps/index.js";
|
|
3
|
+
export * from "./linear/index.js";
|
|
4
|
+
export * from "./irregular/index.js";
|
|
5
|
+
export * from "./spring/index.js";
|
|
6
|
+
export * from "./eases/index.js";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - easings - ESM
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export { eases } from './eases.js';
|
|
8
|
+
export { cubicBezier } from './cubic-bezier/index.js';
|
|
9
|
+
export { steps } from './steps/index.js';
|
|
10
|
+
export { linear } from './linear/index.js';
|
|
11
|
+
export { irregular } from './irregular/index.js';
|
|
12
|
+
export { Spring, createSpring, spring } from './spring/index.js';
|
|
13
|
+
export { eases } from './eases/parser.js';
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - easings - CJS
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
'use strict';
|
|
9
9
|
|
|
10
|
-
var helpers = require('
|
|
11
|
-
var
|
|
10
|
+
var helpers = require('../../core/helpers.cjs');
|
|
11
|
+
var index = require('../linear/index.cjs');
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @import {
|
|
15
15
|
* EasingFunction,
|
|
16
|
-
* } from '
|
|
16
|
+
* } from '../../types/index.js'
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -35,7 +35,7 @@ const irregular = (length = 10, randomness = 1) => {
|
|
|
35
35
|
values.push(helpers.clamp(randomValue, previousValue, 1));
|
|
36
36
|
}
|
|
37
37
|
values.push(1);
|
|
38
|
-
return
|
|
38
|
+
return index.linear(...values);
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
exports.irregular = irregular;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export function irregular(length?: number, randomness?: number): EasingFunction;
|
|
2
|
-
import type { EasingFunction } from '
|
|
2
|
+
import type { EasingFunction } from '../../types/index.js';
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - easings - ESM
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { clamp } from '
|
|
9
|
-
import { linear } from '
|
|
8
|
+
import { clamp } from '../../core/helpers.js';
|
|
9
|
+
import { linear } from '../linear/index.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @import {
|
|
13
13
|
* EasingFunction,
|
|
14
|
-
* } from '
|
|
14
|
+
* } from '../../types/index.js'
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - easings - CJS
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
'use strict';
|
|
9
9
|
|
|
10
|
-
var helpers = require('
|
|
11
|
-
var none = require('
|
|
10
|
+
var helpers = require('../../core/helpers.cjs');
|
|
11
|
+
var none = require('../none.cjs');
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @import {
|
|
15
15
|
* EasingFunction,
|
|
16
|
-
* } from '
|
|
16
|
+
* } from '../../types/index.js'
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export function linear(...args: (string | number)[]): EasingFunction;
|
|
2
|
-
import type { EasingFunction } from '
|
|
2
|
+
import type { EasingFunction } from '../../types/index.js';
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - easings - ESM
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { isStr, parseNumber, isUnd } from '
|
|
9
|
-
import { none } from '
|
|
8
|
+
import { isStr, parseNumber, isUnd } from '../../core/helpers.js';
|
|
9
|
+
import { none } from '../none.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @import {
|
|
13
13
|
* EasingFunction,
|
|
14
|
-
* } from '
|
|
14
|
+
* } from '../../types/index.js'
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
/**
|