animejs 4.2.0-beta.0 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/dist/bundles/anime.esm.js +543 -304
- package/dist/bundles/anime.esm.min.js +2 -2
- package/dist/bundles/anime.umd.js +544 -305
- package/dist/bundles/anime.umd.min.js +2 -2
- package/dist/modules/animatable/animatable.cjs +4 -4
- package/dist/modules/animatable/animatable.js +3 -3
- package/dist/modules/animatable/index.cjs +1 -1
- package/dist/modules/animatable/index.js +1 -1
- package/dist/modules/animation/additive.cjs +1 -1
- package/dist/modules/animation/additive.js +1 -1
- package/dist/modules/animation/animation.cjs +28 -17
- package/dist/modules/animation/animation.d.ts +8 -5
- package/dist/modules/animation/animation.js +27 -16
- package/dist/modules/animation/composition.cjs +1 -1
- package/dist/modules/animation/composition.js +1 -1
- package/dist/modules/animation/index.cjs +1 -1
- package/dist/modules/animation/index.js +1 -1
- package/dist/modules/core/clock.cjs +1 -1
- package/dist/modules/core/clock.js +1 -1
- package/dist/modules/core/colors.cjs +1 -1
- package/dist/modules/core/colors.js +1 -1
- package/dist/modules/core/consts.cjs +7 -2
- package/dist/modules/core/consts.d.ts +2 -0
- package/dist/modules/core/consts.js +6 -3
- package/dist/modules/core/globals.cjs +3 -2
- package/dist/modules/core/globals.js +3 -2
- package/dist/modules/core/helpers.cjs +1 -1
- package/dist/modules/core/helpers.js +1 -1
- package/dist/modules/core/render.cjs +4 -2
- package/dist/modules/core/render.js +4 -2
- package/dist/modules/core/styles.cjs +8 -8
- package/dist/modules/core/styles.js +10 -10
- package/dist/modules/core/targets.cjs +1 -1
- package/dist/modules/core/targets.js +1 -1
- package/dist/modules/core/transforms.cjs +1 -1
- package/dist/modules/core/transforms.js +1 -1
- package/dist/modules/core/units.cjs +1 -1
- package/dist/modules/core/units.js +1 -1
- package/dist/modules/core/values.cjs +17 -6
- package/dist/modules/core/values.js +19 -8
- package/dist/modules/draggable/draggable.cjs +32 -19
- package/dist/modules/draggable/draggable.d.ts +3 -1
- package/dist/modules/draggable/draggable.js +28 -15
- package/dist/modules/draggable/index.cjs +1 -1
- package/dist/modules/draggable/index.js +1 -1
- package/dist/modules/easings/{cubic-bezier.cjs → cubic-bezier/index.cjs} +4 -4
- package/dist/modules/easings/{cubic-bezier.d.ts → cubic-bezier/index.d.ts} +1 -1
- package/dist/modules/easings/{cubic-bezier.js → cubic-bezier/index.js} +4 -4
- package/dist/modules/easings/eases/index.cjs +14 -0
- package/dist/modules/easings/eases/index.d.ts +1 -0
- package/dist/modules/easings/eases/index.js +8 -0
- package/dist/modules/easings/{eases.cjs → eases/parser.cjs} +69 -27
- package/dist/modules/easings/{eases.d.ts → eases/parser.d.ts} +31 -17
- package/dist/modules/easings/{eases.js → eases/parser.js} +60 -21
- package/dist/modules/easings/index.cjs +15 -13
- package/dist/modules/easings/index.d.ts +6 -6
- package/dist/modules/easings/index.js +7 -7
- package/dist/modules/easings/{irregular.cjs → irregular/index.cjs} +5 -5
- package/dist/modules/easings/{irregular.d.ts → irregular/index.d.ts} +1 -1
- package/dist/modules/easings/{irregular.js → irregular/index.js} +4 -4
- package/dist/modules/easings/{linear.cjs → linear/index.cjs} +4 -4
- package/dist/modules/easings/{linear.d.ts → linear/index.d.ts} +1 -1
- package/dist/modules/easings/{linear.js → linear/index.js} +4 -4
- package/dist/modules/easings/none.cjs +1 -1
- package/dist/modules/easings/none.js +1 -1
- package/dist/modules/easings/spring/index.cjs +255 -0
- package/dist/modules/{spring/spring.d.ts → easings/spring/index.d.ts} +21 -5
- package/dist/modules/easings/spring/index.js +251 -0
- package/dist/modules/easings/{steps.cjs → steps/index.cjs} +3 -3
- package/dist/modules/easings/{steps.d.ts → steps/index.d.ts} +1 -1
- package/dist/modules/easings/{steps.js → steps/index.js} +3 -3
- package/dist/modules/engine/engine.cjs +1 -1
- package/dist/modules/engine/engine.js +1 -1
- package/dist/modules/engine/index.cjs +1 -1
- package/dist/modules/engine/index.js +1 -1
- package/dist/modules/events/index.cjs +1 -1
- package/dist/modules/events/index.js +1 -1
- package/dist/modules/events/scroll.cjs +17 -9
- package/dist/modules/events/scroll.d.ts +4 -0
- package/dist/modules/events/scroll.js +16 -8
- package/dist/modules/index.cjs +15 -16
- package/dist/modules/index.d.ts +0 -1
- package/dist/modules/index.js +7 -8
- package/dist/modules/scope/index.cjs +1 -1
- package/dist/modules/scope/index.js +1 -1
- package/dist/modules/scope/scope.cjs +1 -1
- package/dist/modules/scope/scope.js +1 -1
- package/dist/modules/svg/drawable.cjs +1 -1
- package/dist/modules/svg/drawable.js +1 -1
- package/dist/modules/svg/helpers.cjs +1 -1
- package/dist/modules/svg/helpers.js +1 -1
- package/dist/modules/svg/index.cjs +1 -1
- package/dist/modules/svg/index.js +1 -1
- package/dist/modules/svg/morphto.cjs +12 -2
- package/dist/modules/svg/morphto.js +12 -2
- package/dist/modules/svg/motionpath.cjs +18 -11
- package/dist/modules/svg/motionpath.d.ts +1 -1
- package/dist/modules/svg/motionpath.js +18 -11
- package/dist/modules/text/index.cjs +1 -1
- package/dist/modules/text/index.js +1 -1
- package/dist/modules/text/split.cjs +1 -1
- package/dist/modules/text/split.js +1 -1
- package/dist/modules/timeline/index.cjs +1 -1
- package/dist/modules/timeline/index.js +1 -1
- package/dist/modules/timeline/position.cjs +1 -1
- package/dist/modules/timeline/position.js +1 -1
- package/dist/modules/timeline/timeline.cjs +11 -7
- package/dist/modules/timeline/timeline.d.ts +8 -3
- package/dist/modules/timeline/timeline.js +10 -6
- package/dist/modules/timer/index.cjs +1 -1
- package/dist/modules/timer/index.js +1 -1
- package/dist/modules/timer/timer.cjs +17 -14
- package/dist/modules/timer/timer.d.ts +12 -7
- package/dist/modules/timer/timer.js +17 -14
- package/dist/modules/types/index.d.ts +35 -14
- package/dist/modules/utils/chainable.cjs +1 -1
- package/dist/modules/utils/chainable.js +1 -1
- package/dist/modules/utils/index.cjs +1 -1
- package/dist/modules/utils/index.js +1 -1
- package/dist/modules/utils/number.cjs +1 -1
- package/dist/modules/utils/number.js +1 -1
- package/dist/modules/utils/random.cjs +1 -1
- package/dist/modules/utils/random.js +1 -1
- package/dist/modules/utils/stagger.cjs +4 -4
- package/dist/modules/utils/stagger.js +3 -3
- package/dist/modules/utils/target.cjs +1 -1
- package/dist/modules/utils/target.js +1 -1
- package/dist/modules/utils/time.cjs +1 -1
- package/dist/modules/utils/time.js +1 -1
- package/dist/modules/waapi/composition.cjs +11 -5
- package/dist/modules/waapi/composition.d.ts +1 -1
- package/dist/modules/waapi/composition.js +11 -5
- package/dist/modules/waapi/index.cjs +1 -1
- package/dist/modules/waapi/index.js +1 -1
- package/dist/modules/waapi/waapi.cjs +58 -36
- package/dist/modules/waapi/waapi.d.ts +12 -7
- package/dist/modules/waapi/waapi.js +59 -37
- package/package.json +48 -13
- package/dist/modules/easings/parser.cjs +0 -59
- package/dist/modules/easings/parser.d.ts +0 -21
- package/dist/modules/easings/parser.js +0 -55
- package/dist/modules/spring/index.cjs +0 -15
- package/dist/modules/spring/index.d.ts +0 -1
- package/dist/modules/spring/index.js +0 -8
- package/dist/modules/spring/spring.cjs +0 -133
- package/dist/modules/spring/spring.js +0 -130
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - waapi - ESM
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { isNil, isUnd, stringStartsWith, isKey, isObj, isArr,
|
|
8
|
+
import { isNil, isUnd, stringStartsWith, isKey, isObj, isArr, toLowerCase, round, isStr, 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';
|
|
12
12
|
import { isBrowser, validTransforms, noop, transformsSymbol, shortTransforms, transformsFragmentStrings, emptyString, K } from '../core/consts.js';
|
|
13
13
|
import { none } from '../easings/none.js';
|
|
14
|
-
import { parseEaseString
|
|
14
|
+
import { parseEaseString } from '../easings/eases/parser.js';
|
|
15
15
|
import { addWAAPIAnimation } from './composition.js';
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -25,7 +25,6 @@ import { addWAAPIAnimation } from './composition.js';
|
|
|
25
25
|
* WAAPIAnimationParams,
|
|
26
26
|
* WAAPITweenOptions,
|
|
27
27
|
* WAAPIKeyframeValue,
|
|
28
|
-
* WAAPICallback,
|
|
29
28
|
* WAAPITweenValue
|
|
30
29
|
* } from '../types/index.js'
|
|
31
30
|
*/
|
|
@@ -33,7 +32,7 @@ import { addWAAPIAnimation } from './composition.js';
|
|
|
33
32
|
/**
|
|
34
33
|
* @import {
|
|
35
34
|
* Spring,
|
|
36
|
-
* } from '../spring/
|
|
35
|
+
* } from '../easings/spring/index.js'
|
|
37
36
|
*/
|
|
38
37
|
|
|
39
38
|
/**
|
|
@@ -50,21 +49,11 @@ import { addWAAPIAnimation } from './composition.js';
|
|
|
50
49
|
*/
|
|
51
50
|
const easingToLinear = (fn, samples = 100) => {
|
|
52
51
|
const points = [];
|
|
53
|
-
for (let i = 0; i <= samples; i++) points.push(fn(i / samples));
|
|
52
|
+
for (let i = 0; i <= samples; i++) points.push(round(fn(i / samples), 4));
|
|
54
53
|
return `linear(${points.join(', ')})`;
|
|
55
54
|
};
|
|
56
55
|
|
|
57
|
-
const WAAPIEasesLookups = {
|
|
58
|
-
in: 'ease-in',
|
|
59
|
-
out: 'ease-out',
|
|
60
|
-
inOut: 'ease-in-out',
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const WAAPIeases = /*#__PURE__*/(() => {
|
|
64
|
-
const list = {};
|
|
65
|
-
for (let type in easeTypes) list[type] = (/** @type {String|Number} */p) => easeTypes[type](easeInPower(p));
|
|
66
|
-
return /** @type {Record<String, EasingFunction>} */(list);
|
|
67
|
-
})();
|
|
56
|
+
const WAAPIEasesLookups = {};
|
|
68
57
|
|
|
69
58
|
/**
|
|
70
59
|
* @param {EasingParam} ease
|
|
@@ -85,9 +74,10 @@ const parseWAAPIEasing = (ease) => {
|
|
|
85
74
|
} else if (stringStartsWith(ease, 'cubicB')) {
|
|
86
75
|
parsedEase = toLowerCase(ease);
|
|
87
76
|
} else {
|
|
88
|
-
const parsed = parseEaseString(ease
|
|
77
|
+
const parsed = parseEaseString(ease);
|
|
89
78
|
if (isFnc(parsed)) parsedEase = parsed === none ? 'linear' : easingToLinear(parsed);
|
|
90
79
|
}
|
|
80
|
+
// Only cache string based easing name, otherwise function arguments get lost
|
|
91
81
|
WAAPIEasesLookups[ease] = parsedEase;
|
|
92
82
|
} else if (isFnc(ease)) {
|
|
93
83
|
const easing = easingToLinear(ease);
|
|
@@ -128,7 +118,8 @@ let transformsPropertiesRegistered = null;
|
|
|
128
118
|
* @return {String}
|
|
129
119
|
*/
|
|
130
120
|
const normalizeTweenValue = (propName, value, $el, i, targetsLength) => {
|
|
131
|
-
|
|
121
|
+
// Do not try to compute strings with getFunctionValue otherwise it will convert CSS variables
|
|
122
|
+
let v = isStr(value) ? value : getFunctionValue(/** @type {any} */(value), $el, i, targetsLength);
|
|
132
123
|
if (!isNum(v)) return v;
|
|
133
124
|
if (commonDefaultPXProperties.includes(propName) || stringStartsWith(propName, 'translate')) return `${v}px`;
|
|
134
125
|
if (stringStartsWith(propName, 'rotate') || stringStartsWith(propName, 'skew')) return `${v}deg`;
|
|
@@ -208,7 +199,7 @@ class WAAPIAnimation {
|
|
|
208
199
|
/** @type {PlaybackDirection} */
|
|
209
200
|
const direction = alternate ? reversed ? 'alternate-reverse' : 'alternate' : reversed ? 'reverse' : 'normal';
|
|
210
201
|
/** @type {FillMode} */
|
|
211
|
-
const fill = '
|
|
202
|
+
const fill = 'both'; // We use 'both' here because the animation can be reversed during playback
|
|
212
203
|
/** @type {String} */
|
|
213
204
|
const easing = parseWAAPIEasing(ease);
|
|
214
205
|
const timeScale = (globals.timeScale === 1 ? 1 : K);
|
|
@@ -220,7 +211,7 @@ class WAAPIAnimation {
|
|
|
220
211
|
/** @type {globalThis.Animation}] */
|
|
221
212
|
this.controlAnimation = null;
|
|
222
213
|
/** @type {Callback<this>} */
|
|
223
|
-
this.onComplete = params.onComplete ||
|
|
214
|
+
this.onComplete = params.onComplete || /** @type {Callback<WAAPIAnimation>} */(/** @type {unknown} */(globals.defaults.onComplete));
|
|
224
215
|
/** @type {Number} */
|
|
225
216
|
this.duration = 0;
|
|
226
217
|
/** @type {Boolean} */
|
|
@@ -231,6 +222,8 @@ class WAAPIAnimation {
|
|
|
231
222
|
this.paused = !autoplay || scroll !== false;
|
|
232
223
|
/** @type {Boolean} */
|
|
233
224
|
this.reversed = reversed;
|
|
225
|
+
/** @type {Boolean} */
|
|
226
|
+
this.persist = setValue(params.persist, globals.defaults.persist);
|
|
234
227
|
/** @type {Boolean|ScrollObserver} */
|
|
235
228
|
this.autoplay = autoplay;
|
|
236
229
|
/** @type {Number} */
|
|
@@ -239,17 +232,18 @@ class WAAPIAnimation {
|
|
|
239
232
|
this._resolve = noop; // Used by .then()
|
|
240
233
|
/** @type {Number} */
|
|
241
234
|
this._completed = 0;
|
|
242
|
-
/** @type {Array
|
|
243
|
-
this._inlineStyles =
|
|
235
|
+
/** @type {Array.<Object>} */
|
|
236
|
+
this._inlineStyles = [];
|
|
244
237
|
|
|
245
238
|
parsedTargets.forEach(($el, i) => {
|
|
246
239
|
|
|
247
240
|
const cachedTransforms = $el[transformsSymbol];
|
|
248
|
-
|
|
249
241
|
const hasIndividualTransforms = validIndividualTransforms.some(t => params.hasOwnProperty(t));
|
|
242
|
+
const elStyle = $el.style;
|
|
243
|
+
const inlineStyles = this._inlineStyles[i] = {};
|
|
250
244
|
|
|
251
245
|
/** @type {Number} */
|
|
252
|
-
const duration = (spring ? /** @type {Spring} */(spring).
|
|
246
|
+
const duration = (spring ? /** @type {Spring} */(spring).settlingDuration : getFunctionValue(setValue(params.duration, globals.defaults.duration), $el, i, targetsLength)) * timeScale;
|
|
253
247
|
/** @type {Number} */
|
|
254
248
|
const delay = getFunctionValue(setValue(params.delay, globals.defaults.delay), $el, i, targetsLength) * timeScale;
|
|
255
249
|
/** @type {CompositeOperation} */
|
|
@@ -263,6 +257,12 @@ class WAAPIAnimation {
|
|
|
263
257
|
const tweenParams = { iterations, direction, fill, easing, duration, delay, composite };
|
|
264
258
|
const propertyValue = params[name];
|
|
265
259
|
const individualTransformProperty = hasIndividualTransforms ? validTransforms.includes(name) ? name : shortTransforms.get(name) : false;
|
|
260
|
+
|
|
261
|
+
const styleName = individualTransformProperty ? 'transform' : name;
|
|
262
|
+
if (!inlineStyles[styleName]) {
|
|
263
|
+
inlineStyles[styleName] = elStyle[styleName];
|
|
264
|
+
}
|
|
265
|
+
|
|
266
266
|
let parsedPropertyValue;
|
|
267
267
|
if (isObj(propertyValue)) {
|
|
268
268
|
const tweenOptions = /** @type {WAAPITweenOptions} */(propertyValue);
|
|
@@ -271,7 +271,7 @@ class WAAPIAnimation {
|
|
|
271
271
|
const to = /** @type {WAAPITweenOptions} */(tweenOptions).to;
|
|
272
272
|
const from = /** @type {WAAPITweenOptions} */(tweenOptions).from;
|
|
273
273
|
/** @type {Number} */
|
|
274
|
-
tweenParams.duration = (tweenOptionsSpring ? /** @type {Spring} */(tweenOptionsSpring).
|
|
274
|
+
tweenParams.duration = (tweenOptionsSpring ? /** @type {Spring} */(tweenOptionsSpring).settlingDuration : getFunctionValue(setValue(tweenOptions.duration, duration), $el, i, targetsLength)) * timeScale;
|
|
275
275
|
/** @type {Number} */
|
|
276
276
|
tweenParams.delay = getFunctionValue(setValue(tweenOptions.delay, delay), $el, i, targetsLength) * timeScale;
|
|
277
277
|
/** @type {CompositeOperation} */
|
|
@@ -288,10 +288,10 @@ class WAAPIAnimation {
|
|
|
288
288
|
addWAAPIAnimation(this, $el, name, keyframes, tweenParams);
|
|
289
289
|
if (!isUnd(from)) {
|
|
290
290
|
if (!individualTransformProperty) {
|
|
291
|
-
|
|
291
|
+
elStyle[name] = keyframes[name][0];
|
|
292
292
|
} else {
|
|
293
293
|
const key = `--${individualTransformProperty}`;
|
|
294
|
-
|
|
294
|
+
elStyle.setProperty(key, keyframes[key][0]);
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
} else {
|
|
@@ -312,7 +312,7 @@ class WAAPIAnimation {
|
|
|
312
312
|
for (let t in cachedTransforms) {
|
|
313
313
|
transforms += `${transformsFragmentStrings[t]}var(--${t})) `;
|
|
314
314
|
}
|
|
315
|
-
|
|
315
|
+
elStyle.transform = transforms;
|
|
316
316
|
}
|
|
317
317
|
});
|
|
318
318
|
|
|
@@ -357,7 +357,8 @@ class WAAPIAnimation {
|
|
|
357
357
|
// Make sure the animation playState is not 'paused' in order to properly trigger an onfinish callback.
|
|
358
358
|
// The "paused" play state supersedes the "finished" play state; if the animation is both paused and finished, the "paused" state is the one that will be reported.
|
|
359
359
|
// https://developer.mozilla.org/en-US/docs/Web/API/Animation/finish_event
|
|
360
|
-
|
|
360
|
+
// This is not needed for persisting animations since they never finish.
|
|
361
|
+
if (!this.persist && t >= this.duration) anim.play();
|
|
361
362
|
anim.currentTime = t;
|
|
362
363
|
});
|
|
363
364
|
}
|
|
@@ -427,25 +428,46 @@ class WAAPIAnimation {
|
|
|
427
428
|
}
|
|
428
429
|
|
|
429
430
|
cancel() {
|
|
430
|
-
this.
|
|
431
|
-
return this.
|
|
431
|
+
this.muteCallbacks = true; // This prevents triggering the onComplete callback and resolving the Promise
|
|
432
|
+
return this.commitStyles().forEach('cancel');
|
|
432
433
|
}
|
|
433
434
|
|
|
434
435
|
revert() {
|
|
435
|
-
|
|
436
|
-
|
|
436
|
+
// NOTE: We need a better way to revert the transforms, since right now the entire transform property value is reverted,
|
|
437
|
+
// This means if you have multiple animations animating different transforms on the same target,
|
|
438
|
+
// 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 is they exist instead of the entire transform value,
|
|
440
|
+
// and update the CSS variables with the orignal value
|
|
441
|
+
this.cancel().targets.forEach(($el, i) => {
|
|
442
|
+
const targetStyle = $el.style;
|
|
443
|
+
const targetInlineStyles = this._inlineStyles[i];
|
|
444
|
+
for (let name in targetInlineStyles) {
|
|
445
|
+
const originalInlinedValue = targetInlineStyles[name];
|
|
446
|
+
if (isUnd(originalInlinedValue) || originalInlinedValue === emptyString) {
|
|
447
|
+
targetStyle.removeProperty(toLowerCase(name));
|
|
448
|
+
} else {
|
|
449
|
+
targetStyle[name] = originalInlinedValue;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
// Remove style attribute if empty
|
|
453
|
+
if ($el.getAttribute('style') === emptyString) $el.removeAttribute('style');
|
|
454
|
+
});
|
|
437
455
|
return this;
|
|
438
456
|
}
|
|
439
457
|
|
|
440
458
|
/**
|
|
441
|
-
* @
|
|
442
|
-
|
|
459
|
+
* @typedef {this & {then: null}} ResolvedWAAPIAnimation
|
|
460
|
+
*/
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* @param {Callback<ResolvedWAAPIAnimation>} [callback]
|
|
464
|
+
* @return Promise<this>
|
|
443
465
|
*/
|
|
444
466
|
then(callback = noop) {
|
|
445
467
|
const then = this.then;
|
|
446
468
|
const onResolve = () => {
|
|
447
469
|
this.then = null;
|
|
448
|
-
callback(this);
|
|
470
|
+
callback(/** @type {ResolvedWAAPIAnimation} */(this));
|
|
449
471
|
this.then = then;
|
|
450
472
|
this._resolve = noop;
|
|
451
473
|
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "animejs",
|
|
3
|
-
"version": "4.2.
|
|
4
|
-
"description": "JavaScript animation engine",
|
|
3
|
+
"version": "4.2.1",
|
|
5
4
|
"homepage": "https://animejs.com",
|
|
5
|
+
"description": "JavaScript animation engine",
|
|
6
6
|
"author": "Julian Garnier <julian@animejs.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|
|
@@ -20,14 +20,18 @@
|
|
|
20
20
|
"anime",
|
|
21
21
|
"animejs",
|
|
22
22
|
"anime.js",
|
|
23
|
+
"timer",
|
|
23
24
|
"animation",
|
|
24
25
|
"timeline",
|
|
26
|
+
"animatable",
|
|
27
|
+
"draggable",
|
|
28
|
+
"scope",
|
|
29
|
+
"engine",
|
|
30
|
+
"scroll",
|
|
25
31
|
"easings",
|
|
32
|
+
"cubic-bezier",
|
|
26
33
|
"spring",
|
|
27
|
-
"
|
|
28
|
-
"drag",
|
|
29
|
-
"text",
|
|
30
|
-
"JavaScript",
|
|
34
|
+
"splitText",
|
|
31
35
|
"CSS",
|
|
32
36
|
"SVG",
|
|
33
37
|
"WAAPI",
|
|
@@ -100,18 +104,48 @@
|
|
|
100
104
|
"import": "./dist/modules/events/index.js",
|
|
101
105
|
"default": "./dist/modules/events/index.cjs"
|
|
102
106
|
},
|
|
103
|
-
"./spring": {
|
|
104
|
-
"types": "./dist/modules/spring/index.d.ts",
|
|
105
|
-
"require": "./dist/modules/spring/index.cjs",
|
|
106
|
-
"import": "./dist/modules/spring/index.js",
|
|
107
|
-
"default": "./dist/modules/spring/index.cjs"
|
|
108
|
-
},
|
|
109
107
|
"./easings": {
|
|
110
108
|
"types": "./dist/modules/easings/index.d.ts",
|
|
111
109
|
"require": "./dist/modules/easings/index.cjs",
|
|
112
110
|
"import": "./dist/modules/easings/index.js",
|
|
113
111
|
"default": "./dist/modules/easings/index.cjs"
|
|
114
112
|
},
|
|
113
|
+
"./easings/eases": {
|
|
114
|
+
"types": "./dist/modules/easings/eases/index.d.ts",
|
|
115
|
+
"require": "./dist/modules/easings/eases/index.cjs",
|
|
116
|
+
"import": "./dist/modules/easings/eases/index.js",
|
|
117
|
+
"default": "./dist/modules/easings/eases/index.cjs"
|
|
118
|
+
},
|
|
119
|
+
"./easings/linear": {
|
|
120
|
+
"types": "./dist/modules/easings/linear/index.d.ts",
|
|
121
|
+
"require": "./dist/modules/easings/linear/index.cjs",
|
|
122
|
+
"import": "./dist/modules/easings/linear/index.js",
|
|
123
|
+
"default": "./dist/modules/easings/linear/index.cjs"
|
|
124
|
+
},
|
|
125
|
+
"./easings/steps": {
|
|
126
|
+
"types": "./dist/modules/easings/steps/index.d.ts",
|
|
127
|
+
"require": "./dist/modules/easings/steps/index.cjs",
|
|
128
|
+
"import": "./dist/modules/easings/steps/index.js",
|
|
129
|
+
"default": "./dist/modules/easings/steps/index.cjs"
|
|
130
|
+
},
|
|
131
|
+
"./easings/irregular": {
|
|
132
|
+
"types": "./dist/modules/easings/irregular/index.d.ts",
|
|
133
|
+
"require": "./dist/modules/easings/irregular/index.cjs",
|
|
134
|
+
"import": "./dist/modules/easings/irregular/index.js",
|
|
135
|
+
"default": "./dist/modules/easings/irregular/index.cjs"
|
|
136
|
+
},
|
|
137
|
+
"./easings/cubic-bezier": {
|
|
138
|
+
"types": "./dist/modules/easings/cubic-bezier/index.d.ts",
|
|
139
|
+
"require": "./dist/modules/easings/cubic-bezier/index.cjs",
|
|
140
|
+
"import": "./dist/modules/easings/cubic-bezier/index.js",
|
|
141
|
+
"default": "./dist/modules/easings/cubic-bezier/index.cjs"
|
|
142
|
+
},
|
|
143
|
+
"./easings/spring": {
|
|
144
|
+
"types": "./dist/modules/easings/spring/index.d.ts",
|
|
145
|
+
"require": "./dist/modules/easings/spring/index.cjs",
|
|
146
|
+
"import": "./dist/modules/easings/spring/index.js",
|
|
147
|
+
"default": "./dist/modules/easings/spring/index.cjs"
|
|
148
|
+
},
|
|
115
149
|
"./utils": {
|
|
116
150
|
"types": "./dist/modules/utils/index.d.ts",
|
|
117
151
|
"require": "./dist/modules/utils/index.cjs",
|
|
@@ -139,8 +173,9 @@
|
|
|
139
173
|
},
|
|
140
174
|
"devDependencies": {
|
|
141
175
|
"@rollup/plugin-terser": "^0.4.4",
|
|
176
|
+
"@types/mocha": "^10.0.10",
|
|
142
177
|
"@types/node": "^24.3.0",
|
|
143
|
-
"browser-sync": "^
|
|
178
|
+
"browser-sync": "^3.0.4",
|
|
144
179
|
"chai": "^4.3.10",
|
|
145
180
|
"mocha": "^10.2.0",
|
|
146
181
|
"nodemon": "^3.1.10",
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Anime.js - easings - CJS
|
|
3
|
-
* @version v4.2.0
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright 2025 - Julian Garnier
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
'use strict';
|
|
9
|
-
|
|
10
|
-
var helpers = require('../core/helpers.cjs');
|
|
11
|
-
var none = require('./none.cjs');
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @import {
|
|
15
|
-
* EasingFunction,
|
|
16
|
-
* PowerEasing,
|
|
17
|
-
* EasingFunctionWithParams,
|
|
18
|
-
* } from '../types/index.js'
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/** @type {PowerEasing} */
|
|
22
|
-
const easeInPower = (p = 1.68) => t => helpers.pow(t, +p);
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @callback EaseType
|
|
26
|
-
* @param {EasingFunction} Ease
|
|
27
|
-
* @return {EasingFunction}
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
/** @type {Record<String, EaseType>} */
|
|
31
|
-
const easeTypes = {
|
|
32
|
-
in: easeIn => t => easeIn(t),
|
|
33
|
-
out: easeIn => t => 1 - easeIn(1 - t),
|
|
34
|
-
inOut: easeIn => t => t < .5 ? easeIn(t * 2) / 2 : 1 - easeIn(t * -2 + 2) / 2,
|
|
35
|
-
outIn: easeIn => t => t < .5 ? (1 - easeIn(1 - t * 2)) / 2 : (easeIn(t * 2 - 1) + 1) / 2,
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @param {String} string
|
|
40
|
-
* @param {Record<String, EasingFunctionWithParams|EasingFunction>} easesFunctions
|
|
41
|
-
* @param {Object} easesLookups
|
|
42
|
-
* @return {EasingFunction}
|
|
43
|
-
*/
|
|
44
|
-
const parseEaseString = (string, easesFunctions, easesLookups) => {
|
|
45
|
-
if (easesLookups[string]) return easesLookups[string];
|
|
46
|
-
if (string.indexOf('(') <= -1) {
|
|
47
|
-
const hasParams = easeTypes[string] || string.includes('Back') || string.includes('Elastic');
|
|
48
|
-
const parsedFn = /** @type {EasingFunction} */(hasParams ? /** @type {EasingFunctionWithParams} */(easesFunctions[string])() : easesFunctions[string]);
|
|
49
|
-
return parsedFn ? easesLookups[string] = parsedFn : none.none;
|
|
50
|
-
} else {
|
|
51
|
-
const split = string.slice(0, -1).split('(');
|
|
52
|
-
const parsedFn = /** @type {EasingFunctionWithParams} */(easesFunctions[split[0]]);
|
|
53
|
-
return parsedFn ? easesLookups[string] = parsedFn(...split[1].split(',')) : none.none;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
exports.easeInPower = easeInPower;
|
|
58
|
-
exports.easeTypes = easeTypes;
|
|
59
|
-
exports.parseEaseString = parseEaseString;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @import {
|
|
3
|
-
* EasingFunction,
|
|
4
|
-
* PowerEasing,
|
|
5
|
-
* EasingFunctionWithParams,
|
|
6
|
-
* } from '../types/index.js'
|
|
7
|
-
*/
|
|
8
|
-
/** @type {PowerEasing} */
|
|
9
|
-
export const easeInPower: PowerEasing;
|
|
10
|
-
/**
|
|
11
|
-
* @callback EaseType
|
|
12
|
-
* @param {EasingFunction} Ease
|
|
13
|
-
* @return {EasingFunction}
|
|
14
|
-
*/
|
|
15
|
-
/** @type {Record<String, EaseType>} */
|
|
16
|
-
export const easeTypes: Record<string, EaseType>;
|
|
17
|
-
export function parseEaseString(string: string, easesFunctions: Record<string, EasingFunctionWithParams | EasingFunction>, easesLookups: any): EasingFunction;
|
|
18
|
-
export type EaseType = (Ease: EasingFunction) => EasingFunction;
|
|
19
|
-
import type { PowerEasing } from '../types/index.js';
|
|
20
|
-
import type { EasingFunctionWithParams } from '../types/index.js';
|
|
21
|
-
import type { EasingFunction } from '../types/index.js';
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Anime.js - easings - ESM
|
|
3
|
-
* @version v4.2.0
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright 2025 - Julian Garnier
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { pow } from '../core/helpers.js';
|
|
9
|
-
import { none } from './none.js';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @import {
|
|
13
|
-
* EasingFunction,
|
|
14
|
-
* PowerEasing,
|
|
15
|
-
* EasingFunctionWithParams,
|
|
16
|
-
* } from '../types/index.js'
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/** @type {PowerEasing} */
|
|
20
|
-
const easeInPower = (p = 1.68) => t => pow(t, +p);
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @callback EaseType
|
|
24
|
-
* @param {EasingFunction} Ease
|
|
25
|
-
* @return {EasingFunction}
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/** @type {Record<String, EaseType>} */
|
|
29
|
-
const easeTypes = {
|
|
30
|
-
in: easeIn => t => easeIn(t),
|
|
31
|
-
out: easeIn => t => 1 - easeIn(1 - t),
|
|
32
|
-
inOut: easeIn => t => t < .5 ? easeIn(t * 2) / 2 : 1 - easeIn(t * -2 + 2) / 2,
|
|
33
|
-
outIn: easeIn => t => t < .5 ? (1 - easeIn(1 - t * 2)) / 2 : (easeIn(t * 2 - 1) + 1) / 2,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @param {String} string
|
|
38
|
-
* @param {Record<String, EasingFunctionWithParams|EasingFunction>} easesFunctions
|
|
39
|
-
* @param {Object} easesLookups
|
|
40
|
-
* @return {EasingFunction}
|
|
41
|
-
*/
|
|
42
|
-
const parseEaseString = (string, easesFunctions, easesLookups) => {
|
|
43
|
-
if (easesLookups[string]) return easesLookups[string];
|
|
44
|
-
if (string.indexOf('(') <= -1) {
|
|
45
|
-
const hasParams = easeTypes[string] || string.includes('Back') || string.includes('Elastic');
|
|
46
|
-
const parsedFn = /** @type {EasingFunction} */(hasParams ? /** @type {EasingFunctionWithParams} */(easesFunctions[string])() : easesFunctions[string]);
|
|
47
|
-
return parsedFn ? easesLookups[string] = parsedFn : none;
|
|
48
|
-
} else {
|
|
49
|
-
const split = string.slice(0, -1).split('(');
|
|
50
|
-
const parsedFn = /** @type {EasingFunctionWithParams} */(easesFunctions[split[0]]);
|
|
51
|
-
return parsedFn ? easesLookups[string] = parsedFn(...split[1].split(',')) : none;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export { easeInPower, easeTypes, parseEaseString };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Anime.js - spring - CJS
|
|
3
|
-
* @version v4.2.0
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright 2025 - Julian Garnier
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
'use strict';
|
|
9
|
-
|
|
10
|
-
var spring = require('./spring.cjs');
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
exports.Spring = spring.Spring;
|
|
15
|
-
exports.createSpring = spring.createSpring;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./spring.js";
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Anime.js - spring - CJS
|
|
3
|
-
* @version v4.2.0
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright 2025 - Julian Garnier
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
'use strict';
|
|
9
|
-
|
|
10
|
-
var consts = require('../core/consts.cjs');
|
|
11
|
-
var globals = require('../core/globals.cjs');
|
|
12
|
-
var helpers = require('../core/helpers.cjs');
|
|
13
|
-
var values = require('../core/values.cjs');
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @import {
|
|
17
|
-
* EasingFunction,
|
|
18
|
-
* SpringParams,
|
|
19
|
-
* } from '../types/index.js'
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/*
|
|
23
|
-
* Spring ease solver adapted from https://webkit.org/demos/spring/spring.js
|
|
24
|
-
* (c) 2016 Webkit - Apple Inc
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
const maxSpringParamValue = consts.K * 10;
|
|
28
|
-
|
|
29
|
-
class Spring {
|
|
30
|
-
/**
|
|
31
|
-
* @param {SpringParams} [parameters]
|
|
32
|
-
*/
|
|
33
|
-
constructor(parameters = {}) {
|
|
34
|
-
this.timeStep = .02; // Interval fed to the solver to calculate duration
|
|
35
|
-
this.restThreshold = .0005; // Values below this threshold are considered resting position
|
|
36
|
-
this.restDuration = 200; // Duration in ms used to check if the spring is resting after reaching restThreshold
|
|
37
|
-
this.maxDuration = 60000; // The maximum allowed spring duration in ms (default 1 min)
|
|
38
|
-
this.maxRestSteps = this.restDuration / this.timeStep / consts.K; // How many steps allowed after reaching restThreshold before stopping the duration calculation
|
|
39
|
-
this.maxIterations = this.maxDuration / this.timeStep / consts.K; // Calculate the maximum iterations allowed based on maxDuration
|
|
40
|
-
this.m = helpers.clamp(values.setValue(parameters.mass, 1), 0, maxSpringParamValue);
|
|
41
|
-
this.s = helpers.clamp(values.setValue(parameters.stiffness, 100), 1, maxSpringParamValue);
|
|
42
|
-
this.d = helpers.clamp(values.setValue(parameters.damping, 10), .1, maxSpringParamValue);
|
|
43
|
-
this.v = helpers.clamp(values.setValue(parameters.velocity, 0), -maxSpringParamValue, maxSpringParamValue);
|
|
44
|
-
this.w0 = 0;
|
|
45
|
-
this.zeta = 0;
|
|
46
|
-
this.wd = 0;
|
|
47
|
-
this.b = 0;
|
|
48
|
-
this.solverDuration = 0;
|
|
49
|
-
this.duration = 0;
|
|
50
|
-
this.compute();
|
|
51
|
-
/** @type {EasingFunction} */
|
|
52
|
-
this.ease = t => t === 0 || t === 1 ? t : this.solve(t * this.solverDuration);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** @type {EasingFunction} */
|
|
56
|
-
solve(time) {
|
|
57
|
-
const { zeta, w0, wd, b } = this;
|
|
58
|
-
let t = time;
|
|
59
|
-
if (zeta < 1) {
|
|
60
|
-
t = helpers.exp(-t * zeta * w0) * (1 * helpers.cos(wd * t) + b * helpers.sin(wd * t));
|
|
61
|
-
} else {
|
|
62
|
-
t = (1 + b * t) * helpers.exp(-t * w0);
|
|
63
|
-
}
|
|
64
|
-
return 1 - t;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
compute() {
|
|
68
|
-
const { maxRestSteps, maxIterations, restThreshold, timeStep, m, d, s, v } = this;
|
|
69
|
-
const w0 = this.w0 = helpers.clamp(helpers.sqrt(s / m), consts.minValue, consts.K);
|
|
70
|
-
const zeta = this.zeta = d / (2 * helpers.sqrt(s * m));
|
|
71
|
-
const wd = this.wd = zeta < 1 ? w0 * helpers.sqrt(1 - zeta * zeta) : 0;
|
|
72
|
-
this.b = zeta < 1 ? (zeta * w0 + -v) / wd : -v + w0;
|
|
73
|
-
let solverTime = 0;
|
|
74
|
-
let restSteps = 0;
|
|
75
|
-
let iterations = 0;
|
|
76
|
-
while (restSteps < maxRestSteps && iterations < maxIterations) {
|
|
77
|
-
if (helpers.abs(1 - this.solve(solverTime)) < restThreshold) {
|
|
78
|
-
restSteps++;
|
|
79
|
-
} else {
|
|
80
|
-
restSteps = 0;
|
|
81
|
-
}
|
|
82
|
-
this.solverDuration = solverTime;
|
|
83
|
-
solverTime += timeStep;
|
|
84
|
-
iterations++;
|
|
85
|
-
}
|
|
86
|
-
this.duration = helpers.round(this.solverDuration * consts.K, 0) * globals.globals.timeScale;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
get mass() {
|
|
90
|
-
return this.m;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
set mass(v) {
|
|
94
|
-
this.m = helpers.clamp(values.setValue(v, 1), 0, maxSpringParamValue);
|
|
95
|
-
this.compute();
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
get stiffness() {
|
|
99
|
-
return this.s;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
set stiffness(v) {
|
|
103
|
-
this.s = helpers.clamp(values.setValue(v, 100), 1, maxSpringParamValue);
|
|
104
|
-
this.compute();
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
get damping() {
|
|
108
|
-
return this.d;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
set damping(v) {
|
|
112
|
-
this.d = helpers.clamp(values.setValue(v, 10), .1, maxSpringParamValue);
|
|
113
|
-
this.compute();
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
get velocity() {
|
|
117
|
-
return this.v;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
set velocity(v) {
|
|
121
|
-
this.v = helpers.clamp(values.setValue(v, 0), -maxSpringParamValue, maxSpringParamValue);
|
|
122
|
-
this.compute();
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* @param {SpringParams} [parameters]
|
|
128
|
-
* @returns {Spring}
|
|
129
|
-
*/
|
|
130
|
-
const createSpring = (parameters) => new Spring(parameters);
|
|
131
|
-
|
|
132
|
-
exports.Spring = Spring;
|
|
133
|
-
exports.createSpring = createSpring;
|