Skip to content

Commit ab6d5b2

Browse files
committed
v4.1.2
1 parent cd1ba81 commit ab6d5b2

27 files changed

+554
-135
lines changed

examples/draggable-playground/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ utils.set('#map-props .carousel-item', {
295295
});
296296

297297
const carousel = createDraggable('#map-props .carousel', {
298+
trigger: '#map-props',
298299
x: { mapTo: 'rotateY' },
299300
y: false,
300301
snap: itemAngle,

examples/easings-visualizer/index.html

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -349,13 +349,15 @@
349349
}
350350
}
351351

352-
.ease-button {
352+
button.ease-button {
353353
position: relative;
354354
display: flex;
355+
flex-shrink: 0;
355356
flex-direction: column;
356357
justify-content: center;
357358
align-items: center;
358359
width: calc(25% - .25rem);
360+
height: auto;
359361
margin: .125rem;
360362
padding: .5rem;
361363
background-color: rgba(255, 255, 255, .05);
@@ -367,48 +369,48 @@
367369
}
368370

369371
@media (min-width: 1280px) {
370-
.ease-button {
372+
button.ease-button {
371373
width: calc(12.5% - .25rem);
372374
}
373375
}
374376

375-
.ease-button:hover {
377+
button.ease-button:hover {
376378
background-color: rgba(255, 255, 255, .1);
377379
transition: background-color .05s ease-out;
378380
}
379381

380-
.ease-button.is-active {
382+
button.ease-button.is-active {
381383
background: var(--red);
382384
color: var(--black);
383385
}
384386

385-
.ease-button .ease-config {
387+
button.ease-button .ease-config {
386388
position: absolute;
387389
top: .25rem;
388390
right: .41rem;
389391
font-size: .75rem;
390392
}
391393

392-
.ease-button svg {
394+
button.ease-button svg {
393395
overflow: visible;
394396
width: calc(100% - 3rem);
395397
margin-top: 0.25rem;
396398
margin-bottom: 0.5rem;
397399
}
398400

399401
@media (min-width: 640px) {
400-
.ease-button svg {
402+
button.ease-button svg {
401403
width: calc(100% - 2rem);
402404
margin-top: 1rem;
403405
margin-bottom: 1rem;
404406
}
405407
}
406408

407-
.ease-button svg polyline {
409+
button.ease-button svg polyline {
408410
stroke: var(--red);
409411
}
410412

411-
.ease-button.is-active svg polyline {
413+
button.ease-button.is-active svg polyline {
412414
stroke: var(--black);
413415
}
414416

examples/onscroll-sticky/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ createTimeline({
2929
enter: 'top top',
3030
leave: 'bottom bottom',
3131
sync: .5,
32-
// debug: true,
32+
debug: true,
3333
}),
3434
})
3535
.add('.stack', {

lib/anime.cjs

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

lib/anime.esm.js

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* anime.js - ESM
3-
* @version v4.1.1
3+
* @version v4.1.2
44
* @author Julian Garnier
55
* @license MIT
66
* @copyright (c) 2025 Julian Garnier
@@ -470,10 +470,10 @@
470470
// TODO: Do we need to check if we're running inside a worker ?
471471
const isBrowser = typeof window !== 'undefined';
472472

473-
/** @type {Object|Null} */
474-
const win = isBrowser ? window : null;
473+
/** @type {Window & {AnimeJS: Array}|null} */
474+
const win = isBrowser ? /** @type {Window & {AnimeJS: Array}} */(/** @type {unknown} */(window)) : null;
475475

476-
/** @type {Document} */
476+
/** @type {Document|null} */
477477
const doc = isBrowser ? document : null;
478478

479479
// Enums
@@ -625,7 +625,7 @@ const globals = {
625625
tickThreshold: 200,
626626
};
627627

628-
const globalVersions = { version: '4.1.1', engine: null };
628+
const globalVersions = { version: '4.1.2', engine: null };
629629

630630
if (isBrowser) {
631631
if (!win.AnimeJS) win.AnimeJS = [];
@@ -1316,7 +1316,7 @@ const tick = (tickable, time, muteCallbacks, internalRender, tickMode) => {
13161316
if (!muteCallbacks && tlChildrenHasRendered) tl.onRender(/** @type {CallbackArgument} */(tl));
13171317

13181318
// 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) {
13201320
// Make sure the paused flag is false in case it has been skipped in the render function
13211321
tl.paused = true;
13221322
if (!tl.completed) {
@@ -3909,7 +3909,8 @@ class JSAnimation extends Timer {
39093909
tween._fromNumber = decomposedOriginalValue.n;
39103910
tween._toNumbers = cloneArray(toTargetObject.d);
39113911
tween._strings = cloneArray(toTargetObject.s);
3912-
tween._toNumber = toTargetObject.n;
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;
39133914
}
39143915
});
39153916
return this;
@@ -5741,7 +5742,8 @@ class Draggable {
57415742
this.deltaY = dy;
57425743
this.coords[2] = x;
57435744
this.coords[3] = y;
5744-
if (hasUpdated) {
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)) {
57455747
this.onUpdate(this);
57465748
}
57475749
if (!hasReleased) {
@@ -6526,7 +6528,6 @@ class Draggable {
65266528
this.targetStyles.revert();
65276529
this.targetStyles = null;
65286530
}
6529-
this.stop();
65306531
this.$target.classList.add('is-disabled');
65316532
this.$trigger.removeEventListener('touchstart', this);
65326533
this.$trigger.removeEventListener('mousedown', this);
@@ -6549,6 +6550,7 @@ class Draggable {
65496550
this.overshootYTicker.revert();
65506551
this.resizeTicker.revert();
65516552
this.animate.revert();
6553+
this.resizeObserver.disconnect();
65526554
return this;
65536555
}
65546556

@@ -6826,7 +6828,7 @@ const createScope = params => new Scope(params);
68266828
* @return {Number}
68276829
*/
68286830
const getMaxViewHeight = () => {
6829-
const $el = document.createElement('div');
6831+
const $el = doc.createElement('div');
68306832
doc.body.appendChild($el);
68316833
$el.style.height = '100lvh';
68326834
const height = $el.offsetHeight;
@@ -7025,7 +7027,7 @@ class ScrollContainer {
70257027
this.dataTimer.cancel();
70267028
this.resizeTicker.cancel();
70277029
this.wakeTicker.cancel();
7028-
this.resizeObserver.unobserve(this.element);
7030+
this.resizeObserver.disconnect();
70297031
(this.useWin ? win : this.element).removeEventListener('scroll', this);
70307032
scrollContainers.delete(this.element);
70317033
}
@@ -7254,8 +7256,8 @@ class ScrollObserver {
72547256
this.forceEnter = false;
72557257
/** @type {Boolean} */
72567258
this.hasEntered = false;
7257-
/** @type {Array.<Number>} */
7258-
this.offsets = [];
7259+
// /** @type {Array.<Number>} */
7260+
// this.offsets = [];
72597261
/** @type {Number} */
72607262
this.offset = 0;
72617263
/** @type {Number} */
@@ -7499,33 +7501,46 @@ class ScrollObserver {
74997501
const linked = this.linked;
75007502
let linkedTime;
75017503
let $el = $target;
7502-
let offsetX = 0;
7503-
let offsetY = 0;
7504+
// let offsetX = 0;
7505+
// let offsetY = 0;
7506+
// let $offsetParent = $el;
75047507
/** @type {Element} */
7505-
let $offsetParent = $el;
75067508
if (linked) {
75077509
linkedTime = linked.currentTime;
75087510
linked.seek(0, true);
75097511
}
7510-
const isContainerStatic = getTargetValue(container.element, 'position') === 'static' ? setTargetValues(container.element, { position: 'relative '}) : false;
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+
75117533
while ($el && $el !== container.element && $el !== doc.body) {
7512-
const isSticky = getTargetValue($el, 'position') === 'sticky' ?
7513-
setTargetValues($el, { position: 'static' }) :
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;
75217536
if (isSticky) {
75227537
if (!stickys) stickys = [];
75237538
stickys.push(isSticky);
75247539
}
75257540
}
7526-
if (isContainerStatic) isContainerStatic.revert();
7527-
const offset = isHori ? offsetX : offsetY;
7528-
const targetSize = isHori ? $target.offsetWidth : $target.offsetHeight;
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;
75297544
const containerSize = isHori ? container.width : container.height;
75307545
const scrollSize = isHori ? container.scrollWidth : container.scrollHeight;
75317546
const maxScroll = scrollSize - containerSize;
@@ -7574,8 +7589,8 @@ class ScrollObserver {
75747589
const offsetStart = parsedEnterTarget + offset - parsedEnterContainer;
75757590
const offsetEnd = parsedLeaveTarget + offset - parsedLeaveContainer;
75767591
const scrollDelta = offsetEnd - offsetStart;
7577-
this.offsets[0] = offsetX;
7578-
this.offsets[1] = offsetY;
7592+
// this.offsets[0] = offsetX;
7593+
// this.offsets[1] = offsetY;
75797594
this.offset = offset;
75807595
this.offsetStart = offsetStart;
75817596
this.offsetEnd = offsetEnd;

lib/anime.esm.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/anime.iife.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/anime.iife.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/anime.min.cjs

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

lib/anime.umd.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)