animejs 4.1.0 → 4.1.2
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/lib/anime.cjs +2 -2
- package/lib/anime.esm.js +53 -37
- package/lib/anime.esm.min.js +2 -2
- package/lib/anime.iife.js +2 -2
- package/lib/anime.iife.min.js +2 -2
- package/lib/anime.min.cjs +2 -2
- package/lib/anime.umd.js +2 -2
- package/lib/anime.umd.min.js +2 -2
- package/package.json +1 -1
- package/types/index.d.ts +0 -1
- package/types/index.js +52 -38
package/types/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* anime.js - ESM
|
|
3
|
-
* @version v4.1.
|
|
3
|
+
* @version v4.1.2
|
|
4
4
|
* @author Julian Garnier
|
|
5
5
|
* @license MIT
|
|
6
6
|
* @copyright (c) 2025 Julian Garnier
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
// Environments
|
|
11
11
|
// TODO: Do we need to check if we're running inside a worker ?
|
|
12
12
|
const isBrowser = typeof window !== 'undefined';
|
|
13
|
-
/** @type {
|
|
14
|
-
const win = isBrowser ? window : null;
|
|
15
|
-
/** @type {Document} */
|
|
13
|
+
/** @type {Window & {AnimeJS: Array}|null} */
|
|
14
|
+
const win = isBrowser ? /** @type {Window & {AnimeJS: Array}} */ ( /** @type {unknown} */(window)) : null;
|
|
15
|
+
/** @type {Document|null} */
|
|
16
16
|
const doc = isBrowser ? document : null;
|
|
17
17
|
// Enums
|
|
18
18
|
/** @enum {Number} */
|
|
@@ -142,7 +142,7 @@ const globals = {
|
|
|
142
142
|
/** @type {Number} */
|
|
143
143
|
tickThreshold: 200,
|
|
144
144
|
};
|
|
145
|
-
const globalVersions = { version: '4.1.
|
|
145
|
+
const globalVersions = { version: '4.1.2', engine: null };
|
|
146
146
|
if (isBrowser) {
|
|
147
147
|
if (!win.AnimeJS)
|
|
148
148
|
win.AnimeJS = [];
|
|
@@ -779,7 +779,7 @@ const tick = (tickable, time, muteCallbacks, internalRender, tickMode) => {
|
|
|
779
779
|
if (!muteCallbacks && tlChildrenHasRendered)
|
|
780
780
|
tl.onRender(/** @type {CallbackArgument} */ (tl));
|
|
781
781
|
// Triggers the timeline onComplete() once all chindren all completed and the current time has reached the end
|
|
782
|
-
if (tlChildrenHaveCompleted && tl._currentTime >= tl.duration) {
|
|
782
|
+
if ((tlChildrenHaveCompleted || tlIsRunningBackwards) && tl._currentTime >= tl.duration) {
|
|
783
783
|
// Make sure the paused flag is false in case it has been skipped in the render function
|
|
784
784
|
tl.paused = true;
|
|
785
785
|
if (!tl.completed) {
|
|
@@ -3152,7 +3152,8 @@ class JSAnimation extends Timer {
|
|
|
3152
3152
|
tween._fromNumber = decomposedOriginalValue.n;
|
|
3153
3153
|
tween._toNumbers = cloneArray(toTargetObject.d);
|
|
3154
3154
|
tween._strings = cloneArray(toTargetObject.s);
|
|
3155
|
-
|
|
3155
|
+
// Make sure to apply relative operators https://github.com/juliangarnier/anime/issues/1025
|
|
3156
|
+
tween._toNumber = toTargetObject.o ? getRelativeValue(decomposedOriginalValue.n, toTargetObject.n, toTargetObject.o) : toTargetObject.n;
|
|
3156
3157
|
}
|
|
3157
3158
|
});
|
|
3158
3159
|
return this;
|
|
@@ -4923,7 +4924,8 @@ class Draggable {
|
|
|
4923
4924
|
this.deltaY = dy;
|
|
4924
4925
|
this.coords[2] = x;
|
|
4925
4926
|
this.coords[3] = y;
|
|
4926
|
-
if
|
|
4927
|
+
// Check if dx or dy are not 0 to check if the draggable has actually moved https://github.com/juliangarnier/anime/issues/1032
|
|
4928
|
+
if (hasUpdated && (dx || dy)) {
|
|
4927
4929
|
this.onUpdate(this);
|
|
4928
4930
|
}
|
|
4929
4931
|
if (!hasReleased) {
|
|
@@ -5669,7 +5671,6 @@ class Draggable {
|
|
|
5669
5671
|
this.targetStyles.revert();
|
|
5670
5672
|
this.targetStyles = null;
|
|
5671
5673
|
}
|
|
5672
|
-
this.stop();
|
|
5673
5674
|
this.$target.classList.add('is-disabled');
|
|
5674
5675
|
this.$trigger.removeEventListener('touchstart', this);
|
|
5675
5676
|
this.$trigger.removeEventListener('mousedown', this);
|
|
@@ -5691,6 +5692,7 @@ class Draggable {
|
|
|
5691
5692
|
this.overshootYTicker.revert();
|
|
5692
5693
|
this.resizeTicker.revert();
|
|
5693
5694
|
this.animate.revert();
|
|
5695
|
+
this.resizeObserver.disconnect();
|
|
5694
5696
|
return this;
|
|
5695
5697
|
}
|
|
5696
5698
|
/**
|
|
@@ -5966,7 +5968,7 @@ const createScope = params => new Scope(params);
|
|
|
5966
5968
|
* @return {Number}
|
|
5967
5969
|
*/
|
|
5968
5970
|
const getMaxViewHeight = () => {
|
|
5969
|
-
const $el =
|
|
5971
|
+
const $el = doc.createElement('div');
|
|
5970
5972
|
doc.body.appendChild($el);
|
|
5971
5973
|
$el.style.height = '100lvh';
|
|
5972
5974
|
const height = $el.offsetHeight;
|
|
@@ -6157,7 +6159,7 @@ class ScrollContainer {
|
|
|
6157
6159
|
this.dataTimer.cancel();
|
|
6158
6160
|
this.resizeTicker.cancel();
|
|
6159
6161
|
this.wakeTicker.cancel();
|
|
6160
|
-
this.resizeObserver.
|
|
6162
|
+
this.resizeObserver.disconnect();
|
|
6161
6163
|
(this.useWin ? win : this.element).removeEventListener('scroll', this);
|
|
6162
6164
|
scrollContainers.delete(this.element);
|
|
6163
6165
|
}
|
|
@@ -6381,8 +6383,8 @@ class ScrollObserver {
|
|
|
6381
6383
|
this.forceEnter = false;
|
|
6382
6384
|
/** @type {Boolean} */
|
|
6383
6385
|
this.hasEntered = false;
|
|
6384
|
-
/** @type {Array.<Number>} */
|
|
6385
|
-
this.offsets = [];
|
|
6386
|
+
// /** @type {Array.<Number>} */
|
|
6387
|
+
// this.offsets = [];
|
|
6386
6388
|
/** @type {Number} */
|
|
6387
6389
|
this.offset = 0;
|
|
6388
6390
|
/** @type {Number} */
|
|
@@ -6618,35 +6620,46 @@ class ScrollObserver {
|
|
|
6618
6620
|
const linked = this.linked;
|
|
6619
6621
|
let linkedTime;
|
|
6620
6622
|
let $el = $target;
|
|
6621
|
-
let offsetX = 0;
|
|
6622
|
-
let offsetY = 0;
|
|
6623
|
+
// let offsetX = 0;
|
|
6624
|
+
// let offsetY = 0;
|
|
6625
|
+
// let $offsetParent = $el;
|
|
6623
6626
|
/** @type {Element} */
|
|
6624
|
-
let $offsetParent = $el;
|
|
6625
6627
|
if (linked) {
|
|
6626
6628
|
linkedTime = linked.currentTime;
|
|
6627
6629
|
linked.seek(0, true);
|
|
6628
6630
|
}
|
|
6629
|
-
|
|
6631
|
+
/* Old implementation to get offset and targetSize before fixing https://github.com/juliangarnier/anime/issues/1021
|
|
6632
|
+
// const isContainerStatic = getTargetValue(container.element, 'position') === 'static' ? setTargetValues(container.element, { position: 'relative '}) : false;
|
|
6633
|
+
// while ($el && $el !== container.element && $el !== doc.body) {
|
|
6634
|
+
// const isSticky = getTargetValue($el, 'position') === 'sticky' ?
|
|
6635
|
+
// setTargetValues($el, { position: 'static' }) :
|
|
6636
|
+
// false;
|
|
6637
|
+
// if ($el === $offsetParent) {
|
|
6638
|
+
// offsetX += $el.offsetLeft || 0;
|
|
6639
|
+
// offsetY += $el.offsetTop || 0;
|
|
6640
|
+
// $offsetParent = $el.offsetParent;
|
|
6641
|
+
// }
|
|
6642
|
+
// $el = /** @type {HTMLElement} */ ($el.parentElement);
|
|
6643
|
+
// if (isSticky) {
|
|
6644
|
+
// if (!stickys) stickys = [];
|
|
6645
|
+
// stickys.push(isSticky);
|
|
6646
|
+
// }
|
|
6647
|
+
// }
|
|
6648
|
+
// if (isContainerStatic) isContainerStatic.revert();
|
|
6649
|
+
// const offset = isHori ? offsetX : offsetY;
|
|
6650
|
+
// const targetSize = isHori ? $target.offsetWidth : $target.offsetHeight;
|
|
6630
6651
|
while ($el && $el !== container.element && $el !== doc.body) {
|
|
6631
|
-
const isSticky = getTargetValue($el, 'position') === 'sticky' ?
|
|
6632
|
-
|
|
6633
|
-
false;
|
|
6634
|
-
if ($el === $offsetParent) {
|
|
6635
|
-
offsetX += $el.offsetLeft || 0;
|
|
6636
|
-
offsetY += $el.offsetTop || 0;
|
|
6637
|
-
$offsetParent = $el.offsetParent;
|
|
6638
|
-
}
|
|
6639
|
-
$el = /** @type {HTMLElement} */ ($el.parentElement);
|
|
6652
|
+
const isSticky = getTargetValue($el, 'position') === 'sticky' ? setTargetValues($el, { position: 'static' }) : false;
|
|
6653
|
+
$el = $el.parentElement;
|
|
6640
6654
|
if (isSticky) {
|
|
6641
6655
|
if (!stickys)
|
|
6642
6656
|
stickys = [];
|
|
6643
6657
|
stickys.push(isSticky);
|
|
6644
6658
|
}
|
|
6645
6659
|
}
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
const
|
|
6649
|
-
const targetSize = isHori ? $target.offsetWidth : $target.offsetHeight;
|
|
6660
|
+
const rect = $target.getBoundingClientRect();
|
|
6661
|
+
const offset = isHori ? rect.left + container.scrollX - container.left : rect.top + container.scrollY - container.top;
|
|
6662
|
+
const targetSize = isHori ? rect.width : rect.height;
|
|
6650
6663
|
const containerSize = isHori ? container.width : container.height;
|
|
6651
6664
|
const scrollSize = isHori ? container.scrollWidth : container.scrollHeight;
|
|
6652
6665
|
const maxScroll = scrollSize - containerSize;
|
|
@@ -6699,8 +6712,8 @@ class ScrollObserver {
|
|
|
6699
6712
|
const offsetStart = parsedEnterTarget + offset - parsedEnterContainer;
|
|
6700
6713
|
const offsetEnd = parsedLeaveTarget + offset - parsedLeaveContainer;
|
|
6701
6714
|
const scrollDelta = offsetEnd - offsetStart;
|
|
6702
|
-
this.offsets[0] = offsetX;
|
|
6703
|
-
this.offsets[1] = offsetY;
|
|
6715
|
+
// this.offsets[0] = offsetX;
|
|
6716
|
+
// this.offsets[1] = offsetY;
|
|
6704
6717
|
this.offset = offset;
|
|
6705
6718
|
this.offsetStart = offsetStart;
|
|
6706
6719
|
this.offsetEnd = offsetEnd;
|
|
@@ -7209,6 +7222,10 @@ class TextSplitter {
|
|
|
7209
7222
|
const fontsReady = doc.fonts.status !== 'loading';
|
|
7210
7223
|
const canSplitLines = lineTemplate && fontsReady;
|
|
7211
7224
|
this.ready = !lineTemplate || fontsReady;
|
|
7225
|
+
if (canSplitLines || clearCache) {
|
|
7226
|
+
// No need to revert effects animations here since it's already taken care by the refreshable
|
|
7227
|
+
this.effectsCleanups.forEach(cleanup => isFnc(cleanup) && cleanup(this));
|
|
7228
|
+
}
|
|
7212
7229
|
if (!isCached) {
|
|
7213
7230
|
if (clearCache) {
|
|
7214
7231
|
$el.innerHTML = this.html;
|
|
@@ -7217,10 +7234,7 @@ class TextSplitter {
|
|
|
7217
7234
|
this.splitNode($el);
|
|
7218
7235
|
this.cache = $el.innerHTML;
|
|
7219
7236
|
}
|
|
7220
|
-
// Always reset the html when splitting by lines
|
|
7221
7237
|
if (canSplitLines) {
|
|
7222
|
-
// No need to revert effects animations here since it's already taken care by the refreshable
|
|
7223
|
-
this.effectsCleanups.forEach(cleanup => isFnc(cleanup) && cleanup(this));
|
|
7224
7238
|
if (isCached)
|
|
7225
7239
|
$el.innerHTML = this.cache;
|
|
7226
7240
|
this.lines.length = 0;
|
|
@@ -7281,9 +7295,6 @@ class TextSplitter {
|
|
|
7281
7295
|
}
|
|
7282
7296
|
words.length = 0;
|
|
7283
7297
|
}
|
|
7284
|
-
if (canSplitLines || clearCache) {
|
|
7285
|
-
this.effects.forEach((effect, i) => this.effectsCleanups[i] = effect(this));
|
|
7286
|
-
}
|
|
7287
7298
|
if (this.accessible && (canSplitLines || !isCached)) {
|
|
7288
7299
|
const $accessible = doc.createElement('span');
|
|
7289
7300
|
// Make the accessible element visually-hidden (https://www.scottohara.me/blog/2017/04/14/inclusively-hidden.html)
|
|
@@ -7296,6 +7307,9 @@ class TextSplitter {
|
|
|
7296
7307
|
this.chars.forEach(setAriaHidden);
|
|
7297
7308
|
}
|
|
7298
7309
|
this.width = /** @type {HTMLElement} */ ($el).offsetWidth;
|
|
7310
|
+
if (canSplitLines || clearCache) {
|
|
7311
|
+
this.effects.forEach((effect, i) => this.effectsCleanups[i] = effect(this));
|
|
7312
|
+
}
|
|
7299
7313
|
return this;
|
|
7300
7314
|
}
|
|
7301
7315
|
refresh() {
|