motion-dom 12.33.0 → 12.33.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/dist/cjs/index.js CHANGED
@@ -6828,6 +6828,22 @@ function createAnimationState(visualElement) {
6828
6828
  typeof prop === "boolean") {
6829
6829
  continue;
6830
6830
  }
6831
+ /**
6832
+ * If exit is already active and wasn't just activated, skip
6833
+ * re-processing to prevent interrupting running exit animations.
6834
+ * Re-resolving exit with a changed custom value can start new
6835
+ * value animations that stop the originals, leaving the exit
6836
+ * animation promise unresolved and the component stuck in the DOM.
6837
+ */
6838
+ if (type === "exit" && typeState.isActive && activeDelta !== true) {
6839
+ if (typeState.prevResolvedValues) {
6840
+ encounteredKeys = {
6841
+ ...encounteredKeys,
6842
+ ...typeState.prevResolvedValues,
6843
+ };
6844
+ }
6845
+ continue;
6846
+ }
6831
6847
  /**
6832
6848
  * As we go look through the values defined on this type, if we detect
6833
6849
  * a changed value or a value that was removed in a higher priority, we set
@@ -7399,6 +7415,15 @@ class NodeStack {
7399
7415
  }
7400
7416
  add(node) {
7401
7417
  motionUtils.addUniqueItem(this.members, node);
7418
+ for (let i = this.members.length - 1; i >= 0; i--) {
7419
+ const m = this.members[i];
7420
+ if (m === node || m === this.lead || m === this.prevLead)
7421
+ continue;
7422
+ const inst = m.instance;
7423
+ if (inst && inst.isConnected === false && m.isPresent !== false && !m.snapshot) {
7424
+ motionUtils.removeItem(this.members, m);
7425
+ }
7426
+ }
7402
7427
  node.scheduleRender();
7403
7428
  }
7404
7429
  remove(node) {
@@ -7423,7 +7448,8 @@ class NodeStack {
7423
7448
  let prevLead;
7424
7449
  for (let i = indexOfNode; i >= 0; i--) {
7425
7450
  const member = this.members[i];
7426
- if (member.isPresent !== false) {
7451
+ const inst = member.instance;
7452
+ if (member.isPresent !== false && (!inst || inst.isConnected !== false)) {
7427
7453
  prevLead = member;
7428
7454
  break;
7429
7455
  }
@@ -7458,17 +7484,21 @@ class NodeStack {
7458
7484
  nextDep !== undefined &&
7459
7485
  prevDep === nextDep;
7460
7486
  if (!dependencyMatches) {
7461
- node.resumeFrom = prevLead;
7462
- if (preserveFollowOpacity) {
7463
- node.resumeFrom.preserveOpacity = true;
7464
- }
7465
- if (prevLead.snapshot) {
7466
- node.snapshot = prevLead.snapshot;
7467
- node.snapshot.latestValues =
7468
- prevLead.animationValues || prevLead.latestValues;
7469
- }
7470
- if (node.root && node.root.isUpdating) {
7471
- node.isLayoutDirty = true;
7487
+ const prevInstance = prevLead.instance;
7488
+ const isStale = prevInstance && prevInstance.isConnected === false && !prevLead.snapshot;
7489
+ if (!isStale) {
7490
+ node.resumeFrom = prevLead;
7491
+ if (preserveFollowOpacity) {
7492
+ node.resumeFrom.preserveOpacity = true;
7493
+ }
7494
+ if (prevLead.snapshot) {
7495
+ node.snapshot = prevLead.snapshot;
7496
+ node.snapshot.latestValues =
7497
+ prevLead.animationValues || prevLead.latestValues;
7498
+ }
7499
+ if (node.root && node.root.isUpdating) {
7500
+ node.isLayoutDirty = true;
7501
+ }
7472
7502
  }
7473
7503
  }
7474
7504
  const { crossfade } = node.options;