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
|
@@ -17,8 +17,8 @@ var timer = require('../timer/timer.cjs');
|
|
|
17
17
|
var animation = require('../animation/animation.cjs');
|
|
18
18
|
var composition = require('../animation/composition.cjs');
|
|
19
19
|
var animatable = require('../animatable/animatable.cjs');
|
|
20
|
-
var
|
|
21
|
-
var
|
|
20
|
+
var parser = require('../easings/eases/parser.cjs');
|
|
21
|
+
var index = require('../easings/spring/index.cjs');
|
|
22
22
|
var target = require('../utils/target.cjs');
|
|
23
23
|
|
|
24
24
|
/**
|
|
@@ -40,7 +40,7 @@ var target = require('../utils/target.cjs');
|
|
|
40
40
|
/**
|
|
41
41
|
* @import {
|
|
42
42
|
* Spring,
|
|
43
|
-
* } from '../spring/
|
|
43
|
+
* } from '../easings/spring/index.js'
|
|
44
44
|
*/
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -178,7 +178,7 @@ class Draggable {
|
|
|
178
178
|
const trigger = parameters.trigger;
|
|
179
179
|
const modifier = parameters.modifier;
|
|
180
180
|
const ease = parameters.releaseEase;
|
|
181
|
-
const customEase = ease &&
|
|
181
|
+
const customEase = ease && parser.parseEase(ease);
|
|
182
182
|
const hasSpring = !helpers.isUnd(ease) && !helpers.isUnd(/** @type {Spring} */(ease).ease);
|
|
183
183
|
const xProp = /** @type {String} */(helpers.isObj(paramX) && !helpers.isUnd(/** @type {Object} */(paramX).mapTo) ? /** @type {Object} */(paramX).mapTo : 'translateX');
|
|
184
184
|
const yProp = /** @type {String} */(helpers.isObj(paramY) && !helpers.isUnd(/** @type {Object} */(paramY).mapTo) ? /** @type {Object} */(paramY).mapTo : 'translateY');
|
|
@@ -218,19 +218,19 @@ class Draggable {
|
|
|
218
218
|
/** @type {Boolean|DraggableCursorParams} */
|
|
219
219
|
this.cursor = false;
|
|
220
220
|
/** @type {Spring} */
|
|
221
|
-
this.releaseXSpring = hasSpring ? /** @type {Spring} */(ease) : spring
|
|
221
|
+
this.releaseXSpring = hasSpring ? /** @type {Spring} */(ease) : index.spring({
|
|
222
222
|
mass: values.setValue(parameters.releaseMass, 1),
|
|
223
223
|
stiffness: values.setValue(parameters.releaseStiffness, 80),
|
|
224
224
|
damping: values.setValue(parameters.releaseDamping, 20),
|
|
225
225
|
});
|
|
226
226
|
/** @type {Spring} */
|
|
227
|
-
this.releaseYSpring = hasSpring ? /** @type {Spring} */(ease) : spring
|
|
227
|
+
this.releaseYSpring = hasSpring ? /** @type {Spring} */(ease) : index.spring({
|
|
228
228
|
mass: values.setValue(parameters.releaseMass, 1),
|
|
229
229
|
stiffness: values.setValue(parameters.releaseStiffness, 80),
|
|
230
230
|
damping: values.setValue(parameters.releaseDamping, 20),
|
|
231
231
|
});
|
|
232
232
|
/** @type {EasingFunction} */
|
|
233
|
-
this.releaseEase = customEase ||
|
|
233
|
+
this.releaseEase = customEase || parser.eases.outQuint;
|
|
234
234
|
/** @type {Boolean} */
|
|
235
235
|
this.hasReleaseSpring = hasSpring;
|
|
236
236
|
/** @type {Callback<this>} */
|
|
@@ -753,7 +753,7 @@ class Draggable {
|
|
|
753
753
|
* @param {EasingParam} [ease]
|
|
754
754
|
* @return {this}
|
|
755
755
|
*/
|
|
756
|
-
scrollInView(duration, gap = 0, ease =
|
|
756
|
+
scrollInView(duration, gap = 0, ease = parser.eases.inOutQuad) {
|
|
757
757
|
this.updateScrollCoords();
|
|
758
758
|
const x = this.destX;
|
|
759
759
|
const y = this.destY;
|
|
@@ -796,7 +796,7 @@ class Draggable {
|
|
|
796
796
|
* @param {EasingParam} [ease]
|
|
797
797
|
* @return {this}
|
|
798
798
|
*/
|
|
799
|
-
animateInView(duration, gap = 0, ease =
|
|
799
|
+
animateInView(duration, gap = 0, ease = parser.eases.inOutQuad) {
|
|
800
800
|
this.stop();
|
|
801
801
|
this.updateBoundingValues();
|
|
802
802
|
const x = this.x;
|
|
@@ -877,7 +877,7 @@ class Draggable {
|
|
|
877
877
|
cursor: /** @type {DraggableCursorParams} */(this.cursor).onGrab
|
|
878
878
|
});
|
|
879
879
|
}
|
|
880
|
-
this.scrollInView(100, 0,
|
|
880
|
+
this.scrollInView(100, 0, parser.eases.out(3));
|
|
881
881
|
this.onGrab(this);
|
|
882
882
|
|
|
883
883
|
consts.doc.addEventListener('touchmove', this);
|
|
@@ -941,8 +941,8 @@ class Draggable {
|
|
|
941
941
|
this.$trigger.addEventListener('touchmove', preventDefault, { passive: false });
|
|
942
942
|
this.$trigger.addEventListener('touchend', preventDefault);
|
|
943
943
|
|
|
944
|
-
|
|
945
|
-
if ((!this.disabled[0] && helpers.abs(movedX) > 3) || (!this.disabled[1] && helpers.abs(movedY) > 3)) {
|
|
944
|
+
// Don't check for a miminim distance move if already dragging
|
|
945
|
+
if (this.dragged || (!this.disabled[0] && helpers.abs(movedX) > 3) || (!this.disabled[1] && helpers.abs(movedY) > 3)) {
|
|
946
946
|
|
|
947
947
|
this.updateTicker.resume();
|
|
948
948
|
this.pointer[2] = this.pointer[0];
|
|
@@ -1008,8 +1008,8 @@ class Draggable {
|
|
|
1008
1008
|
const directionX = dx === cr ? cx > cr ? -1 : 1 : cx < cl ? -1 : 1;
|
|
1009
1009
|
const distanceX = helpers.round(cx - dx, 0);
|
|
1010
1010
|
springX.velocity = disabledY && hasReleaseSpring ? distanceX ? (ds * directionX) / helpers.abs(distanceX) : 0 : pv;
|
|
1011
|
-
const { ease,
|
|
1012
|
-
durationX = cx === dx ? 0 : hasReleaseSpring ?
|
|
1011
|
+
const { ease, settlingDuration, restDuration } = springX;
|
|
1012
|
+
durationX = cx === dx ? 0 : hasReleaseSpring ? settlingDuration : settlingDuration - (restDuration * globals.globals.timeScale);
|
|
1013
1013
|
if (hasReleaseSpring) easeX = ease;
|
|
1014
1014
|
if (durationX > longestReleaseDuration) longestReleaseDuration = durationX;
|
|
1015
1015
|
}
|
|
@@ -1018,8 +1018,8 @@ class Draggable {
|
|
|
1018
1018
|
const directionY = dy === cb ? cy > cb ? -1 : 1 : cy < ct ? -1 : 1;
|
|
1019
1019
|
const distanceY = helpers.round(cy - dy, 0);
|
|
1020
1020
|
springY.velocity = disabledX && hasReleaseSpring ? distanceY ? (ds * directionY) / helpers.abs(distanceY) : 0 : pv;
|
|
1021
|
-
const { ease,
|
|
1022
|
-
durationY = cy === dy ? 0 : hasReleaseSpring ?
|
|
1021
|
+
const { ease, settlingDuration, restDuration } = springY;
|
|
1022
|
+
durationY = cy === dy ? 0 : hasReleaseSpring ? settlingDuration : settlingDuration - (restDuration * globals.globals.timeScale);
|
|
1023
1023
|
if (hasReleaseSpring) easeY = ease;
|
|
1024
1024
|
if (durationY > longestReleaseDuration) longestReleaseDuration = durationY;
|
|
1025
1025
|
}
|
|
@@ -206,7 +206,7 @@ export class Draggable {
|
|
|
206
206
|
}
|
|
207
207
|
export function createDraggable(target: TargetsParam, parameters?: DraggableParams): Draggable;
|
|
208
208
|
import type { DraggableCursorParams } from '../types/index.js';
|
|
209
|
-
import type { Spring } from '../spring/
|
|
209
|
+
import type { Spring } from '../easings/spring/index.js';
|
|
210
210
|
import type { EasingFunction } from '../types/index.js';
|
|
211
211
|
import type { Callback } from '../types/index.js';
|
|
212
212
|
import type { AnimatableObject } from '../types/index.js';
|
|
@@ -15,8 +15,8 @@ import { Timer } from '../timer/timer.js';
|
|
|
15
15
|
import { JSAnimation } from '../animation/animation.js';
|
|
16
16
|
import { removeTargetsFromRenderable } from '../animation/composition.js';
|
|
17
17
|
import { Animatable } from '../animatable/animatable.js';
|
|
18
|
-
import { parseEase, eases } from '../easings/eases.js';
|
|
19
|
-
import {
|
|
18
|
+
import { parseEase, eases } from '../easings/eases/parser.js';
|
|
19
|
+
import { spring } from '../easings/spring/index.js';
|
|
20
20
|
import { get, set } from '../utils/target.js';
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -38,7 +38,7 @@ import { get, set } from '../utils/target.js';
|
|
|
38
38
|
/**
|
|
39
39
|
* @import {
|
|
40
40
|
* Spring,
|
|
41
|
-
* } from '../spring/
|
|
41
|
+
* } from '../easings/spring/index.js'
|
|
42
42
|
*/
|
|
43
43
|
|
|
44
44
|
/**
|
|
@@ -216,13 +216,13 @@ class Draggable {
|
|
|
216
216
|
/** @type {Boolean|DraggableCursorParams} */
|
|
217
217
|
this.cursor = false;
|
|
218
218
|
/** @type {Spring} */
|
|
219
|
-
this.releaseXSpring = hasSpring ? /** @type {Spring} */(ease) :
|
|
219
|
+
this.releaseXSpring = hasSpring ? /** @type {Spring} */(ease) : spring({
|
|
220
220
|
mass: setValue(parameters.releaseMass, 1),
|
|
221
221
|
stiffness: setValue(parameters.releaseStiffness, 80),
|
|
222
222
|
damping: setValue(parameters.releaseDamping, 20),
|
|
223
223
|
});
|
|
224
224
|
/** @type {Spring} */
|
|
225
|
-
this.releaseYSpring = hasSpring ? /** @type {Spring} */(ease) :
|
|
225
|
+
this.releaseYSpring = hasSpring ? /** @type {Spring} */(ease) : spring({
|
|
226
226
|
mass: setValue(parameters.releaseMass, 1),
|
|
227
227
|
stiffness: setValue(parameters.releaseStiffness, 80),
|
|
228
228
|
damping: setValue(parameters.releaseDamping, 20),
|
|
@@ -939,8 +939,8 @@ class Draggable {
|
|
|
939
939
|
this.$trigger.addEventListener('touchmove', preventDefault, { passive: false });
|
|
940
940
|
this.$trigger.addEventListener('touchend', preventDefault);
|
|
941
941
|
|
|
942
|
-
|
|
943
|
-
if ((!this.disabled[0] && abs(movedX) > 3) || (!this.disabled[1] && abs(movedY) > 3)) {
|
|
942
|
+
// Don't check for a miminim distance move if already dragging
|
|
943
|
+
if (this.dragged || (!this.disabled[0] && abs(movedX) > 3) || (!this.disabled[1] && abs(movedY) > 3)) {
|
|
944
944
|
|
|
945
945
|
this.updateTicker.resume();
|
|
946
946
|
this.pointer[2] = this.pointer[0];
|
|
@@ -1006,8 +1006,8 @@ class Draggable {
|
|
|
1006
1006
|
const directionX = dx === cr ? cx > cr ? -1 : 1 : cx < cl ? -1 : 1;
|
|
1007
1007
|
const distanceX = round(cx - dx, 0);
|
|
1008
1008
|
springX.velocity = disabledY && hasReleaseSpring ? distanceX ? (ds * directionX) / abs(distanceX) : 0 : pv;
|
|
1009
|
-
const { ease,
|
|
1010
|
-
durationX = cx === dx ? 0 : hasReleaseSpring ?
|
|
1009
|
+
const { ease, settlingDuration, restDuration } = springX;
|
|
1010
|
+
durationX = cx === dx ? 0 : hasReleaseSpring ? settlingDuration : settlingDuration - (restDuration * globals.timeScale);
|
|
1011
1011
|
if (hasReleaseSpring) easeX = ease;
|
|
1012
1012
|
if (durationX > longestReleaseDuration) longestReleaseDuration = durationX;
|
|
1013
1013
|
}
|
|
@@ -1016,8 +1016,8 @@ class Draggable {
|
|
|
1016
1016
|
const directionY = dy === cb ? cy > cb ? -1 : 1 : cy < ct ? -1 : 1;
|
|
1017
1017
|
const distanceY = round(cy - dy, 0);
|
|
1018
1018
|
springY.velocity = disabledX && hasReleaseSpring ? distanceY ? (ds * directionY) / abs(distanceY) : 0 : pv;
|
|
1019
|
-
const { ease,
|
|
1020
|
-
durationY = cy === dy ? 0 : hasReleaseSpring ?
|
|
1019
|
+
const { ease, settlingDuration, restDuration } = springY;
|
|
1020
|
+
durationY = cy === dy ? 0 : hasReleaseSpring ? settlingDuration : settlingDuration - (restDuration * globals.timeScale);
|
|
1021
1021
|
if (hasReleaseSpring) easeY = ease;
|
|
1022
1022
|
if (durationY > longestReleaseDuration) longestReleaseDuration = durationY;
|
|
1023
1023
|
}
|
|
@@ -7,13 +7,13 @@
|
|
|
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 cubicBezier(mX1?: number, mY1?: number, mX2?: number, mY2?: number): EasingFunction;
|
|
2
|
-
import type { EasingFunction } from '
|
|
2
|
+
import type { EasingFunction } from '../../types/index.js';
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { abs } from '
|
|
9
|
-
import { none } from '
|
|
8
|
+
import { abs } 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
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { eases } from "./parser.js";
|
|
@@ -7,14 +7,9 @@
|
|
|
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';
|
|
@@ -5,14 +5,9 @@
|
|
|
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 };
|
|
@@ -7,18 +7,20 @@
|
|
|
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";
|