motion-dom 12.37.0 → 12.38.0

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
@@ -3556,13 +3556,16 @@ function animateTarget(visualElement, targetAndTransition, { delay = 0, transiti
3556
3556
  };
3557
3557
  /**
3558
3558
  * If the value is already at the defined target, skip the animation.
3559
+ * We still re-assert the value via frame.update to take precedence
3560
+ * over any stale transitionEnd callbacks from previous animations.
3559
3561
  */
3560
3562
  const currentValue = value.get();
3561
3563
  if (currentValue !== undefined &&
3562
- !value.isAnimating &&
3564
+ !value.isAnimating() &&
3563
3565
  !Array.isArray(valueTarget) &&
3564
3566
  valueTarget === currentValue &&
3565
3567
  !valueTransition.velocity) {
3568
+ frame.update(() => value.set(valueTarget));
3566
3569
  continue;
3567
3570
  }
3568
3571
  /**
@@ -7393,21 +7396,27 @@ function calcBoxDelta(delta, source, target, origin) {
7393
7396
  calcAxisDelta(delta.x, source.x, target.x, origin ? origin.originX : undefined);
7394
7397
  calcAxisDelta(delta.y, source.y, target.y, origin ? origin.originY : undefined);
7395
7398
  }
7396
- function calcRelativeAxis(target, relative, parent) {
7397
- target.min = parent.min + relative.min;
7399
+ function calcRelativeAxis(target, relative, parent, anchor = 0) {
7400
+ const anchorPoint = anchor
7401
+ ? mixNumber$1(parent.min, parent.max, anchor)
7402
+ : parent.min;
7403
+ target.min = anchorPoint + relative.min;
7398
7404
  target.max = target.min + calcLength(relative);
7399
7405
  }
7400
- function calcRelativeBox(target, relative, parent) {
7401
- calcRelativeAxis(target.x, relative.x, parent.x);
7402
- calcRelativeAxis(target.y, relative.y, parent.y);
7406
+ function calcRelativeBox(target, relative, parent, anchor) {
7407
+ calcRelativeAxis(target.x, relative.x, parent.x, anchor?.x);
7408
+ calcRelativeAxis(target.y, relative.y, parent.y, anchor?.y);
7403
7409
  }
7404
- function calcRelativeAxisPosition(target, layout, parent) {
7405
- target.min = layout.min - parent.min;
7410
+ function calcRelativeAxisPosition(target, layout, parent, anchor = 0) {
7411
+ const anchorPoint = anchor
7412
+ ? mixNumber$1(parent.min, parent.max, anchor)
7413
+ : parent.min;
7414
+ target.min = layout.min - anchorPoint;
7406
7415
  target.max = target.min + calcLength(layout);
7407
7416
  }
7408
- function calcRelativePosition(target, layout, parent) {
7409
- calcRelativeAxisPosition(target.x, layout.x, parent.x);
7410
- calcRelativeAxisPosition(target.y, layout.y, parent.y);
7417
+ function calcRelativePosition(target, layout, parent, anchor) {
7418
+ calcRelativeAxisPosition(target.x, layout.x, parent.x, anchor?.x);
7419
+ calcRelativeAxisPosition(target.y, layout.y, parent.y, anchor?.y);
7411
7420
  }
7412
7421
 
7413
7422
  /**
@@ -8187,8 +8196,18 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
8187
8196
  // but should still clean up the measurements so that the next
8188
8197
  // snapshot could be taken correctly.
8189
8198
  if (updateWasBlocked) {
8199
+ const wasBlockedByResize = this.updateBlockedByResize;
8190
8200
  this.unblockUpdate();
8201
+ this.updateBlockedByResize = false;
8191
8202
  this.clearAllSnapshots();
8203
+ /**
8204
+ * When blocked by resize, still measure layouts so
8205
+ * callbacks like onLayoutMeasure fire (e.g. Reorder).
8206
+ * Skip notifyLayoutUpdate to prevent animations.
8207
+ */
8208
+ if (wasBlockedByResize) {
8209
+ this.nodes.forEach(forceLayoutMeasure);
8210
+ }
8192
8211
  this.nodes.forEach(clearMeasurements);
8193
8212
  return;
8194
8213
  }
@@ -8538,7 +8557,9 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
8538
8557
  * even if no animation has started.
8539
8558
  */
