motion-dom 12.36.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.
Files changed (35) hide show
  1. package/dist/cjs/index.js +179 -83
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/es/animation/AsyncMotionValueAnimation.mjs +15 -6
  4. package/dist/es/animation/AsyncMotionValueAnimation.mjs.map +1 -1
  5. package/dist/es/animation/JSAnimation.mjs +16 -3
  6. package/dist/es/animation/JSAnimation.mjs.map +1 -1
  7. package/dist/es/animation/interfaces/motion-value.mjs +1 -1
  8. package/dist/es/animation/interfaces/motion-value.mjs.map +1 -1
  9. package/dist/es/animation/interfaces/visual-element-target.mjs +4 -1
  10. package/dist/es/animation/interfaces/visual-element-target.mjs.map +1 -1
  11. package/dist/es/animation/utils/active-animations.mjs +5 -2
  12. package/dist/es/animation/utils/active-animations.mjs.map +1 -1
  13. package/dist/es/animation/utils/is-transition-defined.mjs +18 -2
  14. package/dist/es/animation/utils/is-transition-defined.mjs.map +1 -1
  15. package/dist/es/animation/waapi/supports/waapi.mjs +21 -12
  16. package/dist/es/animation/waapi/supports/waapi.mjs.map +1 -1
  17. package/dist/es/animation/waapi/utils/is-browser-color.mjs +13 -0
  18. package/dist/es/animation/waapi/utils/is-browser-color.mjs.map +1 -0
  19. package/dist/es/index.mjs +1 -1
  20. package/dist/es/projection/animation/mix-values.mjs +8 -3
  21. package/dist/es/projection/animation/mix-values.mjs.map +1 -1
  22. package/dist/es/projection/geometry/delta-apply.mjs +4 -6
  23. package/dist/es/projection/geometry/delta-apply.mjs.map +1 -1
  24. package/dist/es/projection/geometry/delta-calc.mjs +16 -10
  25. package/dist/es/projection/geometry/delta-calc.mjs.map +1 -1
  26. package/dist/es/projection/node/create-projection-node.mjs +49 -16
  27. package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
  28. package/dist/es/value/follow-value.mjs +3 -0
  29. package/dist/es/value/follow-value.mjs.map +1 -1
  30. package/dist/index.d.ts +30 -11
  31. package/dist/motion-dom.dev.js +179 -83
  32. package/dist/motion-dom.js +1 -1
  33. package/package.json +2 -2
  34. package/dist/es/animation/utils/get-final-keyframe.mjs +0 -13
  35. package/dist/es/animation/utils/get-final-keyframe.mjs.map +0 -1
@@ -1324,9 +1324,9 @@
1324
1324
  };
1325
1325
  }
1326
1326
 
