motion-dom 14.9.0 → 14.9.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/dist/cjs/index.js +39 -17
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/animation/NativeAnimation.mjs +8 -5
- package/dist/es/animation/NativeAnimation.mjs.map +1 -1
- package/dist/es/animation/NativeAnimationWrapper.mjs +2 -1
- package/dist/es/animation/NativeAnimationWrapper.mjs.map +1 -1
- package/dist/es/animation/waapi/transforms/TransformAnimation.mjs +16 -5
- package/dist/es/animation/waapi/transforms/TransformAnimation.mjs.map +1 -1
- package/dist/es/projection/node/create-projection-node.mjs +7 -4
- package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
- package/dist/es/render/VisualElement.mjs +6 -2
- package/dist/es/render/VisualElement.mjs.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/motion-dom.dev.js +39 -17
- package/dist/motion-dom.js +1 -1
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -2670,7 +2670,8 @@ class NativeAnimation extends WithPromise {
|
|
|
2670
2670
|
if (transition.autoplay === false) {
|
|
2671
2671
|
this.animation.pause();
|
|
2672
2672
|
}
|
|
2673
|
-
this.animation.onfinish = () => {
|
|
2673
|
+
this.animation.onfinish = this.onFinish = () => {
|
|
2674
|
+
this.animation.onfinish = null;
|
|
2674
2675
|
this.finishedTime = this.time;
|
|
2675
2676
|
if (!pseudoElement) {
|
|
2676
2677
|
const keyframe = getFinalKeyframe(keyframes, this.options, finalKeyframe, this.speed);
|
|
@@ -2694,6 +2695,7 @@ class NativeAnimation extends WithPromise {
|
|
|
2694
2695
|
if (this.isStopped)
|
|
2695
2696
|
return;
|
|
2696
2697
|
this.manualStartTime = null;
|
|
2698
|
+
this.animation.onfinish = this.onFinish;
|
|
2697
2699
|
this.animation.play();
|
|
2698
2700
|
if (this.state === "finished") {
|
|
2699
2701
|
this.updateFinished();
|
|
@@ -2703,9 +2705,12 @@ class NativeAnimation extends WithPromise {
|
|
|
2703
2705
|
this.animation.pause();
|
|
2704
2706
|
}
|
|
2705
2707
|
complete() {
|
|
2708
|
+
if (!this.isStopped)
|
|
2709
|
+
this.animation.onfinish = this.onFinish;
|
|
2706
2710
|
this.animation.finish?.();
|
|
2707
2711
|
}
|
|
2708
2712
|
cancel() {
|
|
2713
|
+
this.animation.onfinish = null;
|
|
2709
2714
|
try {
|
|
2710
2715
|
this.animation.cancel();
|
|
2711
2716
|
}
|
|
@@ -2729,10 +2734,8 @@ class NativeAnimation extends WithPromise {
|
|
|
2729
2734
|
else {
|
|
2730
2735
|
this.commitStyles();
|
|
2731
2736
|
}
|
|
2732
|
-
if (!this.isPseudoElement)
|
|
2733
|
-
this.animation.onfinish = null;
|
|
2737
|
+
if (!this.isPseudoElement)
|
|
2734
2738
|
this.cancel();
|
|
2735
|
-
}
|
|
2736
2739
|
}
|
|
2737
2740
|
/**
|
|
2738
2741
|
* WAAPI doesn't natively have any interruption capabilities.
|
|
@@ -2803,7 +2806,7 @@ class NativeAnimation extends WithPromise {
|
|
|
2803
2806
|
if (this.allowFlatten) {
|
|
2804
2807
|
this.animation.effect?.updateTiming({ easing: "linear" });
|
|
2805
2808
|
}
|
|
2806
|
-
this.animation.onfinish = null;
|
|
2809
|
+
this.animation.onfinish = this.onFinish = null;
|
|
2807
2810
|
if (timeline && supportsScrollTimeline()) {
|
|
2808
2811
|
this.animation.timeline = timeline;
|
|
2809
2812
|
onAttach?.(this.animation);
|
|
@@ -3438,13 +3441,15 @@ class TransformAnimation extends JSAnimation {
|
|
|
3438
3441
|
}
|
|
3439
3442
|
}
|
|
3440
3443
|
/**
|
|
3441
|
-
* JSAnimation finishes on its next tick, which only happens
|
|
3442
|
-
* main thread, so finish now.
|
|
3444
|
+
* JSAnimation finishes on its next tick, which only happens once the
|
|
3445
|
+
* group is on the main thread, so finish now. That includes an
|
|
3446
|
+
* animation that can't be accelerated but reached its end before the
|
|
3447
|
+
* group could move there.
|
|
3443
3448
|
*/
|
|
3444
3449
|
complete() {
|
|
3445
3450
|
super.complete();
|
|
3446
3451
|
const { group } = this;
|
|
3447
|
-
group && !group.isJS && this.
|
|
3452
|
+
group && !group.isJS && this.tick(time.now());
|
|
3448
3453
|
}
|
|
3449
3454
|
/**
|
|
3450
3455
|
* Without a tick to rebase it, a held time still includes the delay,
|
|
@@ -3547,13 +3552,22 @@ function createGroup(owner) {
|
|
|
3547
3552
|
const commit = (values = valuesAt()) => {
|
|
3548
3553
|
element.style.transform = toTransform(values, true);
|
|
3549
3554
|
};
|
|
3555
|
+
/**
|
|
3556
|
+
* Cancel a WAAPI animation and remove its handlers, as WebKit never
|
|
3557
|
+
* collects an animation once it has run, nor anything its handlers
|
|
3558
|
+
* reference (#4034).
|
|
3559
|
+
*/
|
|
3560
|
+
const cancel = (animation) => {
|
|
3561
|
+
animation.onfinish = animation.oncancel = null;
|
|
3562
|
+
animation.cancel();
|
|
3563
|
+
};
|
|
3550
3564
|
/**
|
|
3551
3565
|
* Cancel the WAAPI animations, by default first committing the
|
|
3552
3566
|
* transform. The renderer writes its own version on its next render.
|
|
3553
3567
|
*/
|
|
3554
3568
|
const stop = (shouldCommit = true) => {
|
|
3555
3569
|
shouldCommit && commit();
|
|
3556
|
-
segments.forEach(({ animation }) =>
|
|
3570
|
+
segments.forEach(({ animation }) => cancel(animation));
|
|
3557
3571
|
segments = [];
|
|
3558
3572
|
};
|
|
3559
3573
|
/**
|
|
@@ -3574,7 +3588,7 @@ function createGroup(owner) {
|
|
|
3574
3588
|
animation.onfinish = () => {
|
|
3575
3589
|
segment.isDone = true;
|
|
3576
3590
|
if (segments.some((s) => s.end === Infinity)) {
|
|
3577
|
-
|
|
3591
|
+
cancel(animation);
|
|
3578
3592
|
segments = segments.filter((s) => s !== segment);
|
|
3579
3593
|
}
|
|
3580
3594
|
group.schedule(false);
|
|
@@ -4360,7 +4374,8 @@ class NativeAnimationWrapper extends NativeAnimation {
|
|
|
4360
4374
|
constructor(animation) {
|
|
4361
4375
|
super();
|
|
4362
4376
|
this.animation = animation;
|
|
4363
|
-
animation.onfinish = () => {
|
|
4377
|
+
animation.onfinish = this.onFinish = () => {
|
|
4378
|
+
animation.onfinish = null;
|
|
4364
4379
|
this.finishedTime = this.time;
|
|
4365
4380
|
this.notifyFinished();
|
|
4366
4381
|
};
|
|
@@ -8965,12 +8980,15 @@ function notifyLayoutUpdate(node) {
|
|
|
8965
8980
|
let hasRelativeLayoutChanged = false;
|
|
8966
8981
|
const relativeParent = node.getClosestProjectingParent();
|
|
8967
8982
|
/**
|
|
8968
|
-
* A snapshot
|
|
8969
|
-
*
|
|
8983
|
+
* A snapshot from another element is only relative to this node's
|
|
8984
|
+
* relativeParent if it's a layoutRoot that contains both. A node can
|
|
8985
|
+
* hold one without resumeFrom, when the element it came from changed
|
|
8986
|
+
* layoutId but stayed mounted (see switchLayoutId), or a remix
|
|
8987
|
+
* layout exit cleared it (see markLayoutExit).
|
|
8970
8988
|
*/
|
|
8971
|
-
if (!
|
|
8989
|
+
if (!isShared ||
|
|
8972
8990
|
(relativeParent?.options.layoutRoot &&
|
|
8973
|
-
node.resumeFrom
|
|
8991
|
+
node.resumeFrom?.path.includes(relativeParent))) {
|
|
8974
8992
|
/**
|
|
8975
8993
|
* If the relativeParent is itself resuming from a different element then
|
|
8976
8994
|
* the relative snapshot is not relavent
|
|
@@ -9487,9 +9505,13 @@ class VisualElement {
|
|
|
9487
9505
|
* If this element has been mounted before (e.g. after a Suspense
|
|
9488
9506
|
* unmount/remount), reset motion values to their initial state
|
|
9489
9507
|
* so animations replay correctly from initial → animate, unless
|
|
9490
|
-
* the presence asks to keep them
|
|
9508
|
+
* the presence asks to keep them or the element is only shown
|
|
9509
|
+
* again to exit (#4049).
|
|
9491
9510
|
*/
|
|
9492
|
-
|
|
9511
|
+
const presence = this.presenceContext;
|
|
9512
|
+
if (this.hasBeenMounted &&
|
|
9513
|
+
presence?.isPresent !== false &&
|
|
9514
|
+
!presence?.keepValuesOnRemount) {
|
|
9493
9515
|
for (const key in this.initialValues) {
|
|
9494
9516
|
this.values.get(key)?.jump(this.initialValues[key]);
|
|
9495
9517
|
this.latestValues[key] = this.initialValues[key];
|