animejs 4.2.2 → 4.3.0-beta.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 +82 -28
- package/dist/bundles/anime.esm.js +2705 -1303
- package/dist/bundles/anime.esm.min.js +2 -2
- package/dist/bundles/anime.umd.js +2710 -1306
- package/dist/bundles/anime.umd.min.js +2 -2
- package/dist/modules/animatable/animatable.cjs +1 -1
- package/dist/modules/animatable/animatable.js +1 -1
- 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 +18 -9
- package/dist/modules/animation/animation.js +19 -10
- 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 +10 -10
- package/dist/modules/core/clock.d.ts +1 -1
- package/dist/modules/core/clock.js +10 -10
- package/dist/modules/core/colors.cjs +1 -1
- package/dist/modules/core/colors.js +1 -1
- package/dist/modules/core/consts.cjs +6 -4
- package/dist/modules/core/consts.d.ts +13 -5
- package/dist/modules/core/consts.js +6 -4
- package/dist/modules/core/globals.cjs +5 -2
- package/dist/modules/core/globals.d.ts +1 -0
- package/dist/modules/core/globals.js +5 -3
- package/dist/modules/core/helpers.cjs +1 -1
- package/dist/modules/core/helpers.js +1 -1
- package/dist/modules/core/render.cjs +1 -1
- package/dist/modules/core/render.js +1 -1
- package/dist/modules/core/styles.cjs +1 -1
- package/dist/modules/core/styles.js +1 -1
- 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 +1 -1
- package/dist/modules/core/values.js +1 -1
- package/dist/modules/draggable/draggable.cjs +1 -1
- package/dist/modules/draggable/draggable.js +1 -1
- package/dist/modules/draggable/index.cjs +1 -1
- package/dist/modules/draggable/index.js +1 -1
- package/dist/modules/easings/cubic-bezier/index.cjs +1 -1
- package/dist/modules/easings/cubic-bezier/index.js +1 -1
- package/dist/modules/easings/eases/index.cjs +1 -1
- package/dist/modules/easings/eases/index.js +1 -1
- package/dist/modules/easings/eases/parser.cjs +1 -1
- package/dist/modules/easings/eases/parser.js +1 -1
- package/dist/modules/easings/index.cjs +1 -1
- package/dist/modules/easings/index.js +1 -1
- package/dist/modules/easings/irregular/index.cjs +1 -1
- package/dist/modules/easings/irregular/index.js +1 -1
- package/dist/modules/easings/linear/index.cjs +1 -1
- package/dist/modules/easings/linear/index.js +1 -1
- package/dist/modules/easings/none.cjs +1 -1
- package/dist/modules/easings/none.js +1 -1
- package/dist/modules/easings/spring/index.cjs +1 -1
- package/dist/modules/easings/spring/index.js +1 -1
- package/dist/modules/easings/steps/index.cjs +1 -1
- package/dist/modules/easings/steps/index.js +1 -1
- package/dist/modules/engine/engine.cjs +2 -2
- package/dist/modules/engine/engine.js +2 -2
- 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 +1 -1
- package/dist/modules/events/scroll.js +1 -1
- package/dist/modules/index.cjs +4 -1
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +2 -1
- package/dist/modules/layout/index.cjs +15 -0
- package/dist/modules/layout/index.d.ts +1 -0
- package/dist/modules/layout/index.js +8 -0
- package/dist/modules/layout/layout.cjs +1384 -0
- package/dist/modules/layout/layout.d.ts +211 -0
- package/dist/modules/layout/layout.js +1381 -0
- 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 +1 -1
- package/dist/modules/svg/morphto.js +1 -1
- package/dist/modules/svg/motionpath.cjs +1 -1
- package/dist/modules/svg/motionpath.js +1 -1
- package/dist/modules/text/index.cjs +1 -1
- package/dist/modules/text/index.js +1 -1
- package/dist/modules/text/split.cjs +23 -9
- package/dist/modules/text/split.js +23 -9
- 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 +14 -6
- package/dist/modules/timeline/timeline.d.ts +2 -0
- package/dist/modules/timeline/timeline.js +15 -7
- package/dist/modules/timer/index.cjs +1 -1
- package/dist/modules/timer/index.js +1 -1
- package/dist/modules/timer/timer.cjs +26 -13
- package/dist/modules/timer/timer.d.ts +1 -0
- package/dist/modules/timer/timer.js +27 -14
- package/dist/modules/types/index.d.ts +3 -1
- 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 +1 -1
- package/dist/modules/utils/stagger.js +1 -1
- 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 +1 -1
- package/dist/modules/waapi/composition.js +1 -1
- package/dist/modules/waapi/index.cjs +1 -1
- package/dist/modules/waapi/index.js +1 -1
- package/dist/modules/waapi/waapi.cjs +15 -7
- package/dist/modules/waapi/waapi.js +16 -8
- package/package.json +8 -2
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - timer - ESM
|
|
3
|
-
* @version v4.
|
|
3
|
+
* @version v4.3.0-beta.0
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { minValue, noop, maxValue, compositionTypes, tickModes } from '../core/consts.js';
|
|
9
9
|
import { isFnc, isUnd, now, clampInfinity, clamp, round, forEachChildren, addChild, normalizeTime, floor } from '../core/helpers.js';
|
|
10
|
-
import { globals, scope } from '../core/globals.js';
|
|
10
|
+
import { globals, devTools, scope } from '../core/globals.js';
|
|
11
11
|
import { setValue } from '../core/values.js';
|
|
12
12
|
import { tick } from '../core/render.js';
|
|
13
13
|
import { removeTweenSliblings, composeTween, getTweenSiblings } from '../animation/composition.js';
|
|
@@ -80,6 +80,8 @@ class Timer extends Clock {
|
|
|
80
80
|
|
|
81
81
|
super(0);
|
|
82
82
|
|
|
83
|
+
++timerId;
|
|
84
|
+
|
|
83
85
|
const {
|
|
84
86
|
id,
|
|
85
87
|
delay,
|
|
@@ -101,31 +103,42 @@ class Timer extends Clock {
|
|
|
101
103
|
|
|
102
104
|
if (scope.current) scope.current.register(this);
|
|
103
105
|
|
|
104
|
-
const timerInitTime = parent ? 0 : engine.
|
|
106
|
+
const timerInitTime = parent ? 0 : engine._lastTickTime;
|
|
105
107
|
const timerDefaults = parent ? parent.defaults : globals.defaults;
|
|
106
108
|
const timerDelay = /** @type {Number} */(isFnc(delay) || isUnd(delay) ? timerDefaults.delay : +delay);
|
|
107
109
|
const timerDuration = isFnc(duration) || isUnd(duration) ? Infinity : +duration;
|
|
108
110
|
const timerLoop = setValue(loop, timerDefaults.loop);
|
|
109
111
|
const timerLoopDelay = setValue(loopDelay, timerDefaults.loopDelay);
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
let timerIterationCount = timerLoop === true ||
|
|
113
|
+
timerLoop === Infinity ||
|
|
114
|
+
/** @type {Number} */(timerLoop) < 0 ? Infinity :
|
|
115
|
+
/** @type {Number} */(timerLoop) + 1;
|
|
116
|
+
|
|
117
|
+
if (devTools) {
|
|
118
|
+
const isInfinite = timerIterationCount === Infinity;
|
|
119
|
+
const registered = devTools.register(this, parameters, isInfinite);
|
|
120
|
+
if (registered && isInfinite) {
|
|
121
|
+
const minIterations = alternate ? 2 : 1;
|
|
122
|
+
const iterations = parent ? devTools.maxNestedInfiniteLoops : devTools.maxInfiniteLoops;
|
|
123
|
+
timerIterationCount = Math.max(iterations, minIterations);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
114
126
|
|
|
115
127
|
let offsetPosition = 0;
|
|
116
128
|
|
|
117
129
|
if (parent) {
|
|
118
130
|
offsetPosition = parentPosition;
|
|
119
131
|
} else {
|
|
120
|
-
// Make sure to tick the engine once if not currently running to get up to date engine.
|
|
132
|
+
// Make sure to tick the engine once if not currently running to get up to date engine._lastTickTime
|
|
121
133
|
// to avoid big gaps with the following offsetPosition calculation
|
|
122
134
|
if (!engine.reqId) engine.requestTick(now());
|
|
123
135
|
// Make sure to scale the offset position with globals.timeScale to properly handle seconds unit
|
|
124
|
-
offsetPosition = (engine.
|
|
136
|
+
offsetPosition = (engine._lastTickTime - engine._startTime) * globals.timeScale;
|
|
125
137
|
}
|
|
126
138
|
|
|
127
139
|
// Timer's parameters
|
|
128
|
-
|
|
140
|
+
/** @type {String|Number} */
|
|
141
|
+
this.id = !isUnd(id) ? id : timerId;
|
|
129
142
|
/** @type {Timeline} */
|
|
130
143
|
this.parent = parent;
|
|
131
144
|
// Total duration of the timer
|
|
@@ -185,7 +198,7 @@ class Timer extends Clock {
|
|
|
185
198
|
|
|
186
199
|
// Clock's parameters
|
|
187
200
|
/** @type {Number} */
|
|
188
|
-
this.
|
|
201
|
+
this._lastTickTime = timerInitTime;
|
|
189
202
|
/** @type {Number} */
|
|
190
203
|
this._startTime = timerInitTime;
|
|
191
204
|
/** @type {Number} */
|
|
@@ -216,7 +229,7 @@ class Timer extends Clock {
|
|
|
216
229
|
}
|
|
217
230
|
|
|
218
231
|
get iterationCurrentTime() {
|
|
219
|
-
return round(this._iterationTime, globals.precision);
|
|
232
|
+
return clamp(round(this._iterationTime, globals.precision), 0, this.iterationDuration);
|
|
220
233
|
}
|
|
221
234
|
|
|
222
235
|
set iterationCurrentTime(time) {
|
|
@@ -314,9 +327,9 @@ class Timer extends Clock {
|
|
|
314
327
|
/** @return {this} */
|
|
315
328
|
resetTime() {
|
|
316
329
|
const timeScale = 1 / (this._speed * engine._speed);
|
|
317
|
-
// TODO: See if we can safely use engine.
|
|
330
|
+
// TODO: See if we can safely use engine._lastTickTime here
|
|
318
331
|
// if (!engine.reqId) engine.requestTick(now())
|
|
319
|
-
// this._startTime = engine.
|
|
332
|
+
// this._startTime = engine._lastTickTime - (this._currentTime + this._delay) * timeScale;
|
|
320
333
|
this._startTime = now() - (this._currentTime + this._delay) * timeScale;
|
|
321
334
|
return this;
|
|
322
335
|
}
|
|
@@ -26,7 +26,7 @@ export type DefaultsParams = {
|
|
|
26
26
|
export type Renderable = JSAnimation | Timeline;
|
|
27
27
|
export type Tickable = Timer | Renderable;
|
|
28
28
|
export type CallbackArgument = Timer & JSAnimation & Timeline;
|
|
29
|
-
export type Revertible = Animatable | Tickable | WAAPIAnimation | Draggable | ScrollObserver | TextSplitter | Scope;
|
|
29
|
+
export type Revertible = Animatable | Tickable | WAAPIAnimation | Draggable | ScrollObserver | TextSplitter | Scope | AutoLayout;
|
|
30
30
|
export type StaggerFunction<T> = (target?: Target, index?: number, length?: number, tl?: Timeline) => T;
|
|
31
31
|
export type StaggerParams = {
|
|
32
32
|
start?: number | string;
|
|
@@ -249,6 +249,7 @@ export type TimelineAnimationPosition = TimelinePosition | StaggerFunction<numbe
|
|
|
249
249
|
export type TimelineOptions = {
|
|
250
250
|
defaults?: DefaultsParams;
|
|
251
251
|
playbackEase?: EasingParam;
|
|
252
|
+
composition?: boolean;
|
|
252
253
|
};
|
|
253
254
|
export type TimelineParams = TimerOptions & TimelineOptions & TickableCallbacks<Timeline> & RenderableCallbacks<Timeline>;
|
|
254
255
|
export type WAAPITweenValue = string | number | Array<string> | Array<number>;
|
|
@@ -403,6 +404,7 @@ import type { WAAPIAnimation } from '../waapi/waapi.js';
|
|
|
403
404
|
import type { Draggable } from '../draggable/draggable.js';
|
|
404
405
|
import type { TextSplitter } from '../text/split.js';
|
|
405
406
|
import type { Scope } from '../scope/scope.js';
|
|
407
|
+
import type { AutoLayout } from '../layout/layout.js';
|
|
406
408
|
import type { Spring } from '../easings/spring/index.js';
|
|
407
409
|
import type { tweenTypes } from '../core/consts.js';
|
|
408
410
|
import type { valueTypes } from '../core/consts.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - waapi - CJS
|
|
3
|
-
* @version v4.
|
|
3
|
+
* @version v4.3.0-beta.0
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
@@ -333,9 +333,10 @@ class WAAPIAnimation {
|
|
|
333
333
|
* @return {this}
|
|
334
334
|
*/
|
|
335
335
|
forEach(callback) {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
336
|
+
try {
|
|
337
|
+
const cb = helpers.isStr(callback) ? (/** @type {globalThis.Animation} */a) => a[callback]() : callback;
|
|
338
|
+
this.animations.forEach(cb);
|
|
339
|
+
} catch {} return this;
|
|
339
340
|
}
|
|
340
341
|
|
|
341
342
|
get speed() {
|
|
@@ -431,14 +432,21 @@ class WAAPIAnimation {
|
|
|
431
432
|
|
|
432
433
|
cancel() {
|
|
433
434
|
this.muteCallbacks = true; // This prevents triggering the onComplete callback and resolving the Promise
|
|
434
|
-
|
|
435
|
+
this.commitStyles().forEach('cancel');
|
|
436
|
+
this.animations.length = 0; // Needed to release all animations from memory
|
|
437
|
+
requestAnimationFrame(() => {
|
|
438
|
+
this.targets.forEach(($el) => { // Needed to avoid unecessary inline transorms
|
|
439
|
+
if ($el.style.transform === 'none') $el.style.removeProperty('transform');
|
|
440
|
+
});
|
|
441
|
+
});
|
|
442
|
+
return this;
|
|
435
443
|
}
|
|
436
444
|
|
|
437
445
|
revert() {
|
|
438
446
|
// NOTE: We need a better way to revert the transforms, since right now the entire transform property value is reverted,
|
|
439
447
|
// This means if you have multiple animations animating different transforms on the same target,
|
|
440
448
|
// reverting one of them will also override the transform property of the other animations.
|
|
441
|
-
// A better approach would be to store the original custom property values
|
|
449
|
+
// A better approach would be to store the original custom property values if they exist instead of the entire transform value,
|
|
442
450
|
// and update the CSS variables with the orignal value
|
|
443
451
|
this.cancel().targets.forEach(($el, i) => {
|
|
444
452
|
const targetStyle = $el.style;
|
|
@@ -448,7 +456,7 @@ class WAAPIAnimation {
|
|
|
448
456
|
if (helpers.isUnd(originalInlinedValue) || originalInlinedValue === consts.emptyString) {
|
|
449
457
|
targetStyle.removeProperty(helpers.toLowerCase(name));
|
|
450
458
|
} else {
|
|
451
|
-
|
|
459
|
+
$el.style[name] = originalInlinedValue;
|
|
452
460
|
}
|
|
453
461
|
}
|
|
454
462
|
// Remove style attribute if empty
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - waapi - ESM
|
|
3
|
-
* @version v4.
|
|
3
|
+
* @version v4.3.0-beta.0
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { isNil, isUnd, stringStartsWith, isKey, isObj, isArr, toLowerCase, round,
|
|
8
|
+
import { isNil, isUnd, stringStartsWith, isKey, isObj, isArr, isStr, toLowerCase, round, isFnc, isNum } from '../core/helpers.js';
|
|
9
9
|
import { scope, globals } from '../core/globals.js';
|
|
10
10
|
import { registerTargets } from '../core/targets.js';
|
|
11
11
|
import { setValue, getFunctionValue } from '../core/values.js';
|
|
@@ -331,9 +331,10 @@ class WAAPIAnimation {
|
|
|
331
331
|
* @return {this}
|
|
332
332
|
*/
|
|
333
333
|
forEach(callback) {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
334
|
+
try {
|
|
335
|
+
const cb = isStr(callback) ? (/** @type {globalThis.Animation} */a) => a[callback]() : callback;
|
|
336
|
+
this.animations.forEach(cb);
|
|
337
|
+
} catch {} return this;
|
|
337
338
|
}
|
|
338
339
|
|
|
339
340
|
get speed() {
|
|
@@ -429,14 +430,21 @@ class WAAPIAnimation {
|
|
|
429
430
|
|
|
430
431
|
cancel() {
|
|
431
432
|
this.muteCallbacks = true; // This prevents triggering the onComplete callback and resolving the Promise
|
|
432
|
-
|
|
433
|
+
this.commitStyles().forEach('cancel');
|
|
434
|
+
this.animations.length = 0; // Needed to release all animations from memory
|
|
435
|
+
requestAnimationFrame(() => {
|
|
436
|
+
this.targets.forEach(($el) => { // Needed to avoid unecessary inline transorms
|
|
437
|
+
if ($el.style.transform === 'none') $el.style.removeProperty('transform');
|
|
438
|
+
});
|
|
439
|
+
});
|
|
440
|
+
return this;
|
|
433
441
|
}
|
|
434
442
|
|
|
435
443
|
revert() {
|
|
436
444
|
// NOTE: We need a better way to revert the transforms, since right now the entire transform property value is reverted,
|
|
437
445
|
// This means if you have multiple animations animating different transforms on the same target,
|
|
438
446
|
// reverting one of them will also override the transform property of the other animations.
|
|
439
|
-
// A better approach would be to store the original custom property values
|
|
447
|
+
// A better approach would be to store the original custom property values if they exist instead of the entire transform value,
|
|
440
448
|
// and update the CSS variables with the orignal value
|
|
441
449
|
this.cancel().targets.forEach(($el, i) => {
|
|
442
450
|
const targetStyle = $el.style;
|
|
@@ -446,7 +454,7 @@ class WAAPIAnimation {
|
|
|
446
454
|
if (isUnd(originalInlinedValue) || originalInlinedValue === emptyString) {
|
|
447
455
|
targetStyle.removeProperty(toLowerCase(name));
|
|
448
456
|
} else {
|
|
449
|
-
|
|
457
|
+
$el.style[name] = originalInlinedValue;
|
|
450
458
|
}
|
|
451
459
|
}
|
|
452
460
|
// Remove style attribute if empty
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "animejs",
|
|
3
|
-
"version": "4.
|
|
4
|
-
"homepage": "https://animejs.com",
|
|
3
|
+
"version": "4.3.0-beta.0",
|
|
5
4
|
"description": "JavaScript animation engine",
|
|
5
|
+
"homepage": "https://animejs.com",
|
|
6
6
|
"author": "Julian Garnier <julian@animejs.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|
|
@@ -104,6 +104,12 @@
|
|
|
104
104
|
"import": "./dist/modules/events/index.js",
|
|
105
105
|
"default": "./dist/modules/events/index.cjs"
|
|
106
106
|
},
|
|
107
|
+
"./layout": {
|
|
108
|
+
"types": "./dist/modules/layout/index.d.ts",
|
|
109
|
+
"require": "./dist/modules/layout/index.cjs",
|
|
110
|
+
"import": "./dist/modules/layout/index.js",
|
|
111
|
+
"default": "./dist/modules/layout/index.cjs"
|
|
112
|
+
},
|
|
107
113
|
"./easings": {
|
|
108
114
|
"types": "./dist/modules/easings/index.d.ts",
|
|
109
115
|
"require": "./dist/modules/easings/index.cjs",
|