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/lib/anime.esm.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
|
|
@@ -470,10 +470,10 @@
|
|
|
470
470
|
// TODO: Do we need to check if we're running inside a worker ?
|
|
471
471
|
const isBrowser = typeof window !== 'undefined';
|
|
472
472
|
|
|
473
|
-
/** @type {
|
|
474
|
-
const win = isBrowser ? window : null;
|
|
473
|
+
/** @type {Window & {AnimeJS: Array}|null} */
|
|
474
|
+
const win = isBrowser ? /** @type {Window & {AnimeJS: Array}} */(/** @type {unknown} */(window)) : null;
|
|
475
475
|
|
|
476
|
-
/** @type {Document} */
|
|
476
|
+
/** @type {Document|null} */
|
|
477
477
|
const doc = isBrowser ? document : null;
|
|
478
478
|
|
|
479
479
|
// Enums
|
|
@@ -625,7 +625,7 @@ const globals = {
|
|
|
625
625
|
tickThreshold: 200,
|
|
626
626
|
};
|
|
627
627
|
|
|
628
|
-
const globalVersions = { version: '4.1.
|
|
628
|
+
const globalVersions = { version: '4.1.2', engine: null };
|
|
629
629
|
|
|
630
630
|
if (isBrowser) {
|
|
631
631
|
if (!win.AnimeJS) win.AnimeJS = [];
|
|
@@ -1316,7 +1316,7 @@ const tick = (tickable, time, muteCallbacks, internalRender, tickMode) => {
|
|
|
1316
1316
|
if (!muteCallbacks && tlChildrenHasRendered) tl.onRender(/** @type {CallbackArgument} */(tl));
|
|
1317
1317
|
|
|
1318
1318
|
// Triggers the timeline onComplete() once all chindren all completed and the current time has reached the end
|
|
1319
|
-
if (tlChildrenHaveCompleted && tl._currentTime >= tl.duration) {
|
|
1319
|
+
if ((tlChildrenHaveCompleted || tlIsRunningBackwards) && tl._currentTime >= tl.duration) {
|
|
1320
1320
|
// Make sure the paused flag is false in case it has been skipped in the render function
|
|
1321
1321
|
tl.paused = true;
|
|
1322
1322
|
if (!tl.completed) {
|
|
@@ -3909,7 +3909,8 @@ class JSAnimation extends Timer {
|
|
|
3909
3909
|
tween._fromNumber = decomposedOriginalValue.n;
|
|
3910
3910
|
tween._toNumbers = cloneArray(toTargetObject.d);
|
|
3911
3911
|
tween._strings = cloneArray(toTargetObject.s);
|
|
3912
|
-
|
|
3912
|
+
// Make sure to apply relative operators https://github.com/juliangarnier/anime/issues/1025
|
|
3913
|
+
tween._toNumber = toTargetObject.o ? getRelativeValue(decomposedOriginalValue.n, toTargetObject.n, toTargetObject.o) : toTargetObject.n;
|
|
3913
3914
|
}
|
|
3914
3915
|
});
|
|
3915
3916
|
return this;
|
|
@@ -5741,7 +5742,8 @@ class Draggable {
|
|
|
5741
5742
|
this.deltaY = dy;
|
|
5742
5743
|
this.coords[2] = x;
|
|
5743
5744
|
this.coords[3] = y;
|
|
5744
|
-
if
|
|
5745
|
+
// Check if dx or dy are not 0 to check if the draggable has actually moved https://github.com/juliangarnier/anime/issues/1032
|
|
5746
|
+
if (hasUpdated && (dx || dy)) {
|
|
5745
5747
|
this.onUpdate(this);
|
|
5746
5748
|
}
|
|
5747
5749
|
if (!hasReleased) {
|
|
@@ -6526,7 +6528,6 @@ class Draggable {
|
|
|
6526
6528
|
this.targetStyles.revert();
|
|
6527
6529
|
this.targetStyles = null;
|
|
6528
6530
|
}
|
|
6529
|
-
this.stop();
|
|
6530
6531
|
this.$target.classList.add('is-disabled');
|
|
6531
6532
|
this.$trigger.removeEventListener('touchstart', this);
|
|
6532
6533
|
this.$trigger.removeEventListener('mousedown', this);
|
|
@@ -6549,6 +6550,7 @@ class Draggable {
|
|
|
6549
6550
|
this.overshootYTicker.revert();
|
|
6550
6551
|
this.resizeTicker.revert();
|
|
6551
6552
|
this.animate.revert();
|
|
6553
|
+
this.resizeObserver.disconnect();
|
|
6552
6554
|
return this;
|
|
6553
6555
|
}
|
|
6554
6556
|
|
|
@@ -6826,7 +6828,7 @@ const createScope = params => new Scope(params);
|
|
|
6826
6828
|
* @return {Number}
|
|
6827
6829
|
*/
|
|
6828
6830
|
const getMaxViewHeight = () => {
|
|
6829
|
-
const $el =
|
|
6831
|
+
const $el = doc.createElement('div');
|
|
6830
6832
|
doc.body.appendChild($el);
|
|
6831
6833
|
$el.style.height = '100lvh';
|
|
6832
6834
|
const height = $el.offsetHeight;
|
|
@@ -7025,7 +7027,7 @@ class ScrollContainer {
|
|
|
7025
7027
|
this.dataTimer.cancel();
|
|
7026
7028
|
this.resizeTicker.cancel();
|
|
7027
7029
|
this.wakeTicker.cancel();
|
|
7028
|
-
this.resizeObserver.
|
|
7030
|
+
this.resizeObserver.disconnect();
|
|
7029
7031
|
(this.useWin ? win : this.element).removeEventListener('scroll', this);
|
|
7030
7032
|
scrollContainers.delete(this.element);
|
|
7031
7033
|
}
|
|
@@ -7254,8 +7256,8 @@ class ScrollObserver {
|
|
|
7254
7256
|
this.forceEnter = false;
|
|
7255
7257
|
/** @type {Boolean} */
|
|
7256
7258
|
this.hasEntered = false;
|
|
7257
|
-
/** @type {Array.<Number>} */
|
|
7258
|
-
this.offsets = [];
|
|
7259
|
+
// /** @type {Array.<Number>} */
|
|
7260
|
+
// this.offsets = [];
|
|
7259
7261
|
/** @type {Number} */
|
|
7260
7262
|
this.offset = 0;
|
|
7261
7263
|
/** @type {Number} */
|
|
@@ -7499,33 +7501,46 @@ class ScrollObserver {
|
|
|
7499
7501
|
const linked = this.linked;
|
|
7500
7502
|
let linkedTime;
|
|
7501
7503
|
let $el = $target;
|
|
7502
|
-
let offsetX = 0;
|
|
7503
|
-
let offsetY = 0;
|
|
7504
|
+
// let offsetX = 0;
|
|
7505
|
+
// let offsetY = 0;
|
|
7506
|
+
// let $offsetParent = $el;
|
|
7504
7507
|
/** @type {Element} */
|
|
7505
|
-
let $offsetParent = $el;
|
|
7506
7508
|
if (linked) {
|
|
7507
7509
|
linkedTime = linked.currentTime;
|
|
7508
7510
|
linked.seek(0, true);
|
|
7509
7511
|
}
|
|
7510
|
-
|
|
7512
|
+
/* Old implementation to get offset and targetSize before fixing https://github.com/juliangarnier/anime/issues/1021
|
|
7513
|
+
// const isContainerStatic = getTargetValue(container.element, 'position') === 'static' ? setTargetValues(container.element, { position: 'relative '}) : false;
|
|
7514
|
+
// while ($el && $el !== container.element && $el !== doc.body) {
|
|
7515
|
+
// const isSticky = getTargetValue($el, 'position') === 'sticky' ?
|
|
7516
|
+
// setTargetValues($el, { position: 'static' }) :
|
|
7517
|
+
// false;
|
|
7518
|
+
// if ($el === $offsetParent) {
|
|
7519
|
+
// offsetX += $el.offsetLeft || 0;
|
|
7520
|
+
// offsetY += $el.offsetTop || 0;
|
|
7521
|
+
// $offsetParent = $el.offsetParent;
|
|
7522
|
+
// }
|
|
7523
|
+
// $el = /** @type {HTMLElement} */($el.parentElement);
|
|
7524
|
+
// if (isSticky) {
|
|
7525
|
+
// if (!stickys) stickys = [];
|
|
7526
|
+
// stickys.push(isSticky);
|
|
7527
|
+
// }
|
|
7528
|
+
// }
|
|
7529
|
+
// if (isContainerStatic) isContainerStatic.revert();
|
|
7530
|
+
// const offset = isHori ? offsetX : offsetY;
|
|
7531
|
+
// const targetSize = isHori ? $target.offsetWidth : $target.offsetHeight;
|
|
7532
|
+
|
|
7511
7533
|
while ($el && $el !== container.element && $el !== doc.body) {
|
|
7512
|
-
const isSticky = getTargetValue($el, 'position') === 'sticky' ?
|
|
7513
|
-
|
|
7514
|
-
false;
|
|
7515
|
-
if ($el === $offsetParent) {
|
|
7516
|
-
offsetX += $el.offsetLeft || 0;
|
|
7517
|
-
offsetY += $el.offsetTop || 0;
|
|
7518
|
-
$offsetParent = $el.offsetParent;
|
|
7519
|
-
}
|
|
7520
|
-
$el = /** @type {HTMLElement} */($el.parentElement);
|
|
7534
|
+
const isSticky = getTargetValue($el, 'position') === 'sticky' ? setTargetValues($el, { position: 'static' }) : false;
|
|
7535
|
+
$el = $el.parentElement;
|
|
7521
7536
|
if (isSticky) {
|
|
7522
7537
|
if (!stickys) stickys = [];
|
|
7523
7538
|
stickys.push(isSticky);
|
|
7524
7539
|
}
|
|
7525
7540
|
}
|
|
7526
|
-
|
|
7527
|
-
const offset = isHori ?
|
|
7528
|
-
const targetSize = isHori ?
|
|
7541
|
+
const rect = $target.getBoundingClientRect();
|
|
7542
|
+
const offset = isHori ? rect.left + container.scrollX - container.left : rect.top + container.scrollY - container.top;
|
|
7543
|
+
const targetSize = isHori ? rect.width : rect.height;
|
|
7529
7544
|
const containerSize = isHori ? container.width : container.height;
|
|
7530
7545
|
const scrollSize = isHori ? container.scrollWidth : container.scrollHeight;
|
|
7531
7546
|
const maxScroll = scrollSize - containerSize;
|
|
@@ -7574,8 +7589,8 @@ class ScrollObserver {
|
|
|
7574
7589
|
const offsetStart = parsedEnterTarget + offset - parsedEnterContainer;
|
|
7575
7590
|
const offsetEnd = parsedLeaveTarget + offset - parsedLeaveContainer;
|
|
7576
7591
|
const scrollDelta = offsetEnd - offsetStart;
|
|
7577
|
-
this.offsets[0] = offsetX;
|
|
7578
|
-
this.offsets[1] = offsetY;
|
|
7592
|
+
// this.offsets[0] = offsetX;
|
|
7593
|
+
// this.offsets[1] = offsetY;
|
|
7579
7594
|
this.offset = offset;
|
|
7580
7595
|
this.offsetStart = offsetStart;
|
|
7581
7596
|
this.offsetEnd = offsetEnd;
|
|
@@ -8082,6 +8097,10 @@ class TextSplitter {
|
|
|
8082
8097
|
const fontsReady = doc.fonts.status !== 'loading';
|
|
8083
8098
|
const canSplitLines = lineTemplate && fontsReady;
|
|
8084
8099
|
this.ready = !lineTemplate || fontsReady;
|
|
8100
|
+
if (canSplitLines || clearCache) {
|
|
8101
|
+
// No need to revert effects animations here since it's already taken care by the refreshable
|
|
8102
|
+
this.effectsCleanups.forEach(cleanup => isFnc(cleanup) && cleanup(this));
|
|
8103
|
+
}
|
|
8085
8104
|
if (!isCached) {
|
|
8086
8105
|
if (clearCache) {
|
|
8087
8106
|
$el.innerHTML = this.html;
|
|
@@ -8090,10 +8109,7 @@ class TextSplitter {
|
|
|
8090
8109
|
this.splitNode($el);
|
|
8091
8110
|
this.cache = $el.innerHTML;
|
|
8092
8111
|
}
|
|
8093
|
-
// Always reset the html when splitting by lines
|
|
8094
8112
|
if (canSplitLines) {
|
|
8095
|
-
// No need to revert effects animations here since it's already taken care by the refreshable
|
|
8096
|
-
this.effectsCleanups.forEach(cleanup => isFnc(cleanup) && cleanup(this));
|
|
8097
8113
|
if (isCached) $el.innerHTML = this.cache;
|
|
8098
8114
|
this.lines.length = 0;
|
|
8099
8115
|
if (wordTemplate) this.words = getAllTopLevelElements($el, wordType);
|
|
@@ -8147,9 +8163,6 @@ class TextSplitter {
|
|
|
8147
8163
|
}
|
|
8148
8164
|
words.length = 0;
|
|
8149
8165
|
}
|
|
8150
|
-
if (canSplitLines || clearCache) {
|
|
8151
|
-
this.effects.forEach((effect, i) => this.effectsCleanups[i] = effect(this));
|
|
8152
|
-
}
|
|
8153
8166
|
if (this.accessible && (canSplitLines || !isCached)) {
|
|
8154
8167
|
const $accessible = doc.createElement('span');
|
|
8155
8168
|
// Make the accessible element visually-hidden (https://www.scottohara.me/blog/2017/04/14/inclusively-hidden.html)
|
|
@@ -8162,6 +8175,9 @@ class TextSplitter {
|
|
|
8162
8175
|
this.chars.forEach(setAriaHidden);
|
|
8163
8176
|
}
|
|
8164
8177
|
this.width = /** @type {HTMLElement} */($el).offsetWidth;
|
|
8178
|
+
if (canSplitLines || clearCache) {
|
|
8179
|
+
this.effects.forEach((effect, i) => this.effectsCleanups[i] = effect(this));
|
|
8180
|
+
}
|
|
8165
8181
|
return this;
|
|
8166
8182
|
}
|
|
8167
8183
|
|