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,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - events - CJS
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
@@ -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 {
|
|
@@ -95,6 +95,8 @@ class ScrollContainer {
|
|
|
95
95
|
/** @type {Number} */
|
|
96
96
|
this.top = 0;
|
|
97
97
|
/** @type {Number} */
|
|
98
|
+
this.scale = 1;
|
|
99
|
+
/** @type {Number} */
|
|
98
100
|
this.zIndex = 0;
|
|
99
101
|
/** @type {Number} */
|
|
100
102
|
this.scrollX = 0;
|
|
@@ -206,6 +208,7 @@ class ScrollContainer {
|
|
|
206
208
|
height = $el.clientHeight;
|
|
207
209
|
this.top = elRect.top;
|
|
208
210
|
this.left = elRect.left;
|
|
211
|
+
this.scale = elRect.width ? width / elRect.width : (elRect.height ? height / elRect.height : 1);
|
|
209
212
|
}
|
|
210
213
|
this.width = width;
|
|
211
214
|
this.height = height;
|
|
@@ -368,7 +371,7 @@ class ScrollObserver {
|
|
|
368
371
|
constructor(parameters = {}) {
|
|
369
372
|
if (globals.scope.current) globals.scope.current.register(this);
|
|
370
373
|
const syncMode = values.setValue(parameters.sync, 'play pause');
|
|
371
|
-
const ease = syncMode ?
|
|
374
|
+
const ease = syncMode ? parser.parseEase(/** @type {EasingParam} */(syncMode)) : null;
|
|
372
375
|
const isLinear = syncMode && (syncMode === 'linear' || syncMode === none.none);
|
|
373
376
|
const isEase = syncMode && !(ease === none.none && !isLinear);
|
|
374
377
|
const isSmooth = syncMode && (helpers.isNum(syncMode) || syncMode === true || isLinear);
|
|
@@ -435,6 +438,8 @@ class ScrollObserver {
|
|
|
435
438
|
/** @type {Boolean} */
|
|
436
439
|
this.reverted = false;
|
|
437
440
|
/** @type {Boolean} */
|
|
441
|
+
this.ready = false;
|
|
442
|
+
/** @type {Boolean} */
|
|
438
443
|
this.completed = false;
|
|
439
444
|
/** @type {Boolean} */
|
|
440
445
|
this.began = false;
|
|
@@ -444,8 +449,6 @@ class ScrollObserver {
|
|
|
444
449
|
this.forceEnter = false;
|
|
445
450
|
/** @type {Boolean} */
|
|
446
451
|
this.hasEntered = false;
|
|
447
|
-
// /** @type {Array.<Number>} */
|
|
448
|
-
// this.offsets = [];
|
|
449
452
|
/** @type {Number} */
|
|
450
453
|
this.offset = 0;
|
|
451
454
|
/** @type {Number} */
|
|
@@ -493,6 +496,8 @@ class ScrollObserver {
|
|
|
493
496
|
// Make sure to pause the linked object in case it's added later
|
|
494
497
|
linked.pause();
|
|
495
498
|
this.linked = linked;
|
|
499
|
+
// Forces WAAPI Animation to persist; otherwise, they will stop syncing on finish.
|
|
500
|
+
if (!helpers.isUnd(/** @type {WAAPIAnimation} */(linked))) /** @type {WAAPIAnimation} */(linked).persist = true;
|
|
496
501
|
// Try to use a target of the linked object if no target parameters specified
|
|
497
502
|
if (!this._params.target) {
|
|
498
503
|
/** @type {HTMLElement} */
|
|
@@ -532,6 +537,8 @@ class ScrollObserver {
|
|
|
532
537
|
}
|
|
533
538
|
|
|
534
539
|
refresh() {
|
|
540
|
+
// This flag is used to prevent running handleScroll() outside of this.refresh() with values not yet calculated
|
|
541
|
+
this.ready = true;
|
|
535
542
|
this.reverted = false;
|
|
536
543
|
const params = this._params;
|
|
537
544
|
this.repeat = values.setValue(parseScrollObserverFunctionParameter(params.repeat, this), true);
|
|
@@ -727,8 +734,9 @@ class ScrollObserver {
|
|
|
727
734
|
}
|
|
728
735
|
}
|
|
729
736
|
const rect = $target.getBoundingClientRect();
|
|
730
|
-
const
|
|
731
|
-
const
|
|
737
|
+
const scale = container.scale;
|
|
738
|
+
const offset = (isHori ? rect.left + container.scrollX - container.left : rect.top + container.scrollY - container.top) * scale;
|
|
739
|
+
const targetSize = (isHori ? rect.width : rect.height) * scale;
|
|
732
740
|
const containerSize = isHori ? container.width : container.height;
|
|
733
741
|
const scrollSize = isHori ? container.scrollWidth : container.scrollHeight;
|
|
734
742
|
const maxScroll = scrollSize - containerSize;
|
|
@@ -777,8 +785,6 @@ class ScrollObserver {
|
|
|
777
785
|
const offsetStart = parsedEnterTarget + offset - parsedEnterContainer;
|
|
778
786
|
const offsetEnd = parsedLeaveTarget + offset - parsedLeaveContainer;
|
|
779
787
|
const scrollDelta = offsetEnd - offsetStart;
|
|
780
|
-
// this.offsets[0] = offsetX;
|
|
781
|
-
// this.offsets[1] = offsetY;
|
|
782
788
|
this.offset = offset;
|
|
783
789
|
this.offsetStart = offsetStart;
|
|
784
790
|
this.offsetEnd = offsetEnd;
|
|
@@ -797,6 +803,7 @@ class ScrollObserver {
|
|
|
797
803
|
}
|
|
798
804
|
|
|
799
805
|
handleScroll() {
|
|
806
|
+
if (!this.ready) return;
|
|
800
807
|
const linked = this.linked;
|
|
801
808
|
const sync = this.sync;
|
|
802
809
|
const syncEase = this.syncEase;
|
|
@@ -920,6 +927,7 @@ class ScrollObserver {
|
|
|
920
927
|
this.removeDebug();
|
|
921
928
|
}
|
|
922
929
|
this.reverted = true;
|
|
930
|
+
this.ready = false;
|
|
923
931
|
return this;
|
|
924
932
|
}
|
|
925
933
|
|
|
@@ -59,6 +59,8 @@ export class ScrollObserver {
|
|
|
59
59
|
/** @type {Boolean} */
|
|
60
60
|
reverted: boolean;
|
|
61
61
|
/** @type {Boolean} */
|
|
62
|
+
ready: boolean;
|
|
63
|
+
/** @type {Boolean} */
|
|
62
64
|
completed: boolean;
|
|
63
65
|
/** @type {Boolean} */
|
|
64
66
|
began: boolean;
|
|
@@ -132,6 +134,8 @@ declare class ScrollContainer {
|
|
|
132
134
|
/** @type {Number} */
|
|
133
135
|
top: number;
|
|
134
136
|
/** @type {Number} */
|
|
137
|
+
scale: number;
|
|
138
|
+
/** @type {Number} */
|
|
135
139
|
zIndex: number;
|
|
136
140
|
/** @type {Number} */
|
|
137
141
|
scrollX: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - events - ESM
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
@@ -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 {
|
|
@@ -93,6 +93,8 @@ class ScrollContainer {
|
|
|
93
93
|
/** @type {Number} */
|
|
94
94
|
this.top = 0;
|
|
95
95
|
/** @type {Number} */
|
|
96
|
+
this.scale = 1;
|
|
97
|
+
/** @type {Number} */
|
|
96
98
|
this.zIndex = 0;
|
|
97
99
|
/** @type {Number} */
|
|
98
100
|
this.scrollX = 0;
|
|
@@ -204,6 +206,7 @@ class ScrollContainer {
|
|
|
204
206
|
height = $el.clientHeight;
|
|
205
207
|
this.top = elRect.top;
|
|
206
208
|
this.left = elRect.left;
|
|
209
|
+
this.scale = elRect.width ? width / elRect.width : (elRect.height ? height / elRect.height : 1);
|
|
207
210
|
}
|
|
208
211
|
this.width = width;
|
|
209
212
|
this.height = height;
|
|
@@ -433,6 +436,8 @@ class ScrollObserver {
|
|
|
433
436
|
/** @type {Boolean} */
|
|
434
437
|
this.reverted = false;
|
|
435
438
|
/** @type {Boolean} */
|
|
439
|
+
this.ready = false;
|
|
440
|
+
/** @type {Boolean} */
|
|
436
441
|
this.completed = false;
|
|
437
442
|
/** @type {Boolean} */
|
|
438
443
|
this.began = false;
|
|
@@ -442,8 +447,6 @@ class ScrollObserver {
|
|
|
442
447
|
this.forceEnter = false;
|
|
443
448
|
/** @type {Boolean} */
|
|
444
449
|
this.hasEntered = false;
|
|
445
|
-
// /** @type {Array.<Number>} */
|
|
446
|
-
// this.offsets = [];
|
|
447
450
|
/** @type {Number} */
|
|
448
451
|
this.offset = 0;
|
|
449
452
|
/** @type {Number} */
|
|
@@ -491,6 +494,8 @@ class ScrollObserver {
|
|
|
491
494
|
// Make sure to pause the linked object in case it's added later
|
|
492
495
|
linked.pause();
|
|
493
496
|
this.linked = linked;
|
|
497
|
+
// Forces WAAPI Animation to persist; otherwise, they will stop syncing on finish.
|
|
498
|
+
if (!isUnd(/** @type {WAAPIAnimation} */(linked))) /** @type {WAAPIAnimation} */(linked).persist = true;
|
|
494
499
|
// Try to use a target of the linked object if no target parameters specified
|
|
495
500
|
if (!this._params.target) {
|
|
496
501
|
/** @type {HTMLElement} */
|
|
@@ -530,6 +535,8 @@ class ScrollObserver {
|
|
|
530
535
|
}
|
|
531
536
|
|
|
532
537
|
refresh() {
|
|
538
|
+
// This flag is used to prevent running handleScroll() outside of this.refresh() with values not yet calculated
|
|
539
|
+
this.ready = true;
|
|
533
540
|
this.reverted = false;
|
|
534
541
|
const params = this._params;
|
|
535
542
|
this.repeat = setValue(parseScrollObserverFunctionParameter(params.repeat, this), true);
|
|
@@ -725,8 +732,9 @@ class ScrollObserver {
|
|
|
725
732
|
}
|
|
726
733
|
}
|
|
727
734
|
const rect = $target.getBoundingClientRect();
|
|
728
|
-
const
|
|
729
|
-
const
|
|
735
|
+
const scale = container.scale;
|
|
736
|
+
const offset = (isHori ? rect.left + container.scrollX - container.left : rect.top + container.scrollY - container.top) * scale;
|
|
737
|
+
const targetSize = (isHori ? rect.width : rect.height) * scale;
|
|
730
738
|
const containerSize = isHori ? container.width : container.height;
|
|
731
739
|
const scrollSize = isHori ? container.scrollWidth : container.scrollHeight;
|
|
732
740
|
const maxScroll = scrollSize - containerSize;
|
|
@@ -775,8 +783,6 @@ class ScrollObserver {
|
|
|
775
783
|
const offsetStart = parsedEnterTarget + offset - parsedEnterContainer;
|
|
776
784
|
const offsetEnd = parsedLeaveTarget + offset - parsedLeaveContainer;
|
|
777
785
|
const scrollDelta = offsetEnd - offsetStart;
|
|
778
|
-
// this.offsets[0] = offsetX;
|
|
779
|
-
// this.offsets[1] = offsetY;
|
|
780
786
|
this.offset = offset;
|
|
781
787
|
this.offsetStart = offsetStart;
|
|
782
788
|
this.offsetEnd = offsetEnd;
|
|
@@ -795,6 +801,7 @@ class ScrollObserver {
|
|
|
795
801
|
}
|
|
796
802
|
|
|
797
803
|
handleScroll() {
|
|
804
|
+
if (!this.ready) return;
|
|
798
805
|
const linked = this.linked;
|
|
799
806
|
const sync = this.sync;
|
|
800
807
|
const syncEase = this.syncEase;
|
|
@@ -918,6 +925,7 @@ class ScrollObserver {
|
|
|
918
925
|
this.removeDebug();
|
|
919
926
|
}
|
|
920
927
|
this.reverted = true;
|
|
928
|
+
this.ready = false;
|
|
921
929
|
return this;
|
|
922
930
|
}
|
|
923
931
|
|
package/dist/modules/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - CJS
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
@@ -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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - ESM
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
@@ -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';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - svg - CJS
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
@@ -24,8 +24,18 @@ var helpers = require('./helpers.cjs');
|
|
|
24
24
|
* @return {FunctionValue}
|
|
25
25
|
*/
|
|
26
26
|
const morphTo = (path2, precision = .33) => ($path1) => {
|
|
27
|
+
const tagName1 = ($path1.tagName || '').toLowerCase();
|
|
28
|
+
if (!tagName1.match(/^(path|polygon|polyline)$/)) {
|
|
29
|
+
throw new Error(`Can't morph a <${$path1.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);
|
|
30
|
+
}
|
|
27
31
|
const $path2 = /** @type {SVGGeometryElement} */(helpers.getPath(path2));
|
|
28
|
-
if (!$path2)
|
|
32
|
+
if (!$path2) {
|
|
33
|
+
throw new Error("Can't morph to an invalid target. 'path2' must resolve to an existing <path>, <polygon> or <polyline> SVG element.");
|
|
34
|
+
}
|
|
35
|
+
const tagName2 = ($path2.tagName || '').toLowerCase();
|
|
36
|
+
if (!tagName2.match(/^(path|polygon|polyline)$/)) {
|
|
37
|
+
throw new Error(`Can't morph a <${$path2.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);
|
|
38
|
+
}
|
|
29
39
|
const isPath = $path1.tagName === 'path';
|
|
30
40
|
const separator = isPath ? ' ' : ',';
|
|
31
41
|
const previousPoints = $path1[consts.morphPointsSymbol];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - svg - ESM
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
@@ -22,8 +22,18 @@ import { getPath } from './helpers.js';
|
|
|
22
22
|
* @return {FunctionValue}
|
|
23
23
|
*/
|
|
24
24
|
const morphTo = (path2, precision = .33) => ($path1) => {
|
|
25
|
+
const tagName1 = ($path1.tagName || '').toLowerCase();
|
|
26
|
+
if (!tagName1.match(/^(path|polygon|polyline)$/)) {
|
|
27
|
+
throw new Error(`Can't morph a <${$path1.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);
|
|
28
|
+
}
|
|
25
29
|
const $path2 = /** @type {SVGGeometryElement} */(getPath(path2));
|
|
26
|
-
if (!$path2)
|
|
30
|
+
if (!$path2) {
|
|
31
|
+
throw new Error("Can't morph to an invalid target. 'path2' must resolve to an existing <path>, <polygon> or <polyline> SVG element.");
|
|
32
|
+
}
|
|
33
|
+
const tagName2 = ($path2.tagName || '').toLowerCase();
|
|
34
|
+
if (!tagName2.match(/^(path|polygon|polyline)$/)) {
|
|
35
|
+
throw new Error(`Can't morph a <${$path2.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);
|
|
36
|
+
}
|
|
27
37
|
const isPath = $path1.tagName === 'path';
|
|
28
38
|
const separator = isPath ? ' ' : ',';
|
|
29
39
|
const previousPoints = $path1[morphPointsSymbol];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - svg - CJS
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
@@ -24,20 +24,24 @@ var helpers = require('./helpers.cjs');
|
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* @param {SVGGeometryElement} $path
|
|
27
|
+
* @param {Number} totalLength
|
|
27
28
|
* @param {Number} progress
|
|
28
29
|
* @param {Number}lookup
|
|
29
30
|
* @return {DOMPoint}
|
|
30
31
|
*/
|
|
31
|
-
const getPathPoint = ($path, progress, lookup = 0) => {
|
|
32
|
-
|
|
32
|
+
const getPathPoint = ($path, totalLength, progress, lookup = 0) => {
|
|
33
|
+
const point = progress + lookup;
|
|
34
|
+
const pointOnPath = (point % totalLength + totalLength) % totalLength;
|
|
35
|
+
return $path.getPointAtLength(pointOnPath);
|
|
33
36
|
};
|
|
34
37
|
|
|
35
38
|
/**
|
|
36
39
|
* @param {SVGGeometryElement} $path
|
|
37
40
|
* @param {String} pathProperty
|
|
41
|
+
* @param {Number} [offset=0]
|
|
38
42
|
* @return {FunctionValue}
|
|
39
43
|
*/
|
|
40
|
-
const getPathProgess = ($path, pathProperty) => {
|
|
44
|
+
const getPathProgess = ($path, pathProperty, offset = 0) => {
|
|
41
45
|
return $el => {
|
|
42
46
|
const totalLength = +($path.getTotalLength());
|
|
43
47
|
const inSvg = $el[consts.isSvgSymbol];
|
|
@@ -48,12 +52,14 @@ const getPathProgess = ($path, pathProperty) => {
|
|
|
48
52
|
to: totalLength,
|
|
49
53
|
/** @type {TweenModifier} */
|
|
50
54
|
modifier: progress => {
|
|
55
|
+
const offsetLength = offset * totalLength;
|
|
56
|
+
const newProgress = progress + offsetLength;
|
|
51
57
|
if (pathProperty === 'a') {
|
|
52
|
-
const p0 = getPathPoint($path,
|
|
53
|
-
const p1 = getPathPoint($path,
|
|
58
|
+
const p0 = getPathPoint($path, totalLength, newProgress, -1);
|
|
59
|
+
const p1 = getPathPoint($path, totalLength, newProgress, 1);
|
|
54
60
|
return helpers$1.atan2(p1.y - p0.y, p1.x - p0.x) * 180 / helpers$1.PI;
|
|
55
61
|
} else {
|
|
56
|
-
const p = getPathPoint($path,
|
|
62
|
+
const p = getPathPoint($path, totalLength, newProgress, 0);
|
|
57
63
|
return pathProperty === 'x' ?
|
|
58
64
|
inSvg || !ctm ? p.x : p.x * ctm.a + p.y * ctm.c + ctm.e :
|
|
59
65
|
inSvg || !ctm ? p.y : p.x * ctm.b + p.y * ctm.d + ctm.f
|
|
@@ -65,14 +71,15 @@ const getPathProgess = ($path, pathProperty) => {
|
|
|
65
71
|
|
|
66
72
|
/**
|
|
67
73
|
* @param {TargetsParam} path
|
|
74
|
+
* @param {Number} [offset=0]
|
|
68
75
|
*/
|
|
69
|
-
const createMotionPath = path => {
|
|
76
|
+
const createMotionPath = (path, offset = 0) => {
|
|
70
77
|
const $path = helpers.getPath(path);
|
|
71
78
|
if (!$path) return;
|
|
72
79
|
return {
|
|
73
|
-
translateX: getPathProgess($path, 'x'),
|
|
74
|
-
translateY: getPathProgess($path, 'y'),
|
|
75
|
-
rotate: getPathProgess($path, 'a'),
|
|
80
|
+
translateX: getPathProgess($path, 'x', offset),
|
|
81
|
+
translateY: getPathProgess($path, 'y', offset),
|
|
82
|
+
rotate: getPathProgess($path, 'a', offset),
|
|
76
83
|
}
|
|
77
84
|
};
|
|
78
85
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - svg - ESM
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
@@ -22,20 +22,24 @@ import { getPath } from './helpers.js';
|
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* @param {SVGGeometryElement} $path
|
|
25
|
+
* @param {Number} totalLength
|
|
25
26
|
* @param {Number} progress
|
|
26
27
|
* @param {Number}lookup
|
|
27
28
|
* @return {DOMPoint}
|
|
28
29
|
*/
|
|
29
|
-
const getPathPoint = ($path, progress, lookup = 0) => {
|
|
30
|
-
|
|
30
|
+
const getPathPoint = ($path, totalLength, progress, lookup = 0) => {
|
|
31
|
+
const point = progress + lookup;
|
|
32
|
+
const pointOnPath = (point % totalLength + totalLength) % totalLength;
|
|
33
|
+
return $path.getPointAtLength(pointOnPath);
|
|
31
34
|
};
|
|
32
35
|
|
|
33
36
|
/**
|
|
34
37
|
* @param {SVGGeometryElement} $path
|
|
35
38
|
* @param {String} pathProperty
|
|
39
|
+
* @param {Number} [offset=0]
|
|
36
40
|
* @return {FunctionValue}
|
|
37
41
|
*/
|
|
38
|
-
const getPathProgess = ($path, pathProperty) => {
|
|
42
|
+
const getPathProgess = ($path, pathProperty, offset = 0) => {
|
|
39
43
|
return $el => {
|
|
40
44
|
const totalLength = +($path.getTotalLength());
|
|
41
45
|
const inSvg = $el[isSvgSymbol];
|
|
@@ -46,12 +50,14 @@ const getPathProgess = ($path, pathProperty) => {
|
|
|
46
50
|
to: totalLength,
|
|
47
51
|
/** @type {TweenModifier} */
|
|
48
52
|
modifier: progress => {
|
|
53
|
+
const offsetLength = offset * totalLength;
|
|
54
|
+
const newProgress = progress + offsetLength;
|
|
49
55
|
if (pathProperty === 'a') {
|
|
50
|
-
const p0 = getPathPoint($path,
|
|
51
|
-
const p1 = getPathPoint($path,
|
|
56
|
+
const p0 = getPathPoint($path, totalLength, newProgress, -1);
|
|
57
|
+
const p1 = getPathPoint($path, totalLength, newProgress, 1);
|
|
52
58
|
return atan2(p1.y - p0.y, p1.x - p0.x) * 180 / PI;
|
|
53
59
|
} else {
|
|
54
|
-
const p = getPathPoint($path,
|
|
60
|
+
const p = getPathPoint($path, totalLength, newProgress, 0);
|
|
55
61
|
return pathProperty === 'x' ?
|
|
56
62
|
inSvg || !ctm ? p.x : p.x * ctm.a + p.y * ctm.c + ctm.e :
|
|
57
63
|
inSvg || !ctm ? p.y : p.x * ctm.b + p.y * ctm.d + ctm.f
|
|
@@ -63,14 +69,15 @@ const getPathProgess = ($path, pathProperty) => {
|
|
|
63
69
|
|
|
64
70
|
/**
|
|
65
71
|
* @param {TargetsParam} path
|
|
72
|
+
* @param {Number} [offset=0]
|
|
66
73
|
*/
|
|
67
|
-
const createMotionPath = path => {
|
|
74
|
+
const createMotionPath = (path, offset = 0) => {
|
|
68
75
|
const $path = getPath(path);
|
|
69
76
|
if (!$path) return;
|
|
70
77
|
return {
|
|
71
|
-
translateX: getPathProgess($path, 'x'),
|
|
72
|
-
translateY: getPathProgess($path, 'y'),
|
|
73
|
-
rotate: getPathProgess($path, 'a'),
|
|
78
|
+
translateX: getPathProgess($path, 'x', offset),
|
|
79
|
+
translateY: getPathProgess($path, 'y', offset),
|
|
80
|
+
rotate: getPathProgess($path, 'a', offset),
|
|
74
81
|
}
|
|
75
82
|
};
|
|
76
83
|
|