1327
- const isNotNull$1 = (value) => value !== null;
1328
- function getFinalKeyframe$1(keyframes, { repeat, repeatType = "loop" }, finalKeyframe, speed = 1) {
1329
- const resolvedKeyframes = keyframes.filter(isNotNull$1);
1327
+ const isNotNull = (value) => value !== null;
1328
+ function getFinalKeyframe(keyframes, { repeat, repeatType = "loop" }, finalKeyframe, speed = 1) {
1329
+ const resolvedKeyframes = keyframes.filter(isNotNull);
1330
1330
  const useFirstKeyframe = speed < 0 || (repeat && repeatType !== "loop" && repeat % 2 === 1);
1331
1331
  const index = useFirstKeyframe ? 0 : resolvedKeyframes.length - 1;
1332
1332
  return !index || finalKeyframe === undefined
@@ -1391,6 +1391,14 @@
1391
1391
  * Playback speed as a factor. 0 would be stopped, -1 reverse and 2 double speed.
1392
1392
  */
1393
1393
  this.playbackSpeed = 1;
1394
+ /**
1395
+ * Reusable state object for the delay phase to avoid
1396
+ * allocating a new object every frame.
1397
+ */
1398
+ this.delayState = {
1399
+ done: false,
1400
+ value: undefined,
1401
+ };
1394
1402
  /**
1395
1403
  * This method is bound to the instance to fix a pattern where
1396
1404
  * animation.stop is returned as a reference from a useEffect.
@@ -1552,9 +1560,14 @@
1552
1560
  * This prevents delay: x, duration: 0 animations from finishing
1553
1561
  * instantly.
1554
1562
  */
1555
- const state = isInDelayPhase
1556
- ? { done: false, value: keyframes[0] }
1557
- : frameGenerator.next(elapsed);
1563
+ let state;
1564
+ if (isInDelayPhase) {
1565
+ this.delayState.value = keyframes[0];
1566
+ state = this.delayState;
1567
+ }
1568
+ else {
1569
+ state = frameGenerator.next(elapsed);
1570
+ }
1558
1571
  if (mixKeyframes && !isInDelayPhase) {
1559
1572
  state.value = mixKeyframes(state.value);
1560
1573
  }
@@ -1569,7 +1582,7 @@
1569
1582
  (this.state === "finished" || (this.state === "running" && done));
1570
1583
  // TODO: The exception for inertia could be cleaner here
1571
1584
  if (isAnimationFinished && type !== inertia) {
1572
- state.value = getFinalKeyframe$1(keyframes, this.options, finalKeyframe, this.speed);
1585
+ state.value = getFinalKeyframe(keyframes, this.options, finalKeyframe, this.speed);
1573
1586
  }
1574
1587
  if (onUpdate) {
1575
1588
  onUpdate(state.value);
@@ -2177,7 +2190,7 @@
2177
2190
  this.animation.onfinish = () => {
2178
2191
  this.finishedTime = this.time;
2179
2192
  if (!pseudoElement) {
2180
- const keyframe = getFinalKeyframe$1(keyframes, this.options, finalKeyframe, this.speed);
2193
+ const keyframe = getFinalKeyframe(keyframes, this.options, finalKeyframe, this.speed);
2181
2194
  if (this.updateMotionValue) {
2182
2195
  this.updateMotionValue(keyframe);
2183
2196
  }
@@ -2483,17 +2496,42 @@
2483
2496
  /**
2484
2497
  * A list of values that can be hardware-accelerated.
2485
2498
  */
2486
- const acceleratedValues$1 = new Set([
2499
+ const acceleratedValues = new Set([
2487
2500
  "opacity",
2488
2501
  "clipPath",
2489
2502
  "filter",
2490
2503
  "transform",
2491
- // TODO: Could be re-enabled now we have support for linear() easing
2504
+ // TODO: Can be accelerated but currently disabled until https://issues.chromium.org/issues/41491098 is resolved
2505
+ // or until we implement support for linear() easing.
2492
2506
  // "background-color"
2493
2507
  ]);
2508
+
2509
+ const browserColorFunctions = /^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;
2510
+ function hasBrowserOnlyColors(keyframes) {
2511
+ for (let i = 0; i < keyframes.length; i++) {
2512
+ if (typeof keyframes[i] === "string" &&
2513
+ browserColorFunctions.test(keyframes[i])) {
2514
+ return true;
2515
+ }
2516
+ }
2517
+ return false;
2518
+ }
2519
+
2520
+ const colorProperties = new Set([
2521
+ "color",
2522
+ "backgroundColor",
2523
+ "outlineColor",
2524
+ "fill",
2525
+ "stroke",
2526
+ "borderColor",
2527
+ "borderTopColor",
2528
+ "borderRightColor",
2529
+ "borderBottomColor",
2530
+ "borderLeftColor",
2531
+ ]);
2494
2532
  const supportsWaapi = /*@__PURE__*/ motionUtils.memo(() => Object.hasOwnProperty.call(Element.prototype, "animate"));
2495
2533
  function supportsBrowserAnimation(options) {
2496
- const { motionValue, name, repeatDelay, repeatType, damping, type } = options;
2534
+ const { motionValue, name, repeatDelay, repeatType, damping, type, keyframes, } = options;
2497
2535
  const subject = motionValue?.owner?.current;
2498
2536
  /**
2499
2537
  * We use this check instead of isHTMLElement() because we explicitly
@@ -2507,7 +2545,13 @@
2507
2545
  const { onUpdate, transformTemplate } = motionValue.owner.getProps();
2508
2546
  return (supportsWaapi() &&
2509
2547
  name &&
2510
- acceleratedValues$1.has(name) &&
2548
+ /**
2549
+ * Force WAAPI for color properties with browser-only color formats
2550
+ * (oklch, oklab, lab, lch, etc.) that the JS animation path can't parse.
2551
+ */
2552
+ (acceleratedValues.has(name) ||
2553
+ (colorProperties.has(name) &&
2554
+ hasBrowserOnlyColors(keyframes))) &&
2511
2555
  (name !== "transform" || !transformTemplate) &&
2512
2556
  /**
2513
2557
  * If we're outputting values to onUpdate then we can't use WAAPI as there's
@@ -2571,7 +2615,7 @@
2571
2615
  if (!canAnimate(keyframes, name, type, velocity)) {
2572
2616
  canAnimateValue = false;
2573
2617
  if (motionUtils.MotionGlobalConfig.instantAnimations || !delay) {
2574
- onUpdate?.(getFinalKeyframe$1(keyframes, options, finalKeyframe));
2618
+ onUpdate?.(getFinalKeyframe(keyframes, options, finalKeyframe));
2575
2619
  }
2576
2620
  keyframes[0] = keyframes[keyframes.length - 1];
2577
2621
  makeAnimationInstant(options);
@@ -2614,12 +2658,21 @@
2614
2658
  !isHandoff &&
2615
2659
  supportsBrowserAnimation(resolvedOptions);
2616
2660
  const element = resolvedOptions.motionValue?.owner?.current;
2617
- const animation = useWaapi
2618
- ? new NativeAnimationExtended({
2619
- ...resolvedOptions,
2620
- element,
2621
- })
2622
- : new JSAnimation(resolvedOptions);
2661
+ let animation;
2662
+ if (useWaapi) {
2663
+ try {
2664
+ animation = new NativeAnimationExtended({
2665
+ ...resolvedOptions,
2666
+ element,
2667
+ });
2668
+ }
2669
+ catch {
2670
+ animation = new JSAnimation(resolvedOptions);
2671
+ }
2672
+ }
2673
+ else {
2674
+ animation = new JSAnimation(resolvedOptions);
2675
+ }
2623
2676
  animation.finished.then(() => {
2624
2677
  this.notifyFinished();
2625
2678
  }).catch(motionUtils.noop);
@@ -2797,8 +2850,11 @@
2797
2850
  const animationMaps = new WeakMap();
2798
2851
  const animationMapKey = (name, pseudoElement = "") => `${name}:${pseudoElement}`;
2799
2852
  function getAnimationMap(element) {
2800
- const map = animationMaps.get(element) || new Map();
2801
- animationMaps.set(element, map);
2853
+ let map = animationMaps.get(element);
2854
+ if (!map) {
2855
+ map = new Map();
2856
+ animationMaps.set(element, map);
2857
+ }
2802
2858
  return map;
2803
2859
  }
2804
2860
 
@@ -2890,17 +2946,6 @@
2890
2946
  return ease;
2891
2947
  };
2892
2948
 
2893
- const isNotNull = (value) => value !== null;
2894
- function getFinalKeyframe(keyframes, { repeat, repeatType = "loop" }, finalKeyframe) {
2895
- const resolvedKeyframes = keyframes.filter(isNotNull);
2896
- const index = repeat && repeatType !== "loop" && repeat % 2 === 1
2897
- ? 0
2898
- : resolvedKeyframes.length - 1;
2899
- return !index || finalKeyframe === undefined
2900
- ? resolvedKeyframes[index]
2901
- : finalKeyframe;
2902
- }
2903
-
2904
2949
  /**
2905
2950
  * If `transition` has `inherit: true`, shallow-merge it with
2906
2951
  * `parentTransition` (child keys win) and strip the `inherit` key.
@@ -2924,13 +2969,29 @@
2924
2969
  return valueTransition;
2925
2970
  }
2926
2971
 
2972
+ const orchestrationKeys = new Set([
2973
+ "when",
2974
+ "delay",
2975
+ "delayChildren",
2976
+ "staggerChildren",
2977
+ "staggerDirection",
2978
+ "repeat",
2979
+ "repeatType",
2980
+ "repeatDelay",
2981
+ "from",
2982
+ "elapsed",
2983
+ ]);
2927
2984
  /**
2928
2985
  * Decide whether a transition is defined on a given Transition.
2929
2986
  * This filters out orchestration options and returns true
2930
2987
  * if any options are left.
2931
2988
  */
2932
- function isTransitionDefined({ when, delay: _delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, elapsed, ...transition }) {
2933
- return !!Object.keys(transition).length;
2989
+ function isTransitionDefined(transition) {
2990
+ for (const key in transition) {
2991
+ if (!orchestrationKeys.has(key))
2992
+ return true;
2993
+ }
2994
+ return false;
2934
2995
  }
2935
2996
 
2936
2997
  const animateMotionValue = (name, value, target, transition = {}, element, isHandoff) => (onComplete) => {
@@ -3494,13 +3555,16 @@
3494
3555
  };
3495
3556
  /**
3496
3557
  * If the value is already at the defined target, skip the animation.
3558
+ * We still re-assert the value via frame.update to take precedence
3559
+ * over any stale transitionEnd callbacks from previous animations.
3497
3560
  */
3498
3561
  const currentValue = value.get();
3499
3562
  if (currentValue !== undefined &&
3500
- !value.isAnimating &&
3563
+ !value.isAnimating() &&
3501
3564
  !Array.isArray(valueTarget) &&
3502
3565
  valueTarget === currentValue &&
3503
3566
  !valueTransition.velocity) {
3567
+ frame.update(() => value.set(valueTarget));
3504
3568
  continue;
3505
3569
  }
3506
3570
  /**
@@ -4062,19 +4126,6 @@
4062
4126
  return true;
4063
4127
  });
4064
4128
 
4065
- /**
4066
- * A list of values that can be hardware-accelerated.
4067
- */
4068
- const acceleratedValues = new Set([
4069
- "opacity",
4070
- "clipPath",
4071
- "filter",
4072
- "transform",
4073
- // TODO: Can be accelerated but currently disabled until https://issues.chromium.org/issues/41491098 is resolved
4074
- // or until we implement support for linear() easing.
4075
- // "background-color"
4076
- ]);
4077
-
4078
4129
  function resolveElements(elementOrSelector, scope, selectorCache) {
4079
4130
  if (elementOrSelector == null) {
4080
4131
  return [];
@@ -4960,6 +5011,7 @@
4960
5011
  activeAnimation.stop();
4961
5012
  activeAnimation = null;
4962
5013
  }
5014
+ value.animation = undefined;
4963
5015
  };
4964
5016
  const startAnimation = () => {
4965
5017
  const currentValue = asNumber$1(value.get());
@@ -4991,8 +5043,10 @@
4991
5043
  // multiple calls within the same frame (e.g. rapid mouse events)
4992
5044
  const scheduleAnimation = () => {
4993
5045
  startAnimation();
5046
+ value.animation = activeAnimation ?? undefined;
4994
5047
  value["events"].animationStart?.notify();
4995
5048
  activeAnimation?.then(() => {
5049
+ value.animation = undefined;
4996
5050
  value["events"].animationComplete?.notify();
4997
5051
  });
4998
5052
  };
@@ -6291,10 +6345,8 @@
6291
6345
  node.options.layoutScroll &&
6292
6346
  node.scroll &&
6293
6347
  node !== node.root) {
6294
- transformBox(box, {
6295
- x: -node.scroll.offset.x,
6296
- y: -node.scroll.offset.y,
6297
- });
6348
+ translateAxis(box.x, -node.scroll.offset.x);
6349
+ translateAxis(box.y, -node.scroll.offset.y);
6298
6350
  }
6299
6351
  if (delta) {
6300
6352
  // Incoporate each ancestor's scale into a cumulative treeScale for this component
@@ -6321,8 +6373,8 @@
6321
6373
  }
6322
6374
  }
6323
6375
  function translateAxis(axis, distance) {
6324
- axis.min = axis.min + distance;
6325
- axis.max = axis.max + distance;
6376
+ axis.min += distance;
6377
+ axis.max += distance;
6326
6378
  }
6327
6379
  /**
6328
6380
  * Apply a transform to an axis from the latest resolved motion values.
@@ -7343,21 +7395,27 @@
7343
7395
  calcAxisDelta(delta.x, source.x, target.x, origin ? origin.originX : undefined);
7344
7396
  calcAxisDelta(delta.y, source.y, target.y, origin ? origin.originY : undefined);
7345
7397
  }
7346
- function calcRelativeAxis(target, relative, parent) {
7347
- target.min = parent.min + relative.min;
7398
+ function calcRelativeAxis(target, relative, parent, anchor = 0) {
7399
+ const anchorPoint = anchor
7400
+ ? mixNumber$1(parent.min, parent.max, anchor)
7401
+ : parent.min;
7402
+ target.min = anchorPoint + relative.min;
7348
7403
  target.max = target.min + calcLength(relative);
7349
7404
  }
7350
- function calcRelativeBox(target, relative, parent) {
7351
- calcRelativeAxis(target.x, relative.x, parent.x);
7352
- calcRelativeAxis(target.y, relative.y, parent.y);
7405
+ function calcRelativeBox(target, relative, parent, anchor) {
7406
+ calcRelativeAxis(target.x, relative.x, parent.x, anchor?.x);
7407
+ calcRelativeAxis(target.y, relative.y, parent.y, anchor?.y);
7353
7408
  }
7354
- function calcRelativeAxisPosition(target, layout, parent) {
7355
- target.min = layout.min - parent.min;
7409
+ function calcRelativeAxisPosition(target, layout, parent, anchor = 0) {
7410
+ const anchorPoint = anchor
7411
+ ? mixNumber$1(parent.min, parent.max, anchor)
7412
+ : parent.min;
7413
+ target.min = layout.min - anchorPoint;
7356
7414
  target.max = target.min + calcLength(layout);
7357
7415
  }
7358
- function calcRelativePosition(target, layout, parent) {
7359
- calcRelativeAxisPosition(target.x, layout.x, parent.x);
7360
- calcRelativeAxisPosition(target.y, layout.y, parent.y);
7416
+ function calcRelativePosition(target, layout, parent, anchor) {
7417
+ calcRelativeAxisPosition(target.x, layout.x, parent.x, anchor?.x);
7418
+ calcRelativeAxisPosition(target.y, layout.y, parent.y, anchor?.y);
7361
7419
  }
7362
7420
 
7363
7421
  /**
@@ -7489,8 +7547,13 @@
7489
7547
  return transform || "none";
7490
7548
  }
7491
7549
 
7492
- const borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
7493
- const numBorders = borders.length;
7550
+ const borderLabels = [
7551
+ "borderTopLeftRadius",
7552
+ "borderTopRightRadius",
7553
+ "borderBottomLeftRadius",
7554
+ "borderBottomRightRadius",
7555
+ ];
7556
+ const numBorders = borderLabels.length;
7494
7557
  const asNumber = (value) => typeof value === "string" ? parseFloat(value) : value;
7495
7558
  const isPx = (value) => typeof value === "number" || px.test(value);
7496
7559
  function mixValues(target, follow, lead, progress, shouldCrossfadeOpacity, isOnlyMember) {
@@ -7505,7 +7568,7 @@
7505
7568
  * Mix border radius
7506
7569
  */
7507
7570
  for (let i = 0; i < numBorders; i++) {
7508
- const borderLabel = `border${borders[i]}Radius`;
7571
+ const borderLabel = borderLabels[i];
7509
7572
  let followRadius = getRadius(follow, borderLabel);
7510
7573
  let leadRadius = getRadius(lead, borderLabel);
7511
7574
  if (followRadius === undefined && leadRadius === undefined)
@@ -8132,8 +8195,18 @@
8132
8195
  // but should still clean up the measurements so that the next
8133
8196
  // snapshot could be taken correctly.
8134
8197
  if (updateWasBlocked) {
8198
+ const wasBlockedByResize = this.updateBlockedByResize;
8135
8199
  this.unblockUpdate();
8200
+ this.updateBlockedByResize = false;
8136
8201
  this.clearAllSnapshots();
8202
+ /**
8203
+ * When blocked by resize, still measure layouts so
8204
+ * callbacks like onLayoutMeasure fire (e.g. Reorder).
8205
+ * Skip notifyLayoutUpdate to prevent animations.
8206
+ */
8207
+ if (wasBlockedByResize) {
8208
+ this.nodes.forEach(forceLayoutMeasure);
8209
+ }
8137
8210
  this.nodes.forEach(clearMeasurements);
8138
8211
  return;
8139
8212
  }
@@ -8150,6 +8223,11 @@
8150
8223
  }
8151
8224
  else {
8152
8225
  this.isUpdating = false;
8226
+ /**
8227
+ * Ensure animation-blocked nodes (e.g. during drag)
8228
+ * get measured even when memoized (willUpdate skipped).
8229
+ */
8230
+ this.nodes.forEach(ensureDraggedNodesSnapshotted);
8153
8231
  /**
8154
8232
  * Write
8155
8233
  */
@@ -8248,7 +8326,8 @@
8248
8326
  const prevLayout = this.layout;
8249
8327
  this.layout = this.measure(false);
8250
8328
  this.layoutVersion++;
8251
- this.layoutCorrected = createBox();
8329
+ if (!this.layoutCorrected)
8330
+ this.layoutCorrected = createBox();
8252
8331
  this.isLayoutDirty = false;
8253
8332
  this.projectionDelta = undefined;
8254
8333
  this.notifyListeners("measure", this.layout.layoutBox);
@@ -8359,8 +8438,8 @@
8359
8438
  }
8360
8439
  return boxWithoutScroll;
8361
8440
  }
8362
- applyTransform(box, transformOnly = false) {
8363
- const withTransforms = createBox();
8441
+ applyTransform(box, transformOnly = false, output) {
8442
+ const withTransforms = output || createBox();
8364
8443
  copyBoxInto(withTransforms, box);
8365
8444
  for (let i = 0; i < this.path.length; i++) {
8366
8445
  const node = this.path[i];
@@ -8368,10 +8447,8 @@
8368
8447
  node.options.layoutScroll &&
8369
8448
  node.scroll &&
8370
8449
  node !== node.root) {
8371
- transformBox(withTransforms, {
8372
- x: -node.scroll.offset.x,
8373
- y: -node.scroll.offset.y,
8374
- });
8450
+ translateAxis(withTransforms.x, -node.scroll.offset.x);
8451
+ translateAxis(withTransforms.y, -node.scroll.offset.y);
8375
8452
  }
8376
8453
  if (!hasTransform(node.latestValues))
8377
8454
  continue;
@@ -8479,7 +8556,9 @@
8479
8556
  * even if no animation has started.
8480
8557
  */
8481
8558
  if (!this.targetDelta && !this.relativeTarget) {
8482
- if (relativeParent && relativeParent.layout) {
8559
+ if (this.options.layoutAnchor !== false &&
8560
+ relativeParent &&
8561
+ relativeParent.layout) {
8483
8562
  this.createRelativeTarget(relativeParent, this.layout.layoutBox, relativeParent.layout.layoutBox);
8484
8563
  }
8485
8564
  else {
@@ -8507,15 +8586,14 @@
8507
8586
  this.relativeParent &&
8508
8587
  this.relativeParent.target) {
8509
8588
  this.forceRelativeParentToResolveTarget();
8510
- calcRelativeBox(this.target, this.relativeTarget, this.relativeParent.target);
8589
+ calcRelativeBox(this.target, this.relativeTarget, this.relativeParent.target, this.options.layoutAnchor || undefined);
8511
8590
  /**
8512
8591
  * If we've only got a targetDelta, resolve it into a target
8513
8592
  */
8514
8593
  }
8515
8594
  else if (this.targetDelta) {
8516
8595
  if (Boolean(this.resumingFrom)) {
8517
- // TODO: This is creating a new object every frame
8518
- this.target = this.applyTransform(this.layout.layoutBox);
8596
+ this.applyTransform(this.layout.layoutBox, false, this.target);
8519
8597
  }
8520
8598
  else {
8521
8599
  copyBoxInto(this.target, this.layout.layoutBox);
@@ -8533,7 +8611,8 @@
8533
8611
  */
8534
8612
  if (this.attemptToResolveRelativeTarget) {
8535
8613
  this.attemptToResolveRelativeTarget = false;
8536
- if (relativeParent &&
8614
+ if (this.options.layoutAnchor !== false &&
8615
+ relativeParent &&
8537
8616
  Boolean(relativeParent.resumingFrom) ===
8538
8617
  Boolean(this.resumingFrom) &&
8539
8618
  !relativeParent.options.layoutScroll &&
@@ -8577,7 +8656,7 @@
8577
8656
  this.forceRelativeParentToResolveTarget();
8578
8657
  this.relativeTarget = createBox();
8579
8658
  this.relativeTargetOrigin = createBox();
8580
- calcRelativePosition(this.relativeTargetOrigin, layout, parentLayout);
8659
+ calcRelativePosition(this.relativeTargetOrigin, layout, parentLayout, this.options.layoutAnchor || undefined);
8581
8660
  copyBoxInto(this.relativeTarget, this.relativeTargetOrigin);
8582
8661
  }
8583
8662
  removeRelativeTarget() {
@@ -8749,7 +8828,7 @@
8749
8828
  this.layout &&
8750
8829
  this.relativeParent &&
8751
8830
  this.relativeParent.layout) {
8752
- calcRelativePosition(relativeLayout, this.layout.layoutBox, this.relativeParent.layout.layoutBox);
8831
+ calcRelativePosition(relativeLayout, this.layout.layoutBox, this.relativeParent.layout.layoutBox, this.options.layoutAnchor || undefined);
8753
8832
  mixBox(this.relativeTarget, this.relativeTargetOrigin, relativeLayout, progress);
8754
8833
  /**
8755
8834
  * If this is an unchanged relative target we can consider the
@@ -9168,10 +9247,11 @@
9168
9247
  if (relativeParent && !relativeParent.resumeFrom) {
9169
9248
  const { snapshot: parentSnapshot, layout: parentLayout } = relativeParent;
9170
9249
  if (parentSnapshot && parentLayout) {
9250
+ const anchor = node.options.layoutAnchor || undefined;
9171
9251
  const relativeSnapshot = createBox();
9172
- calcRelativePosition(relativeSnapshot, snapshot.layoutBox, parentSnapshot.layoutBox);
9252
+ calcRelativePosition(relativeSnapshot, snapshot.layoutBox, parentSnapshot.layoutBox, anchor);
9173
9253
  const relativeLayout = createBox();
9174
- calcRelativePosition(relativeLayout, layout, parentLayout.layoutBox);
9254
+ calcRelativePosition(relativeLayout, layout, parentLayout.layoutBox, anchor);
9175
9255
  if (!boxEqualsRounded(relativeSnapshot, relativeLayout)) {
9176
9256
  hasRelativeLayoutChanged = true;
9177
9257
  }
@@ -9243,9 +9323,25 @@
9243
9323
  function clearMeasurements(node) {
9244
9324
  node.clearMeasurements();
9245
9325
  }
9326
+ function forceLayoutMeasure(node) {
9327
+ node.isLayoutDirty = true;
9328
+ node.updateLayout();
9329
+ }
9246
9330
  function clearIsLayoutDirty(node) {
9247
9331
  node.isLayoutDirty = false;
9248
9332
  }
9333
+ /**
9334
+ * When a node is animation-blocked (e.g. during drag) and its component
9335
+ * didn't re-render (memoized), willUpdate() is never called so there's
9336
+ * no snapshot. Use the previous layout as a snapshot and mark dirty so
9337
+ * resetTransform/updateLayout/notifyLayoutUpdate process it normally.
9338
+ */
9339
+ function ensureDraggedNodesSnapshotted(node) {
9340
+ if (node.isAnimationBlocked && node.layout && !node.isLayoutDirty) {
9341
+ node.snapshot = node.layout;
9342
+ node.isLayoutDirty = true;
9343
+ }
9344
+ }
9249
9345
  function resetTransformStyle(node) {
9250
9346
  const { visualElement } = node.options;
9251
9347
  if (visualElement && visualElement.getProps().onBeforeLayoutMeasure) {