8540
8559
  if (!this.targetDelta && !this.relativeTarget) {
8541
- if (relativeParent && relativeParent.layout) {
8560
+ if (this.options.layoutAnchor !== false &&
8561
+ relativeParent &&
8562
+ relativeParent.layout) {
8542
8563
  this.createRelativeTarget(relativeParent, this.layout.layoutBox, relativeParent.layout.layoutBox);
8543
8564
  }
8544
8565
  else {
@@ -8566,7 +8587,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
8566
8587
  this.relativeParent &&
8567
8588
  this.relativeParent.target) {
8568
8589
  this.forceRelativeParentToResolveTarget();
8569
- calcRelativeBox(this.target, this.relativeTarget, this.relativeParent.target);
8590
+ calcRelativeBox(this.target, this.relativeTarget, this.relativeParent.target, this.options.layoutAnchor || undefined);
8570
8591
  /**
8571
8592
  * If we've only got a targetDelta, resolve it into a target
8572
8593
  */
@@ -8591,7 +8612,8 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
8591
8612
  */
8592
8613
  if (this.attemptToResolveRelativeTarget) {
8593
8614
  this.attemptToResolveRelativeTarget = false;
8594
- if (relativeParent &&
8615
+ if (this.options.layoutAnchor !== false &&
8616
+ relativeParent &&
8595
8617
  Boolean(relativeParent.resumingFrom) ===
8596
8618
  Boolean(this.resumingFrom) &&
8597
8619
  !relativeParent.options.layoutScroll &&
@@ -8635,7 +8657,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
8635
8657
  this.forceRelativeParentToResolveTarget();
8636
8658
  this.relativeTarget = createBox();
8637
8659
  this.relativeTargetOrigin = createBox();
8638
- calcRelativePosition(this.relativeTargetOrigin, layout, parentLayout);
8660
+ calcRelativePosition(this.relativeTargetOrigin, layout, parentLayout, this.options.layoutAnchor || undefined);
8639
8661
  copyBoxInto(this.relativeTarget, this.relativeTargetOrigin);
8640
8662
  }
8641
8663
  removeRelativeTarget() {
@@ -8807,7 +8829,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
8807
8829
  this.layout &&
8808
8830
  this.relativeParent &&
8809
8831
  this.relativeParent.layout) {
8810
- calcRelativePosition(relativeLayout, this.layout.layoutBox, this.relativeParent.layout.layoutBox);
8832
+ calcRelativePosition(relativeLayout, this.layout.layoutBox, this.relativeParent.layout.layoutBox, this.options.layoutAnchor || undefined);
8811
8833
  mixBox(this.relativeTarget, this.relativeTargetOrigin, relativeLayout, progress);
8812
8834
  /**
8813
8835
  * If this is an unchanged relative target we can consider the
@@ -9226,10 +9248,11 @@ function notifyLayoutUpdate(node) {
9226
9248
  if (relativeParent && !relativeParent.resumeFrom) {
9227
9249
  const { snapshot: parentSnapshot, layout: parentLayout } = relativeParent;
9228
9250
  if (parentSnapshot && parentLayout) {
9251
+ const anchor = node.options.layoutAnchor || undefined;
9229
9252
  const relativeSnapshot = createBox();
9230
- calcRelativePosition(relativeSnapshot, snapshot.layoutBox, parentSnapshot.layoutBox);
9253
+ calcRelativePosition(relativeSnapshot, snapshot.layoutBox, parentSnapshot.layoutBox, anchor);
9231
9254
  const relativeLayout = createBox();
9232
- calcRelativePosition(relativeLayout, layout, parentLayout.layoutBox);
9255
+ calcRelativePosition(relativeLayout, layout, parentLayout.layoutBox, anchor);
9233
9256
  if (!boxEqualsRounded(relativeSnapshot, relativeLayout)) {
9234
9257
  hasRelativeLayoutChanged = true;
9235
9258
  }
@@ -9301,6 +9324,10 @@ function clearSnapshot(node) {
9301
9324
  function clearMeasurements(node) {
9302
9325
  node.clearMeasurements();
9303
9326
  }
9327
+ function forceLayoutMeasure(node) {
9328
+ node.isLayoutDirty = true;
9329
+ node.updateLayout();
9330
+ }
9304
9331
  function clearIsLayoutDirty(node) {
9305
9332
  node.isLayoutDirty = false;
9306
9333
  }