animejs 4.3.6 → 4.4.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 +8 -11
- package/dist/bundles/anime.esm.js +1033 -421
- package/dist/bundles/anime.esm.min.js +2 -2
- package/dist/bundles/anime.umd.js +1038 -421
- package/dist/bundles/anime.umd.min.js +2 -2
- package/dist/modules/animatable/animatable.cjs +1 -1
- package/dist/modules/animatable/animatable.js +2 -2
- 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 +38 -16
- package/dist/modules/animation/animation.d.ts +2 -2
- package/dist/modules/animation/animation.js +42 -20
- package/dist/modules/animation/composition.cjs +1 -1
- package/dist/modules/animation/composition.js +3 -3
- 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 +3 -9
- package/dist/modules/core/consts.d.ts +1 -5
- package/dist/modules/core/consts.js +4 -8
- package/dist/modules/core/globals.cjs +16 -5
- package/dist/modules/core/globals.d.ts +22 -1
- package/dist/modules/core/globals.js +18 -6
- package/dist/modules/core/helpers.cjs +7 -10
- package/dist/modules/core/helpers.js +8 -11
- package/dist/modules/core/render.cjs +66 -63
- package/dist/modules/core/render.js +68 -65
- package/dist/modules/core/styles.cjs +53 -32
- package/dist/modules/core/styles.d.ts +1 -0
- package/dist/modules/core/styles.js +55 -35
- package/dist/modules/core/targets.cjs +1 -1
- package/dist/modules/core/targets.js +1 -1
- package/dist/modules/core/transforms.cjs +129 -13
- package/dist/modules/core/transforms.d.ts +1 -0
- package/dist/modules/core/transforms.js +130 -15
- package/dist/modules/core/units.cjs +1 -1
- package/dist/modules/core/units.js +1 -1
- package/dist/modules/core/values.cjs +68 -8
- package/dist/modules/core/values.d.ts +5 -2
- package/dist/modules/core/values.js +69 -11
- 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 +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 +1 -1
- package/dist/modules/events/scroll.js +1 -1
- package/dist/modules/index.cjs +9 -1
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +4 -1
- package/dist/modules/layout/index.cjs +1 -1
- package/dist/modules/layout/index.js +1 -1
- package/dist/modules/layout/layout.cjs +29 -25
- package/dist/modules/layout/layout.d.ts +4 -3
- package/dist/modules/layout/layout.js +30 -26
- 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 +3 -6
- package/dist/modules/svg/morphto.js +3 -6
- package/dist/modules/svg/motionpath.cjs +1 -1
- package/dist/modules/svg/motionpath.js +1 -1
- package/dist/modules/text/index.cjs +3 -1
- package/dist/modules/text/index.d.ts +1 -0
- package/dist/modules/text/index.js +2 -1
- package/dist/modules/text/scramble.cjs +272 -0
- package/dist/modules/text/scramble.d.ts +3 -0
- package/dist/modules/text/scramble.js +270 -0
- package/dist/modules/text/split.cjs +5 -5
- package/dist/modules/text/split.d.ts +5 -5
- package/dist/modules/text/split.js +5 -5
- 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 +36 -18
- package/dist/modules/timeline/timeline.d.ts +6 -5
- package/dist/modules/timeline/timeline.js +37 -19
- package/dist/modules/timer/index.cjs +1 -1
- package/dist/modules/timer/index.js +1 -1
- package/dist/modules/timer/timer.cjs +8 -12
- package/dist/modules/timer/timer.d.ts +2 -0
- package/dist/modules/timer/timer.js +9 -13
- package/dist/modules/types/index.d.ts +76 -8
- package/dist/modules/utils/chainable.cjs +8 -5
- package/dist/modules/utils/chainable.js +8 -5
- package/dist/modules/utils/index.cjs +5 -1
- package/dist/modules/utils/index.d.ts +1 -0
- package/dist/modules/utils/index.js +2 -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 +117 -20
- package/dist/modules/utils/stagger.js +118 -21
- package/dist/modules/utils/target.cjs +1 -1
- package/dist/modules/utils/target.js +1 -1
- package/dist/modules/utils/time.cjs +5 -3
- package/dist/modules/utils/time.d.ts +1 -1
- package/dist/modules/utils/time.js +5 -3
- 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 +19 -20
- package/dist/modules/waapi/waapi.js +20 -21
- package/package.json +2 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - timeline - CJS
|
|
3
|
-
* @version v4.
|
|
3
|
+
* @version v4.4.0
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2026 - Julian Garnier
|
|
6
6
|
*/
|
|
@@ -14,9 +14,9 @@ var values = require('../core/values.cjs');
|
|
|
14
14
|
var targets = require('../core/targets.cjs');
|
|
15
15
|
var render = require('../core/render.cjs');
|
|
16
16
|
var styles = require('../core/styles.cjs');
|
|
17
|
+
var timer = require('../timer/timer.cjs');
|
|
17
18
|
var composition = require('../animation/composition.cjs');
|
|
18
19
|
var animation = require('../animation/animation.cjs');
|
|
19
|
-
var timer = require('../timer/timer.cjs');
|
|
20
20
|
var parser = require('../easings/eases/parser.cjs');
|
|
21
21
|
var position = require('./position.cjs');
|
|
22
22
|
|
|
@@ -33,6 +33,7 @@ var position = require('./position.cjs');
|
|
|
33
33
|
* DefaultsParams,
|
|
34
34
|
* TimelinePosition,
|
|
35
35
|
* StaggerFunction,
|
|
36
|
+
* TargetsArray,
|
|
36
37
|
* } from '../types/index.js'
|
|
37
38
|
*/
|
|
38
39
|
|
|
@@ -42,6 +43,8 @@ var position = require('./position.cjs');
|
|
|
42
43
|
* } from '../waapi/waapi.js'
|
|
43
44
|
*/
|
|
44
45
|
|
|
46
|
+
/** @import {TweakRegister} from 'tweaks' */
|
|
47
|
+
|
|
45
48
|
/**
|
|
46
49
|
* @param {Timeline} tl
|
|
47
50
|
* @return {Number}
|
|
@@ -63,7 +66,7 @@ function getTimelineTotalDuration(tl) {
|
|
|
63
66
|
* @param {Number} timePosition
|
|
64
67
|
* @param {TargetsParam} targets
|
|
65
68
|
* @param {Number} [index]
|
|
66
|
-
* @param {
|
|
69
|
+
* @param {TargetsArray} [allTargets]
|
|
67
70
|
* @return {Timeline}
|
|
68
71
|
*
|
|
69
72
|
* @param {TimerParams|AnimationParams} childParams
|
|
@@ -71,15 +74,15 @@ function getTimelineTotalDuration(tl) {
|
|
|
71
74
|
* @param {Number} timePosition
|
|
72
75
|
* @param {TargetsParam} [targets]
|
|
73
76
|
* @param {Number} [index]
|
|
74
|
-
* @param {
|
|
77
|
+
* @param {TargetsArray} [allTargets]
|
|
75
78
|
*/
|
|
76
|
-
function addTlChild(childParams, tl, timePosition, targets, index,
|
|
79
|
+
function addTlChild(childParams, tl, timePosition, targets, index, allTargets) {
|
|
77
80
|
const isSetter = helpers.isNum(childParams.duration) && /** @type {Number} */(childParams.duration) <= consts.minValue;
|
|
78
81
|
// Offset the tl position with -minValue for 0 duration animations or .set() calls in order to align their end value with the defined position
|
|
79
82
|
const adjustedPosition = isSetter ? timePosition - consts.minValue : timePosition;
|
|
80
83
|
if (tl.composition) render.tick(tl, adjustedPosition, 1, 1, consts.tickModes.AUTO);
|
|
81
84
|
const tlChild = targets ?
|
|
82
|
-
new animation.JSAnimation(targets,/** @type {AnimationParams} */(childParams), tl, adjustedPosition, false, index,
|
|
85
|
+
new animation.JSAnimation(targets,/** @type {AnimationParams} */(childParams), tl, adjustedPosition, false, index, allTargets) :
|
|
83
86
|
new timer.Timer(/** @type {TimerParams} */(childParams), tl, adjustedPosition);
|
|
84
87
|
if (tl.composition) tlChild.init(true);
|
|
85
88
|
// TODO: Might be better to insert at a position relative to startTime?
|
|
@@ -127,7 +130,7 @@ class Timeline extends timer.Timer {
|
|
|
127
130
|
* @overload
|
|
128
131
|
* @param {TargetsParam} a1
|
|
129
132
|
* @param {AnimationParams} a2
|
|
130
|
-
* @param {TimelinePosition|StaggerFunction<Number|String
|
|
133
|
+
* @param {TimelinePosition|StaggerFunction<Number|String>|TweakRegister} [a3]
|
|
131
134
|
* @return {this}
|
|
132
135
|
*
|
|
133
136
|
* @overload
|
|
@@ -137,7 +140,7 @@ class Timeline extends timer.Timer {
|
|
|
137
140
|
*
|
|
138
141
|
* @param {TargetsParam|TimerParams} a1
|
|
139
142
|
* @param {TimelinePosition|AnimationParams} a2
|
|
140
|
-
* @param {TimelinePosition|StaggerFunction<Number|String
|
|
143
|
+
* @param {TimelinePosition|StaggerFunction<Number|String>|TweakRegister} [a3]
|
|
141
144
|
*/
|
|
142
145
|
add(a1, a2, a3) {
|
|
143
146
|
const isAnim = helpers.isObj(a2);
|
|
@@ -146,9 +149,11 @@ class Timeline extends timer.Timer {
|
|
|
146
149
|
this._hasChildren = true;
|
|
147
150
|
if (isAnim) {
|
|
148
151
|
const childParams = /** @type {AnimationParams} */(a2);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
+
const editorHook = globals.globals.editor && globals.globals.editor.addTimelineChild;
|
|
153
|
+
const isStaggerType = a3 && /** @type {TweakRegister} */(a3).type === 'Stagger' && globals.globals.editor;
|
|
154
|
+
// Check for function or Stagger type children positions
|
|
155
|
+
const staggeredPosition = helpers.isFnc(a3) ? a3 : null;
|
|
156
|
+
if (staggeredPosition || isStaggerType) {
|
|
152
157
|
const parsedTargetsArray = targets.parseTargets(/** @type {TargetsParam} */(a1));
|
|
153
158
|
// Store initial duration before adding new children that will change the duration
|
|
154
159
|
const tlDuration = this.duration;
|
|
@@ -159,28 +164,36 @@ class Timeline extends timer.Timer {
|
|
|
159
164
|
let i = 0;
|
|
160
165
|
/** @type {Number} */
|
|
161
166
|
const parsedLength = (parsedTargetsArray.length);
|
|
167
|
+
// Call editor hook once for the entire stagger group instead of per target
|
|
168
|
+
const resolvedParams = editorHook ? editorHook(/** @type {TargetsParam} */(a1), childParams, this.id, a3, parsedLength) : null;
|
|
169
|
+
// Resolve stagger AFTER editor hook so tweaked position value (a3.defaultValue) is used
|
|
170
|
+
const staggerFn = staggeredPosition || globals.globals.editor.resolveStagger(/** @type {TweakRegister} */(a3).defaultValue);
|
|
162
171
|
parsedTargetsArray.forEach((/** @type {Target} */target) => {
|
|
163
172
|
// Create a new parameter object for each staggered children
|
|
164
|
-
const staggeredChildParams = { ...childParams };
|
|
173
|
+
const staggeredChildParams = { ...(resolvedParams || childParams) };
|
|
165
174
|
// Reset the duration of the timeline iteration before each stagger to prevent wrong start value calculation
|
|
166
175
|
this.duration = tlDuration;
|
|
167
176
|
this.iterationDuration = tlIterationDuration;
|
|
168
177
|
if (!helpers.isUnd(id)) staggeredChildParams.id = id + '-' + i;
|
|
178
|
+
const staggeredTimePosition = position.parseTimelinePosition(this, staggerFn(target, i, parsedTargetsArray, null, this));
|
|
169
179
|
addTlChild(
|
|
170
180
|
staggeredChildParams,
|
|
171
181
|
this,
|
|
172
|
-
|
|
182
|
+
staggeredTimePosition,
|
|
173
183
|
target,
|
|
174
184
|
i,
|
|
175
|
-
|
|
185
|
+
parsedTargetsArray,
|
|
176
186
|
);
|
|
177
187
|
i++;
|
|
178
188
|
});
|
|
179
189
|
} else {
|
|
190
|
+
// Call editor hook before resolving position so tweaked values are applied
|
|
191
|
+
const resolvedChildParams = editorHook ? editorHook(/** @type {TargetsParam} */(a1), childParams, this.id, a3) : childParams;
|
|
192
|
+
const resolvedPosition = a3 && /** @type {*} */(a3).type ? /** @type {*} */(a3).defaultValue : a3;
|
|
180
193
|
addTlChild(
|
|
181
|
-
|
|
194
|
+
resolvedChildParams,
|
|
182
195
|
this,
|
|
183
|
-
position.parseTimelinePosition(this,
|
|
196
|
+
position.parseTimelinePosition(this, resolvedPosition),
|
|
184
197
|
/** @type {TargetsParam} */(a1),
|
|
185
198
|
);
|
|
186
199
|
}
|
|
@@ -302,7 +315,7 @@ class Timeline extends timer.Timer {
|
|
|
302
315
|
revert() {
|
|
303
316
|
super.revert();
|
|
304
317
|
helpers.forEachChildren(this, (/** @type {JSAnimation|Timer} */child) => child.revert, true);
|
|
305
|
-
return styles.
|
|
318
|
+
return styles.revertValues(this);
|
|
306
319
|
}
|
|
307
320
|
|
|
308
321
|
/**
|
|
@@ -322,7 +335,12 @@ class Timeline extends timer.Timer {
|
|
|
322
335
|
* @param {TimelineParams} [parameters]
|
|
323
336
|
* @return {Timeline}
|
|
324
337
|
*/
|
|
325
|
-
const createTimeline = parameters =>
|
|
338
|
+
const createTimeline = parameters => {
|
|
339
|
+
if (globals.globals.editor) {
|
|
340
|
+
return /** @type {Timeline} */(/** @type {unknown} */(globals.globals.editor.addTimeline(parameters)));
|
|
341
|
+
}
|
|
342
|
+
return new Timeline(parameters).init();
|
|
343
|
+
};
|
|
326
344
|
|
|
327
345
|
exports.Timeline = Timeline;
|
|
328
346
|
exports.createTimeline = createTimeline;
|
|
@@ -16,7 +16,7 @@ export class Timeline extends Timer {
|
|
|
16
16
|
* @overload
|
|
17
17
|
* @param {TargetsParam} a1
|
|
18
18
|
* @param {AnimationParams} a2
|
|
19
|
-
* @param {TimelinePosition|StaggerFunction<Number|String
|
|
19
|
+
* @param {TimelinePosition|StaggerFunction<Number|String>|TweakRegister} [a3]
|
|
20
20
|
* @return {this}
|
|
21
21
|
*
|
|
22
22
|
* @overload
|
|
@@ -26,14 +26,14 @@ export class Timeline extends Timer {
|
|
|
26
26
|
*
|
|
27
27
|
* @param {TargetsParam|TimerParams} a1
|
|
28
28
|
* @param {TimelinePosition|AnimationParams} a2
|
|
29
|
-
* @param {TimelinePosition|StaggerFunction<Number|String
|
|
29
|
+
* @param {TimelinePosition|StaggerFunction<Number|String>|TweakRegister} [a3]
|
|
30
30
|
*/
|
|
31
|
-
add(a1: TargetsParam, a2: AnimationParams, a3?: TimelinePosition | StaggerFunction<number | string>): this;
|
|
31
|
+
add(a1: TargetsParam, a2: AnimationParams, a3?: TimelinePosition | StaggerFunction<number | string> | TweakRegister): this;
|
|
32
32
|
/**
|
|
33
33
|
* @overload
|
|
34
34
|
* @param {TargetsParam} a1
|
|
35
35
|
* @param {AnimationParams} a2
|
|
36
|
-
* @param {TimelinePosition|StaggerFunction<Number|String
|
|
36
|
+
* @param {TimelinePosition|StaggerFunction<Number|String>|TweakRegister} [a3]
|
|
37
37
|
* @return {this}
|
|
38
38
|
*
|
|
39
39
|
* @overload
|
|
@@ -43,7 +43,7 @@ export class Timeline extends Timer {
|
|
|
43
43
|
*
|
|
44
44
|
* @param {TargetsParam|TimerParams} a1
|
|
45
45
|
* @param {TimelinePosition|AnimationParams} a2
|
|
46
|
-
* @param {TimelinePosition|StaggerFunction<Number|String
|
|
46
|
+
* @param {TimelinePosition|StaggerFunction<Number|String>|TweakRegister} [a3]
|
|
47
47
|
*/
|
|
48
48
|
add(a1: TimerParams, a2?: TimelinePosition): this;
|
|
49
49
|
/**
|
|
@@ -164,6 +164,7 @@ import type { TargetsParam } from '../types/index.js';
|
|
|
164
164
|
import type { AnimationParams } from '../types/index.js';
|
|
165
165
|
import type { TimelinePosition } from '../types/index.js';
|
|
166
166
|
import type { StaggerFunction } from '../types/index.js';
|
|
167
|
+
import type { TweakRegister } from 'tweaks';
|
|
167
168
|
import type { TimerParams } from '../types/index.js';
|
|
168
169
|
import type { Tickable } from '../types/index.js';
|
|
169
170
|
import type { WAAPIAnimation } from '../waapi/waapi.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - timeline - ESM
|
|
3
|
-
* @version v4.
|
|
3
|
+
* @version v4.4.0
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2026 - Julian Garnier
|
|
6
6
|
*/
|
|
@@ -11,10 +11,10 @@ import { isUnd, mergeObjects, isObj, isFnc, isStr, normalizeTime, forEachChildre
|
|
|
11
11
|
import { setValue } from '../core/values.js';
|
|
12
12
|
import { parseTargets } from '../core/targets.js';
|
|
13
13
|
import { tick } from '../core/render.js';
|
|
14
|
-
import {
|
|
14
|
+
import { revertValues } from '../core/styles.js';
|
|
15
|
+
import { Timer } from '../timer/timer.js';
|
|
15
16
|
import { removeTargetsFromRenderable } from '../animation/composition.js';
|
|
16
17
|
import { JSAnimation } from '../animation/animation.js';
|
|
17
|
-
import { Timer } from '../timer/timer.js';
|
|
18
18
|
import { parseEase } from '../easings/eases/parser.js';
|
|
19
19
|
import { parseTimelinePosition } from './position.js';
|
|
20
20
|
|
|
@@ -31,6 +31,7 @@ import { parseTimelinePosition } from './position.js';
|
|
|
31
31
|
* DefaultsParams,
|
|
32
32
|
* TimelinePosition,
|
|
33
33
|
* StaggerFunction,
|
|
34
|
+
* TargetsArray,
|
|
34
35
|
* } from '../types/index.js'
|
|
35
36
|
*/
|
|
36
37
|
|
|
@@ -40,6 +41,8 @@ import { parseTimelinePosition } from './position.js';
|
|
|
40
41
|
* } from '../waapi/waapi.js'
|
|
41
42
|
*/
|
|
42
43
|
|
|
44
|
+
/** @import {TweakRegister} from 'tweaks' */
|
|
45
|
+
|
|
43
46
|
/**
|
|
44
47
|
* @param {Timeline} tl
|
|
45
48
|
* @return {Number}
|
|
@@ -61,7 +64,7 @@ function getTimelineTotalDuration(tl) {
|
|
|
61
64
|
* @param {Number} timePosition
|
|
62
65
|
* @param {TargetsParam} targets
|
|
63
66
|
* @param {Number} [index]
|
|
64
|
-
* @param {
|
|
67
|
+
* @param {TargetsArray} [allTargets]
|
|
65
68
|
* @return {Timeline}
|
|
66
69
|
*
|
|
67
70
|
* @param {TimerParams|AnimationParams} childParams
|
|
@@ -69,15 +72,15 @@ function getTimelineTotalDuration(tl) {
|
|
|
69
72
|
* @param {Number} timePosition
|
|
70
73
|
* @param {TargetsParam} [targets]
|
|
71
74
|
* @param {Number} [index]
|
|
72
|
-
* @param {
|
|
75
|
+
* @param {TargetsArray} [allTargets]
|
|
73
76
|
*/
|
|
74
|
-
function addTlChild(childParams, tl, timePosition, targets, index,
|
|
77
|
+
function addTlChild(childParams, tl, timePosition, targets, index, allTargets) {
|
|
75
78
|
const isSetter = isNum(childParams.duration) && /** @type {Number} */(childParams.duration) <= minValue;
|
|
76
79
|
// Offset the tl position with -minValue for 0 duration animations or .set() calls in order to align their end value with the defined position
|
|
77
80
|
const adjustedPosition = isSetter ? timePosition - minValue : timePosition;
|
|
78
81
|
if (tl.composition) tick(tl, adjustedPosition, 1, 1, tickModes.AUTO);
|
|
79
82
|
const tlChild = targets ?
|
|
80
|
-
new JSAnimation(targets,/** @type {AnimationParams} */(childParams), tl, adjustedPosition, false, index,
|
|
83
|
+
new JSAnimation(targets,/** @type {AnimationParams} */(childParams), tl, adjustedPosition, false, index, allTargets) :
|
|
81
84
|
new Timer(/** @type {TimerParams} */(childParams), tl, adjustedPosition);
|
|
82
85
|
if (tl.composition) tlChild.init(true);
|
|
83
86
|
// TODO: Might be better to insert at a position relative to startTime?
|
|
@@ -125,7 +128,7 @@ class Timeline extends Timer {
|
|
|
125
128
|
* @overload
|
|
126
129
|
* @param {TargetsParam} a1
|
|
127
130
|
* @param {AnimationParams} a2
|
|
128
|
-
* @param {TimelinePosition|StaggerFunction<Number|String
|
|
131
|
+
* @param {TimelinePosition|StaggerFunction<Number|String>|TweakRegister} [a3]
|
|
129
132
|
* @return {this}
|
|
130
133
|
*
|
|
131
134
|
* @overload
|
|
@@ -135,7 +138,7 @@ class Timeline extends Timer {
|
|
|
135
138
|
*
|
|
136
139
|
* @param {TargetsParam|TimerParams} a1
|
|
137
140
|
* @param {TimelinePosition|AnimationParams} a2
|
|
138
|
-
* @param {TimelinePosition|StaggerFunction<Number|String
|
|
141
|
+
* @param {TimelinePosition|StaggerFunction<Number|String>|TweakRegister} [a3]
|
|
139
142
|
*/
|
|
140
143
|
add(a1, a2, a3) {
|
|
141
144
|
const isAnim = isObj(a2);
|
|
@@ -144,9 +147,11 @@ class Timeline extends Timer {
|
|
|
144
147
|
this._hasChildren = true;
|
|
145
148
|
if (isAnim) {
|
|
146
149
|
const childParams = /** @type {AnimationParams} */(a2);
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
+
const editorHook = globals.editor && globals.editor.addTimelineChild;
|
|
151
|
+
const isStaggerType = a3 && /** @type {TweakRegister} */(a3).type === 'Stagger' && globals.editor;
|
|
152
|
+
// Check for function or Stagger type children positions
|
|
153
|
+
const staggeredPosition = isFnc(a3) ? a3 : null;
|
|
154
|
+
if (staggeredPosition || isStaggerType) {
|
|
150
155
|
const parsedTargetsArray = parseTargets(/** @type {TargetsParam} */(a1));
|
|
151
156
|
// Store initial duration before adding new children that will change the duration
|
|
152
157
|
const tlDuration = this.duration;
|
|
@@ -157,28 +162,36 @@ class Timeline extends Timer {
|
|
|
157
162
|
let i = 0;
|
|
158
163
|
/** @type {Number} */
|
|
159
164
|
const parsedLength = (parsedTargetsArray.length);
|
|
165
|
+
// Call editor hook once for the entire stagger group instead of per target
|
|
166
|
+
const resolvedParams = editorHook ? editorHook(/** @type {TargetsParam} */(a1), childParams, this.id, a3, parsedLength) : null;
|
|
167
|
+
// Resolve stagger AFTER editor hook so tweaked position value (a3.defaultValue) is used
|
|
168
|
+
const staggerFn = staggeredPosition || globals.editor.resolveStagger(/** @type {TweakRegister} */(a3).defaultValue);
|
|
160
169
|
parsedTargetsArray.forEach((/** @type {Target} */target) => {
|
|
161
170
|
// Create a new parameter object for each staggered children
|
|
162
|
-
const staggeredChildParams = { ...childParams };
|
|
171
|
+
const staggeredChildParams = { ...(resolvedParams || childParams) };
|
|
163
172
|
// Reset the duration of the timeline iteration before each stagger to prevent wrong start value calculation
|
|
164
173
|
this.duration = tlDuration;
|
|
165
174
|
this.iterationDuration = tlIterationDuration;
|
|
166
175
|
if (!isUnd(id)) staggeredChildParams.id = id + '-' + i;
|
|
176
|
+
const staggeredTimePosition = parseTimelinePosition(this, staggerFn(target, i, parsedTargetsArray, null, this));
|
|
167
177
|
addTlChild(
|
|
168
178
|
staggeredChildParams,
|
|
169
179
|
this,
|
|
170
|
-
|
|
180
|
+
staggeredTimePosition,
|
|
171
181
|
target,
|
|
172
182
|
i,
|
|
173
|
-
|
|
183
|
+
parsedTargetsArray,
|
|
174
184
|
);
|
|
175
185
|
i++;
|
|
176
186
|
});
|
|
177
187
|
} else {
|
|
188
|
+
// Call editor hook before resolving position so tweaked values are applied
|
|
189
|
+
const resolvedChildParams = editorHook ? editorHook(/** @type {TargetsParam} */(a1), childParams, this.id, a3) : childParams;
|
|
190
|
+
const resolvedPosition = a3 && /** @type {*} */(a3).type ? /** @type {*} */(a3).defaultValue : a3;
|
|
178
191
|
addTlChild(
|
|
179
|
-
|
|
192
|
+
resolvedChildParams,
|
|
180
193
|
this,
|
|
181
|
-
parseTimelinePosition(this,
|
|
194
|
+
parseTimelinePosition(this, resolvedPosition),
|
|
182
195
|
/** @type {TargetsParam} */(a1),
|
|
183
196
|
);
|
|
184
197
|
}
|
|
@@ -300,7 +313,7 @@ class Timeline extends Timer {
|
|
|
300
313
|
revert() {
|
|
301
314
|
super.revert();
|
|
302
315
|
forEachChildren(this, (/** @type {JSAnimation|Timer} */child) => child.revert, true);
|
|
303
|
-
return
|
|
316
|
+
return revertValues(this);
|
|
304
317
|
}
|
|
305
318
|
|
|
306
319
|
/**
|
|
@@ -320,6 +333,11 @@ class Timeline extends Timer {
|
|
|
320
333
|
* @param {TimelineParams} [parameters]
|
|
321
334
|
* @return {Timeline}
|
|
322
335
|
*/
|
|
323
|
-
const createTimeline = parameters =>
|
|
336
|
+
const createTimeline = parameters => {
|
|
337
|
+
if (globals.editor) {
|
|
338
|
+
return /** @type {Timeline} */(/** @type {unknown} */(globals.editor.addTimeline(parameters)));
|
|
339
|
+
}
|
|
340
|
+
return new Timeline(parameters).init();
|
|
341
|
+
};
|
|
324
342
|
|
|
325
343
|
export { Timeline, createTimeline };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - timer - CJS
|
|
3
|
-
* @version v4.
|
|
3
|
+
* @version v4.4.0
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2026 - Julian Garnier
|
|
6
6
|
*/
|
|
@@ -69,6 +69,9 @@ const reviveTimer = timer => {
|
|
|
69
69
|
|
|
70
70
|
let timerId = 0;
|
|
71
71
|
|
|
72
|
+
/** @param {Timer} prev @param {Timer} child */
|
|
73
|
+
const sortByPriority = (prev, child) => prev._priority > child._priority;
|
|
74
|
+
|
|
72
75
|
/**
|
|
73
76
|
* Base class used to create Timers, Animations and Timelines
|
|
74
77
|
*/
|
|
@@ -95,6 +98,7 @@ class Timer extends clock.Clock {
|
|
|
95
98
|
autoplay,
|
|
96
99
|
frameRate,
|
|
97
100
|
playbackRate,
|
|
101
|
+
priority,
|
|
98
102
|
onComplete,
|
|
99
103
|
onLoop,
|
|
100
104
|
onPause,
|
|
@@ -116,16 +120,6 @@ class Timer extends clock.Clock {
|
|
|
116
120
|
/** @type {Number} */(timerLoop) < 0 ? Infinity :
|
|
117
121
|
/** @type {Number} */(timerLoop) + 1;
|
|
118
122
|
|
|
119
|
-
if (globals.devTools) {
|
|
120
|
-
const isInfinite = timerIterationCount === Infinity;
|
|
121
|
-
const registered = globals.devTools.register(this, parameters, isInfinite);
|
|
122
|
-
if (registered && isInfinite) {
|
|
123
|
-
const minIterations = alternate ? 2 : 1;
|
|
124
|
-
const iterations = parent ? globals.devTools.maxNestedInfiniteLoops : globals.devTools.maxInfiniteLoops;
|
|
125
|
-
timerIterationCount = Math.max(iterations, minIterations);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
123
|
let offsetPosition = 0;
|
|
130
124
|
|
|
131
125
|
if (parent) {
|
|
@@ -209,6 +203,8 @@ class Timer extends clock.Clock {
|
|
|
209
203
|
this._fps = values.setValue(frameRate, timerDefaults.frameRate);
|
|
210
204
|
/** @type {Number} */
|
|
211
205
|
this._speed = values.setValue(playbackRate, timerDefaults.playbackRate);
|
|
206
|
+
/** @type {Number} */
|
|
207
|
+
this._priority = +values.setValue(priority, 1);
|
|
212
208
|
}
|
|
213
209
|
|
|
214
210
|
get cancelled() {
|
|
@@ -353,7 +349,7 @@ class Timer extends clock.Clock {
|
|
|
353
349
|
render.tick(this, consts.minValue, 0, 0, consts.tickModes.FORCE);
|
|
354
350
|
} else {
|
|
355
351
|
if (!this._running) {
|
|
356
|
-
helpers.addChild(engine.engine, this);
|
|
352
|
+
helpers.addChild(engine.engine, this, sortByPriority);
|
|
357
353
|
engine.engine._hasChildren = true;
|
|
358
354
|
this._running = true;
|
|
359
355
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - timer - ESM
|
|
3
|
-
* @version v4.
|
|
3
|
+
* @version v4.4.0
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2026 - 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,
|
|
10
|
+
import { globals, 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';
|
|
@@ -67,6 +67,9 @@ const reviveTimer = timer => {
|
|
|
67
67
|
|
|
68
68
|
let timerId = 0;
|
|
69
69
|
|
|
70
|
+
/** @param {Timer} prev @param {Timer} child */
|
|
71
|
+
const sortByPriority = (prev, child) => prev._priority > child._priority;
|
|
72
|
+
|
|
70
73
|
/**
|
|
71
74
|
* Base class used to create Timers, Animations and Timelines
|
|
72
75
|
*/
|
|
@@ -93,6 +96,7 @@ class Timer extends Clock {
|
|
|
93
96
|
autoplay,
|
|
94
97
|
frameRate,
|
|
95
98
|
playbackRate,
|
|
99
|
+
priority,
|
|
96
100
|
onComplete,
|
|
97
101
|
onLoop,
|
|
98
102
|
onPause,
|
|
@@ -114,16 +118,6 @@ class Timer extends Clock {
|
|
|
114
118
|
/** @type {Number} */(timerLoop) < 0 ? Infinity :
|
|
115
119
|
/** @type {Number} */(timerLoop) + 1;
|
|
116
120
|
|
|
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
|
-
}
|
|
126
|
-
|
|
127
121
|
let offsetPosition = 0;
|
|
128
122
|
|
|
129
123
|
if (parent) {
|
|
@@ -207,6 +201,8 @@ class Timer extends Clock {
|
|
|
207
201
|
this._fps = setValue(frameRate, timerDefaults.frameRate);
|
|
208
202
|
/** @type {Number} */
|
|
209
203
|
this._speed = setValue(playbackRate, timerDefaults.playbackRate);
|
|
204
|
+
/** @type {Number} */
|
|
205
|
+
this._priority = +setValue(priority, 1);
|
|
210
206
|
}
|
|
211
207
|
|
|
212
208
|
get cancelled() {
|
|
@@ -351,7 +347,7 @@ class Timer extends Clock {
|
|
|
351
347
|
tick(this, minValue, 0, 0, tickModes.FORCE);
|
|
352
348
|
} else {
|
|
353
349
|
if (!this._running) {
|
|
354
|
-
addChild(engine, this);
|
|
350
|
+
addChild(engine, this, sortByPriority);
|
|
355
351
|
engine._hasChildren = true;
|
|
356
352
|
this._running = true;
|
|
357
353
|
}
|