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
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { ceil, floor, clamp } from '
|
|
8
|
+
import { ceil, floor, clamp } from '../../core/helpers.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @import {
|
|
12
12
|
* EasingFunction,
|
|
13
|
-
* } from '
|
|
13
|
+
* } from '../../types/index.js'
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -17,7 +17,7 @@ var timer = require('../timer/timer.cjs');
|
|
|
17
17
|
var target = require('../utils/target.cjs');
|
|
18
18
|
var time = require('../utils/time.cjs');
|
|
19
19
|
var none = require('../easings/none.cjs');
|
|
20
|
-
var
|
|
20
|
+
var parser = require('../easings/eases/parser.cjs');
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* @import {
|
|
@@ -368,7 +368,7 @@ class ScrollObserver {
|
|
|
368
368
|
constructor(parameters = {}) {
|
|
369
369
|
if (globals.scope.current) globals.scope.current.register(this);
|
|
370
370
|
const syncMode = values.setValue(parameters.sync, 'play pause');
|
|
371
|
-
const ease = syncMode ?
|
|
371
|
+
const ease = syncMode ? parser.parseEase(/** @type {EasingParam} */(syncMode)) : null;
|
|
372
372
|
const isLinear = syncMode && (syncMode === 'linear' || syncMode === none.none);
|
|
373
373
|
const isEase = syncMode && !(ease === none.none && !isLinear);
|
|
374
374
|
const isSmooth = syncMode && (helpers.isNum(syncMode) || syncMode === true || isLinear);
|
|
@@ -435,6 +435,8 @@ class ScrollObserver {
|
|
|
435
435
|
/** @type {Boolean} */
|
|
436
436
|
this.reverted = false;
|
|
437
437
|
/** @type {Boolean} */
|
|
438
|
+
this.ready = false;
|
|
439
|
+
/** @type {Boolean} */
|
|
438
440
|
this.completed = false;
|
|
439
441
|
/** @type {Boolean} */
|
|
440
442
|
this.began = false;
|
|
@@ -444,8 +446,6 @@ class ScrollObserver {
|
|
|
444
446
|
this.forceEnter = false;
|
|
445
447
|
/** @type {Boolean} */
|
|
446
448
|
this.hasEntered = false;
|
|
447
|
-
// /** @type {Array.<Number>} */
|
|
448
|
-
// this.offsets = [];
|
|
449
449
|
/** @type {Number} */
|
|
450
450
|
this.offset = 0;
|
|
451
451
|
/** @type {Number} */
|
|
@@ -493,6 +493,8 @@ class ScrollObserver {
|
|
|
493
493
|
// Make sure to pause the linked object in case it's added later
|
|
494
494
|
linked.pause();
|
|
495
495
|
this.linked = linked;
|
|
496
|
+
// Forces WAAPI Animation to persist; otherwise, they will stop syncing on finish.
|
|
497
|
+
if (!helpers.isUnd(/** @type {WAAPIAnimation} */(linked))) /** @type {WAAPIAnimation} */(linked).persist = true;
|
|
496
498
|
// Try to use a target of the linked object if no target parameters specified
|
|
497
499
|
if (!this._params.target) {
|
|
498
500
|
/** @type {HTMLElement} */
|
|
@@ -532,6 +534,8 @@ class ScrollObserver {
|
|
|
532
534
|
}
|
|
533
535
|
|
|
534
536
|
refresh() {
|
|
537
|
+
// This flag is used to prevent running handleScroll() outside of this.refresh() with values not yet calculated
|
|
538
|
+
this.ready = true;
|
|
535
539
|
this.reverted = false;
|
|
536
540
|
const params = this._params;
|
|
537
541
|
this.repeat = values.setValue(parseScrollObserverFunctionParameter(params.repeat, this), true);
|
|
@@ -777,8 +781,6 @@ class ScrollObserver {
|
|
|
777
781
|
const offsetStart = parsedEnterTarget + offset - parsedEnterContainer;
|
|
778
782
|
const offsetEnd = parsedLeaveTarget + offset - parsedLeaveContainer;
|
|
779
783
|
const scrollDelta = offsetEnd - offsetStart;
|
|
780
|
-
// this.offsets[0] = offsetX;
|
|
781
|
-
// this.offsets[1] = offsetY;
|
|
782
784
|
this.offset = offset;
|
|
783
785
|
this.offsetStart = offsetStart;
|
|
784
786
|
this.offsetEnd = offsetEnd;
|
|
@@ -797,6 +799,7 @@ class ScrollObserver {
|
|
|
797
799
|
}
|
|
798
800
|
|
|
799
801
|
handleScroll() {
|
|
802
|
+
if (!this.ready) return;
|
|
800
803
|
const linked = this.linked;
|
|
801
804
|
const sync = this.sync;
|
|
802
805
|
const syncEase = this.syncEase;
|
|
@@ -920,6 +923,7 @@ class ScrollObserver {
|
|
|
920
923
|
this.removeDebug();
|
|
921
924
|
}
|
|
922
925
|
this.reverted = true;
|
|
926
|
+
this.ready = false;
|
|
923
927
|
return this;
|
|
924
928
|
}
|
|
925
929
|
|
|
@@ -15,7 +15,7 @@ import { Timer } from '../timer/timer.js';
|
|
|
15
15
|
import { get, set } from '../utils/target.js';
|
|
16
16
|
import { sync } from '../utils/time.js';
|
|
17
17
|
import { none } from '../easings/none.js';
|
|
18
|
-
import { parseEase } from '../easings/eases.js';
|
|
18
|
+
import { parseEase } from '../easings/eases/parser.js';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* @import {
|
|
@@ -433,6 +433,8 @@ class ScrollObserver {
|
|
|
433
433
|
/** @type {Boolean} */
|
|
434
434
|
this.reverted = false;
|
|
435
435
|
/** @type {Boolean} */
|
|
436
|
+
this.ready = false;
|
|
437
|
+
/** @type {Boolean} */
|
|
436
438
|
this.completed = false;
|
|
437
439
|
/** @type {Boolean} */
|
|
438
440
|
this.began = false;
|
|
@@ -442,8 +444,6 @@ class ScrollObserver {
|
|
|
442
444
|
this.forceEnter = false;
|
|
443
445
|
/** @type {Boolean} */
|
|
444
446
|
this.hasEntered = false;
|
|
445
|
-
// /** @type {Array.<Number>} */
|
|
446
|
-
// this.offsets = [];
|
|
447
447
|
/** @type {Number} */
|
|
448
448
|
this.offset = 0;
|
|
449
449
|
/** @type {Number} */
|
|
@@ -491,6 +491,8 @@ class ScrollObserver {
|
|
|
491
491
|
// Make sure to pause the linked object in case it's added later
|
|
492
492
|
linked.pause();
|
|
493
493
|
this.linked = linked;
|
|
494
|
+
// Forces WAAPI Animation to persist; otherwise, they will stop syncing on finish.
|
|
495
|
+
if (!isUnd(/** @type {WAAPIAnimation} */(linked))) /** @type {WAAPIAnimation} */(linked).persist = true;
|
|
494
496
|
// Try to use a target of the linked object if no target parameters specified
|
|
495
497
|
if (!this._params.target) {
|
|
496
498
|
/** @type {HTMLElement} */
|
|
@@ -530,6 +532,8 @@ class ScrollObserver {
|
|
|
530
532
|
}
|
|
531
533
|
|
|
532
534
|
refresh() {
|
|
535
|
+
// This flag is used to prevent running handleScroll() outside of this.refresh() with values not yet calculated
|
|
536
|
+
this.ready = true;
|
|
533
537
|
this.reverted = false;
|
|
534
538
|
const params = this._params;
|
|
535
539
|
this.repeat = setValue(parseScrollObserverFunctionParameter(params.repeat, this), true);
|
|
@@ -775,8 +779,6 @@ class ScrollObserver {
|
|
|
775
779
|
const offsetStart = parsedEnterTarget + offset - parsedEnterContainer;
|
|
776
780
|
const offsetEnd = parsedLeaveTarget + offset - parsedLeaveContainer;
|
|
777
781
|
const scrollDelta = offsetEnd - offsetStart;
|
|
778
|
-
// this.offsets[0] = offsetX;
|
|
779
|
-
// this.offsets[1] = offsetY;
|
|
780
782
|
this.offset = offset;
|
|
781
783
|
this.offsetStart = offsetStart;
|
|
782
784
|
this.offsetEnd = offsetEnd;
|
|
@@ -795,6 +797,7 @@ class ScrollObserver {
|
|
|
795
797
|
}
|
|
796
798
|
|
|
797
799
|
handleScroll() {
|
|
800
|
+
if (!this.ready) return;
|
|
798
801
|
const linked = this.linked;
|
|
799
802
|
const sync = this.sync;
|
|
800
803
|
const syncEase = this.syncEase;
|
|
@@ -918,6 +921,7 @@ class ScrollObserver {
|
|
|
918
921
|
this.removeDebug();
|
|
919
922
|
}
|
|
920
923
|
this.reverted = true;
|
|
924
|
+
this.ready = false;
|
|
921
925
|
return this;
|
|
922
926
|
}
|
|
923
927
|
|
package/dist/modules/index.cjs
CHANGED
|
@@ -14,19 +14,18 @@ var animatable = require('./animatable/animatable.cjs');
|
|
|
14
14
|
var draggable = require('./draggable/draggable.cjs');
|
|
15
15
|
var scope = require('./scope/scope.cjs');
|
|
16
16
|
var scroll = require('./events/scroll.cjs');
|
|
17
|
-
var spring = require('./spring/spring.cjs');
|
|
18
17
|
var engine = require('./engine/engine.cjs');
|
|
19
18
|
var index = require('./easings/index.cjs');
|
|
20
19
|
var index$1 = require('./utils/index.cjs');
|
|
21
20
|
var index$2 = require('./svg/index.cjs');
|
|
22
21
|
var index$3 = require('./text/index.cjs');
|
|
23
22
|
var waapi = require('./waapi/waapi.cjs');
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
var
|
|
23
|
+
var index$4 = require('./easings/cubic-bezier/index.cjs');
|
|
24
|
+
var index$5 = require('./easings/steps/index.cjs');
|
|
25
|
+
var index$6 = require('./easings/linear/index.cjs');
|
|
26
|
+
var index$7 = require('./easings/irregular/index.cjs');
|
|
27
|
+
var index$8 = require('./easings/spring/index.cjs');
|
|
28
|
+
var parser = require('./easings/eases/parser.cjs');
|
|
30
29
|
var chainable = require('./utils/chainable.cjs');
|
|
31
30
|
var random = require('./utils/random.cjs');
|
|
32
31
|
var time = require('./utils/time.cjs');
|
|
@@ -56,8 +55,6 @@ exports.createScope = scope.createScope;
|
|
|
56
55
|
exports.ScrollObserver = scroll.ScrollObserver;
|
|
57
56
|
exports.onScroll = scroll.onScroll;
|
|
58
57
|
exports.scrollContainers = scroll.scrollContainers;
|
|
59
|
-
exports.Spring = spring.Spring;
|
|
60
|
-
exports.createSpring = spring.createSpring;
|
|
61
58
|
exports.engine = engine.engine;
|
|
62
59
|
exports.easings = index;
|
|
63
60
|
exports.utils = index$1;
|
|
@@ -65,12 +62,14 @@ exports.svg = index$2;
|
|
|
65
62
|
exports.text = index$3;
|
|
66
63
|
exports.WAAPIAnimation = waapi.WAAPIAnimation;
|
|
67
64
|
exports.waapi = waapi.waapi;
|
|
68
|
-
exports.
|
|
69
|
-
exports.
|
|
70
|
-
exports.
|
|
71
|
-
exports.
|
|
72
|
-
exports.
|
|
73
|
-
exports.
|
|
65
|
+
exports.cubicBezier = index$4.cubicBezier;
|
|
66
|
+
exports.steps = index$5.steps;
|
|
67
|
+
exports.linear = index$6.linear;
|
|
68
|
+
exports.irregular = index$7.irregular;
|
|
69
|
+
exports.Spring = index$8.Spring;
|
|
70
|
+
exports.createSpring = index$8.createSpring;
|
|
71
|
+
exports.spring = index$8.spring;
|
|
72
|
+
exports.eases = parser.eases;
|
|
74
73
|
exports.clamp = chainable.clamp;
|
|
75
74
|
exports.damp = chainable.damp;
|
|
76
75
|
exports.degToRad = chainable.degToRad;
|
package/dist/modules/index.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ export * from "./animatable/index.js";
|
|
|
5
5
|
export * from "./draggable/index.js";
|
|
6
6
|
export * from "./scope/index.js";
|
|
7
7
|
export * from "./events/index.js";
|
|
8
|
-
export * from "./spring/index.js";
|
|
9
8
|
export * from "./engine/index.js";
|
|
10
9
|
export * from "./easings/index.js";
|
|
11
10
|
export * from "./utils/index.js";
|
package/dist/modules/index.js
CHANGED
|
@@ -12,7 +12,6 @@ export { Animatable, createAnimatable } from './animatable/animatable.js';
|
|
|
12
12
|
export { Draggable, createDraggable } from './draggable/draggable.js';
|
|
13
13
|
export { Scope, createScope } from './scope/scope.js';
|
|
14
14
|
export { ScrollObserver, onScroll, scrollContainers } from './events/scroll.js';
|
|
15
|
-
export { Spring, createSpring } from './spring/spring.js';
|
|
16
15
|
export { engine } from './engine/engine.js';
|
|
17
16
|
import * as index from './easings/index.js';
|
|
18
17
|
export { index as easings };
|
|
@@ -23,12 +22,12 @@ export { index$2 as svg };
|
|
|
23
22
|
import * as index$3 from './text/index.js';
|
|
24
23
|
export { index$3 as text };
|
|
25
24
|
export { WAAPIAnimation, waapi } from './waapi/waapi.js';
|
|
26
|
-
export {
|
|
27
|
-
export {
|
|
28
|
-
export {
|
|
29
|
-
export {
|
|
30
|
-
export {
|
|
31
|
-
export { eases } from './easings/eases.js';
|
|
25
|
+
export { cubicBezier } from './easings/cubic-bezier/index.js';
|
|
26
|
+
export { steps } from './easings/steps/index.js';
|
|
27
|
+
export { linear } from './easings/linear/index.js';
|
|
28
|
+
export { irregular } from './easings/irregular/index.js';
|
|
29
|
+
export { Spring, createSpring, spring } from './easings/spring/index.js';
|
|
30
|
+
export { eases } from './easings/eases/parser.js';
|
|
32
31
|
export { clamp, damp, degToRad, lerp, mapRange, padEnd, padStart, radToDeg, round, roundPad, snap, wrap } from './utils/chainable.js';
|
|
33
32
|
export { createSeededRandom, random, randomPick, shuffle } from './utils/random.js';
|
|
34
33
|
export { keepTime, sync } from './utils/time.js';
|
|
@@ -17,7 +17,7 @@ var styles = require('../core/styles.cjs');
|
|
|
17
17
|
var composition = require('../animation/composition.cjs');
|
|
18
18
|
var animation = require('../animation/animation.cjs');
|
|
19
19
|
var timer = require('../timer/timer.cjs');
|
|
20
|
-
var
|
|
20
|
+
var parser = require('../easings/eases/parser.cjs');
|
|
21
21
|
var position = require('./position.cjs');
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -111,7 +111,7 @@ class Timeline extends timer.Timer {
|
|
|
111
111
|
/** @type {Callback<this>} */
|
|
112
112
|
this.onRender = parameters.onRender || globalDefaults.onRender;
|
|
113
113
|
const tlPlaybackEase = values.setValue(parameters.playbackEase, globalDefaults.playbackEase);
|
|
114
|
-
this._ease = tlPlaybackEase ?
|
|
114
|
+
this._ease = tlPlaybackEase ? parser.parseEase(tlPlaybackEase) : null;
|
|
115
115
|
/** @type {Number} */
|
|
116
116
|
this.iterationDuration = 0;
|
|
117
117
|
}
|
|
@@ -15,7 +15,7 @@ import { cleanInlineStyles } from '../core/styles.js';
|
|
|
15
15
|
import { removeTargetsFromRenderable } from '../animation/composition.js';
|
|
16
16
|
import { JSAnimation } from '../animation/animation.js';
|
|
17
17
|
import { Timer } from '../timer/timer.js';
|
|
18
|
-
import { parseEase } from '../easings/eases.js';
|
|
18
|
+
import { parseEase } from '../easings/eases/parser.js';
|
|
19
19
|
import { parseTimelinePosition } from './position.js';
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -7,6 +7,7 @@ export type DefaultsParams = {
|
|
|
7
7
|
loop?: number | boolean;
|
|
8
8
|
reversed?: boolean;
|
|
9
9
|
alternate?: boolean;
|
|
10
|
+
persist?: boolean;
|
|
10
11
|
autoplay?: boolean | ScrollObserver;
|
|
11
12
|
duration?: number | FunctionValue;
|
|
12
13
|
delay?: number | FunctionValue;
|
|
@@ -14,13 +15,13 @@ export type DefaultsParams = {
|
|
|
14
15
|
ease?: EasingParam;
|
|
15
16
|
composition?: "none" | "replace" | "blend" | compositionTypes;
|
|
16
17
|
modifier?: (v: any) => any;
|
|
17
|
-
onBegin?:
|
|
18
|
-
onBeforeUpdate?:
|
|
19
|
-
onUpdate?:
|
|
20
|
-
onLoop?:
|
|
21
|
-
onPause?:
|
|
22
|
-
onComplete?:
|
|
23
|
-
onRender?:
|
|
18
|
+
onBegin?: Callback<Tickable>;
|
|
19
|
+
onBeforeUpdate?: Callback<Tickable>;
|
|
20
|
+
onUpdate?: Callback<Tickable>;
|
|
21
|
+
onLoop?: Callback<Tickable>;
|
|
22
|
+
onPause?: Callback<Tickable>;
|
|
23
|
+
onComplete?: Callback<Tickable>;
|
|
24
|
+
onRender?: Callback<Renderable>;
|
|
24
25
|
};
|
|
25
26
|
export type Renderable = JSAnimation | Timeline;
|
|
26
27
|
export type Tickable = Timer | Renderable;
|
|
@@ -50,12 +51,14 @@ export type JSTargetsArray = Array<JSTarget>;
|
|
|
50
51
|
export type TargetsParam = Array<TargetSelector> | TargetSelector;
|
|
51
52
|
export type TargetsArray = Array<Target>;
|
|
52
53
|
export type EasingFunction = (time: number) => number;
|
|
53
|
-
export type EaseStringParamNames = ("linear" | "
|
|
54
|
+
export type EaseStringParamNames = ("linear" | "none" | "in" | "out" | "inOut" | "inQuad" | "outQuad" | "inOutQuad" | "inCubic" | "outCubic" | "inOutCubic" | "inQuart" | "outQuart" | "inOutQuart" | "inQuint" | "outQuint" | "inOutQuint" | "inSine" | "outSine" | "inOutSine" | "inCirc" | "outCirc" | "inOutCirc" | "inExpo" | "outExpo" | "inOutExpo" | "inBounce" | "outBounce" | "inOutBounce" | "inBack" | "outBack" | "inOutBack" | "inElastic" | "outElastic" | "inOutElastic" | "out(p = 1.675)" | "inOut(p = 1.675)" | "inBack(overshoot = 1.7)" | "outBack(overshoot = 1.7)" | "inOutBack(overshoot = 1.7)" | "inElastic(amplitude = 1, period = .3)" | "outElastic(amplitude = 1, period = .3)" | "inOutElastic(amplitude = 1, period = .3)");
|
|
55
|
+
export type WAAPIEaseStringParamNames = ("ease" | "ease-in" | "ease-out" | "ease-in-out" | "linear(0, 0.25, 1)" | "steps" | "steps(6, start)" | "step-start" | "step-end" | "cubic-bezier(0.42, 0, 1, 1)");
|
|
54
56
|
export type PowerEasing = (power?: number | string) => EasingFunction;
|
|
55
57
|
export type BackEasing = (overshoot?: number | string) => EasingFunction;
|
|
56
58
|
export type ElasticEasing = (amplitude?: number | string, period?: number | string) => EasingFunction;
|
|
57
59
|
export type EasingFunctionWithParams = PowerEasing | BackEasing | ElasticEasing;
|
|
58
60
|
export type EasingParam = (string & {}) | EaseStringParamNames | EasingFunction | Spring;
|
|
61
|
+
export type WAAPIEasingParam = (string & {}) | EaseStringParamNames | WAAPIEaseStringParamNames | EasingFunction | Spring;
|
|
59
62
|
export type SpringParams = {
|
|
60
63
|
/**
|
|
61
64
|
* - Mass, default 1
|
|
@@ -73,6 +76,18 @@ export type SpringParams = {
|
|
|
73
76
|
* - Initial velocity, default 0
|
|
74
77
|
*/
|
|
75
78
|
velocity?: number;
|
|
79
|
+
/**
|
|
80
|
+
* - Initial bounce, default 0
|
|
81
|
+
*/
|
|
82
|
+
bounce?: number;
|
|
83
|
+
/**
|
|
84
|
+
* - The perceived duration, default 0
|
|
85
|
+
*/
|
|
86
|
+
duration?: number;
|
|
87
|
+
/**
|
|
88
|
+
* - Callback function called when the spring currentTime hits the perceived duration
|
|
89
|
+
*/
|
|
90
|
+
onComplete?: Callback<JSAnimation>;
|
|
76
91
|
};
|
|
77
92
|
export type Callback<T> = (self: T, e?: PointerEvent) => any;
|
|
78
93
|
export type TickableCallbacks<T extends unknown> = {
|
|
@@ -131,6 +146,7 @@ export type Tween = {
|
|
|
131
146
|
_isOverlapped: number;
|
|
132
147
|
_isOverridden: number;
|
|
133
148
|
_renderTransforms: number;
|
|
149
|
+
_inlineValue: string;
|
|
134
150
|
_prevRep: Tween;
|
|
135
151
|
_nextRep: Tween;
|
|
136
152
|
_prevAdd: Tween;
|
|
@@ -238,13 +254,13 @@ export type TimelineParams = TimerOptions & TimelineOptions & TickableCallbacks<
|
|
|
238
254
|
export type WAAPITweenValue = string | number | Array<string> | Array<number>;
|
|
239
255
|
export type WAAPIFunctionValue = (target: DOMTarget, index: number, length: number) => WAAPITweenValue;
|
|
240
256
|
export type WAAPIKeyframeValue = WAAPITweenValue | WAAPIFunctionValue | Array<string | number | WAAPIFunctionValue>;
|
|
241
|
-
export type WAAPICallback =
|
|
257
|
+
export type WAAPICallback = Callback<WAAPIAnimation>;
|
|
242
258
|
export type WAAPITweenOptions = {
|
|
243
259
|
to?: WAAPIKeyframeValue;
|
|
244
260
|
from?: WAAPIKeyframeValue;
|
|
245
261
|
duration?: number | WAAPIFunctionValue;
|
|
246
262
|
delay?: number | WAAPIFunctionValue;
|
|
247
|
-
ease?:
|
|
263
|
+
ease?: WAAPIEasingParam;
|
|
248
264
|
composition?: CompositeOperation;
|
|
249
265
|
};
|
|
250
266
|
export type WAAPIAnimationOptions = {
|
|
@@ -255,11 +271,12 @@ export type WAAPIAnimationOptions = {
|
|
|
255
271
|
playbackRate?: number;
|
|
256
272
|
duration?: number | WAAPIFunctionValue;
|
|
257
273
|
delay?: number | WAAPIFunctionValue;
|
|
258
|
-
ease?:
|
|
274
|
+
ease?: WAAPIEasingParam;
|
|
259
275
|
composition?: CompositeOperation;
|
|
276
|
+
persist?: boolean;
|
|
260
277
|
onComplete?: WAAPICallback;
|
|
261
278
|
};
|
|
262
|
-
export type WAAPIAnimationParams = Record<string, WAAPIKeyframeValue | WAAPIAnimationOptions | boolean | ScrollObserver | WAAPICallback |
|
|
279
|
+
export type WAAPIAnimationParams = Record<string, WAAPIKeyframeValue | WAAPIAnimationOptions | boolean | ScrollObserver | WAAPICallback | WAAPIEasingParam | WAAPITweenOptions> & WAAPIAnimationOptions;
|
|
263
280
|
export type AnimatablePropertySetter = (to: number | Array<number>, duration?: number, ease?: EasingParam) => AnimatableObject;
|
|
264
281
|
export type AnimatablePropertyGetter = () => number | Array<number>;
|
|
265
282
|
export type AnimatableProperty = AnimatablePropertySetter & AnimatablePropertyGetter;
|
|
@@ -382,6 +399,6 @@ import type { WAAPIAnimation } from '../waapi/waapi.js';
|
|
|
382
399
|
import type { Draggable } from '../draggable/draggable.js';
|
|
383
400
|
import type { TextSplitter } from '../text/split.js';
|
|
384
401
|
import type { Scope } from '../scope/scope.js';
|
|
385
|
-
import type { Spring } from '../spring/
|
|
402
|
+
import type { Spring } from '../easings/spring/index.js';
|
|
386
403
|
import type { tweenTypes } from '../core/consts.js';
|
|
387
404
|
import type { valueTypes } from '../core/consts.js';
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
var consts = require('../core/consts.cjs');
|
|
11
11
|
var helpers = require('../core/helpers.cjs');
|
|
12
|
-
var
|
|
12
|
+
var parser = require('../easings/eases/parser.cjs');
|
|
13
13
|
var position = require('../timeline/position.cjs');
|
|
14
14
|
var values = require('../core/values.cjs');
|
|
15
15
|
var targets = require('../core/targets.cjs');
|
|
@@ -25,7 +25,7 @@ var random = require('./random.cjs');
|
|
|
25
25
|
/**
|
|
26
26
|
* @import {
|
|
27
27
|
* Spring,
|
|
28
|
-
* } from '../spring/
|
|
28
|
+
* } from '../easings/spring/index.js'
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
31
|
/**
|
|
@@ -65,7 +65,7 @@ const stagger = (val, params = {}) => {
|
|
|
65
65
|
const ease = params.ease;
|
|
66
66
|
const hasEasing = !helpers.isUnd(ease);
|
|
67
67
|
const hasSpring = hasEasing && !helpers.isUnd(/** @type {Spring} */(ease).ease);
|
|
68
|
-
const staggerEase = hasSpring ? /** @type {Spring} */(ease).ease : hasEasing ?
|
|
68
|
+
const staggerEase = hasSpring ? /** @type {Spring} */(ease).ease : hasEasing ? parser.parseEase(ease) : null;
|
|
69
69
|
const grid = params.grid;
|
|
70
70
|
const axis = params.axis;
|
|
71
71
|
const customTotal = params.total;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { unitsExecRgx, emptyString } from '../core/consts.js';
|
|
9
9
|
import { isUnd, parseNumber, isFnc, abs, floor, sqrt, round, isArr, isNum, isStr, max } from '../core/helpers.js';
|
|
10
|
-
import { parseEase } from '../easings/eases.js';
|
|
10
|
+
import { parseEase } from '../easings/eases/parser.js';
|
|
11
11
|
import { parseTimelinePosition } from '../timeline/position.js';
|
|
12
12
|
import { getOriginalAnimatableValue } from '../core/values.js';
|
|
13
13
|
import { registerTargets } from '../core/targets.js';
|
|
@@ -23,7 +23,7 @@ import { shuffle } from './random.js';
|
|
|
23
23
|
/**
|
|
24
24
|
* @import {
|
|
25
25
|
* Spring,
|
|
26
|
-
* } from '../spring/
|
|
26
|
+
* } from '../easings/spring/index.js'
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
29
|
/**
|
|
@@ -30,16 +30,18 @@ const WAAPIAnimationsLookups = {
|
|
|
30
30
|
* @param {DOMTarget} $el
|
|
31
31
|
* @param {String} [property]
|
|
32
32
|
* @param {WAAPIAnimation} [parent]
|
|
33
|
+
* @return {globalThis.Animation}
|
|
33
34
|
*/
|
|
34
35
|
const removeWAAPIAnimation = ($el, property, parent) => {
|
|
35
36
|
let nextLookup = WAAPIAnimationsLookups._head;
|
|
37
|
+
let anim;
|
|
36
38
|
while (nextLookup) {
|
|
37
39
|
const next = nextLookup._next;
|
|
38
40
|
const matchTarget = nextLookup.$el === $el;
|
|
39
41
|
const matchProperty = !property || nextLookup.property === property;
|
|
40
42
|
const matchParent = !parent || nextLookup.parent === parent;
|
|
41
43
|
if (matchTarget && matchProperty && matchParent) {
|
|
42
|
-
|
|
44
|
+
anim = nextLookup.animation;
|
|
43
45
|
try { anim.commitStyles(); } catch {} anim.cancel();
|
|
44
46
|
helpers.removeChild(WAAPIAnimationsLookups, nextLookup);
|
|
45
47
|
const lookupParent = nextLookup.parent;
|
|
@@ -47,8 +49,8 @@ const removeWAAPIAnimation = ($el, property, parent) => {
|
|
|
47
49
|
lookupParent._completed++;
|
|
48
50
|
if (lookupParent.animations.length === lookupParent._completed) {
|
|
49
51
|
lookupParent.completed = true;
|
|
52
|
+
lookupParent.paused = true;
|
|
50
53
|
if (!lookupParent.muteCallbacks) {
|
|
51
|
-
lookupParent.paused = true;
|
|
52
54
|
lookupParent.onComplete(lookupParent);
|
|
53
55
|
lookupParent._resolve(lookupParent);
|
|
54
56
|
}
|
|
@@ -57,6 +59,7 @@ const removeWAAPIAnimation = ($el, property, parent) => {
|
|
|
57
59
|
}
|
|
58
60
|
nextLookup = next;
|
|
59
61
|
}
|
|
62
|
+
return anim;
|
|
60
63
|
};
|
|
61
64
|
|
|
62
65
|
/**
|
|
@@ -65,7 +68,7 @@ const removeWAAPIAnimation = ($el, property, parent) => {
|
|
|
65
68
|
* @param {String} property
|
|
66
69
|
* @param {PropertyIndexedKeyframes} keyframes
|
|
67
70
|
* @param {KeyframeAnimationOptions} params
|
|
68
|
-
* @retun {Animation}
|
|
71
|
+
* @retun {globalThis.Animation}
|
|
69
72
|
*/
|
|
70
73
|
const addWAAPIAnimation = (parent, $el, property, keyframes, params) => {
|
|
71
74
|
const animation = $el.animate(keyframes, params);
|
|
@@ -80,8 +83,11 @@ const addWAAPIAnimation = (parent, $el, property, keyframes, params) => {
|
|
|
80
83
|
removeWAAPIAnimation($el, property);
|
|
81
84
|
helpers.addChild(WAAPIAnimationsLookups, { parent, animation, $el, property, _next: null, _prev: null });
|
|
82
85
|
const handleRemove = () => { removeWAAPIAnimation($el, property, parent); };
|
|
86
|
+
animation.oncancel = handleRemove;
|
|
83
87
|
animation.onremove = handleRemove;
|
|
84
|
-
|
|
88
|
+
if (!parent.persist) {
|
|
89
|
+
animation.onfinish = handleRemove;
|
|
90
|
+
}
|
|
85
91
|
return animation;
|
|
86
92
|
};
|
|
87
93
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function removeWAAPIAnimation($el: DOMTarget, property?: string, parent?: WAAPIAnimation):
|
|
1
|
+
export function removeWAAPIAnimation($el: DOMTarget, property?: string, parent?: WAAPIAnimation): globalThis.Animation;
|
|
2
2
|
export function addWAAPIAnimation(parent: WAAPIAnimation, $el: DOMTarget, property: string, keyframes: PropertyIndexedKeyframes, params: KeyframeAnimationOptions): Animation;
|
|
3
3
|
import type { DOMTarget } from '../types/index.js';
|
|
4
4
|
import type { WAAPIAnimation } from '../waapi/waapi.js';
|
|
@@ -28,16 +28,18 @@ const WAAPIAnimationsLookups = {
|
|
|
28
28
|
* @param {DOMTarget} $el
|
|
29
29
|
* @param {String} [property]
|
|
30
30
|
* @param {WAAPIAnimation} [parent]
|
|
31
|
+
* @return {globalThis.Animation}
|
|
31
32
|
*/
|
|
32
33
|
const removeWAAPIAnimation = ($el, property, parent) => {
|
|
33
34
|
let nextLookup = WAAPIAnimationsLookups._head;
|
|
35
|
+
let anim;
|
|
34
36
|
while (nextLookup) {
|
|
35
37
|
const next = nextLookup._next;
|
|
36
38
|
const matchTarget = nextLookup.$el === $el;
|
|
37
39
|
const matchProperty = !property || nextLookup.property === property;
|
|
38
40
|
const matchParent = !parent || nextLookup.parent === parent;
|
|
39
41
|
if (matchTarget && matchProperty && matchParent) {
|
|
40
|
-
|
|
42
|
+
anim = nextLookup.animation;
|
|
41
43
|
try { anim.commitStyles(); } catch {} anim.cancel();
|
|
42
44
|
removeChild(WAAPIAnimationsLookups, nextLookup);
|
|
43
45
|
const lookupParent = nextLookup.parent;
|
|
@@ -45,8 +47,8 @@ const removeWAAPIAnimation = ($el, property, parent) => {
|
|
|
45
47
|
lookupParent._completed++;
|
|
46
48
|
if (lookupParent.animations.length === lookupParent._completed) {
|
|
47
49
|
lookupParent.completed = true;
|
|
50
|
+
lookupParent.paused = true;
|
|
48
51
|
if (!lookupParent.muteCallbacks) {
|
|
49
|
-
lookupParent.paused = true;
|
|
50
52
|
lookupParent.onComplete(lookupParent);
|
|
51
53
|
lookupParent._resolve(lookupParent);
|
|
52
54
|
}
|
|
@@ -55,6 +57,7 @@ const removeWAAPIAnimation = ($el, property, parent) => {
|
|
|
55
57
|
}
|
|
56
58
|
nextLookup = next;
|
|
57
59
|
}
|
|
60
|
+
return anim;
|
|
58
61
|
};
|
|
59
62
|
|
|
60
63
|
/**
|
|
@@ -63,7 +66,7 @@ const removeWAAPIAnimation = ($el, property, parent) => {
|
|
|
63
66
|
* @param {String} property
|
|
64
67
|
* @param {PropertyIndexedKeyframes} keyframes
|
|
65
68
|
* @param {KeyframeAnimationOptions} params
|
|
66
|
-
* @retun {Animation}
|
|
69
|
+
* @retun {globalThis.Animation}
|
|
67
70
|
*/
|
|
68
71
|
const addWAAPIAnimation = (parent, $el, property, keyframes, params) => {
|
|
69
72
|
const animation = $el.animate(keyframes, params);
|
|
@@ -78,8 +81,11 @@ const addWAAPIAnimation = (parent, $el, property, keyframes, params) => {
|
|
|
78
81
|
removeWAAPIAnimation($el, property);
|
|
79
82
|
addChild(WAAPIAnimationsLookups, { parent, animation, $el, property, _next: null, _prev: null });
|
|
80
83
|
const handleRemove = () => { removeWAAPIAnimation($el, property, parent); };
|
|
84
|
+
animation.oncancel = handleRemove;
|
|
81
85
|
animation.onremove = handleRemove;
|
|
82
|
-
|
|
86
|
+
if (!parent.persist) {
|
|
87
|
+
animation.onfinish = handleRemove;
|
|
88
|
+
}
|
|
83
89
|
return animation;
|
|
84
90
|
};
|
|
85
91
|
|