motion-dom 12.35.2 → 12.37.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 (44) hide show
  1. package/dist/cjs/index.js +181 -75
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/es/animation/AsyncMotionValueAnimation.mjs +23 -7
  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/keyframes/utils/unit-conversion.mjs +12 -2
  10. package/dist/es/animation/keyframes/utils/unit-conversion.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/frameloop/batcher.mjs +3 -2
  20. package/dist/es/frameloop/batcher.mjs.map +1 -1
  21. package/dist/es/frameloop/render-step.mjs +5 -3
  22. package/dist/es/frameloop/render-step.mjs.map +1 -1
  23. package/dist/es/index.mjs +1 -1
  24. package/dist/es/layout/LayoutAnimationBuilder.mjs.map +1 -1
  25. package/dist/es/projection/animation/mix-values.mjs +8 -3
  26. package/dist/es/projection/animation/mix-values.mjs.map +1 -1
  27. package/dist/es/projection/geometry/delta-apply.mjs +4 -6
  28. package/dist/es/projection/geometry/delta-apply.mjs.map +1 -1
  29. package/dist/es/projection/node/create-projection-node.mjs +31 -10
  30. package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
  31. package/dist/es/utils/is-html-element.mjs +3 -1
  32. package/dist/es/utils/is-html-element.mjs.map +1 -1
  33. package/dist/es/value/follow-value.mjs +13 -1
  34. package/dist/es/value/follow-value.mjs.map +1 -1
  35. package/dist/index.d.ts +28 -12
  36. package/dist/motion-dom.dev.js +181 -75
  37. package/dist/motion-dom.js +1 -1
  38. package/dist/size-rollup-motion-value.js +1 -1
  39. package/dist/size-rollup-motion-value.js.map +1 -1
  40. package/dist/size-rollup-style-effect.js +1 -1
  41. package/dist/size-rollup-style-effect.js.map +1 -1
  42. package/package.json +3 -3
  43. package/dist/es/animation/utils/get-final-keyframe.mjs +0 -13
  44. package/dist/es/animation/utils/get-final-keyframe.mjs.map +0 -1
package/dist/cjs/index.js CHANGED
@@ -60,8 +60,7 @@ function createRenderStep(runNextFrame, stepName) {
60
60
  const queue = addToCurrentFrame ? thisFrame : nextFrame;
61
61
  if (keepAlive)
62
62
  toKeepAlive.add(callback);
63
- if (!queue.has(callback))
64
- queue.add(callback);
63
+ queue.add(callback);
65
64
  return callback;
66
65
  },
67
66
  /**
@@ -86,7 +85,10 @@ function createRenderStep(runNextFrame, stepName) {
86
85
  return;
87
86
  }
88
87
  isProcessing = true;
89
- [thisFrame, nextFrame] = [nextFrame, thisFrame];
88
+ // Swap this frame and the next to avoid GC
89
+ const prevFrame = thisFrame;
90
+ thisFrame = nextFrame;
91
+ nextFrame = prevFrame;
90
92
  // Execute this frame
91
93
  thisFrame.forEach(triggerCallback);
92
94
  /**
@@ -125,11 +127,12 @@ function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
125
127
  }, {});
126
128
  const { setup, read, resolveKeyframes, preUpdate, update, preRender, render, postRender, } = steps;
127
129
  const processBatch = () => {
128
- const timestamp = motionUtils.MotionGlobalConfig.useManualTiming
130
+ const useManualTiming = motionUtils.MotionGlobalConfig.useManualTiming;
131
+ const timestamp = useManualTiming
129
132
  ? state.timestamp
130
133
  : performance.now();
131
134
  runNextFrame = false;
132
- if (!motionUtils.MotionGlobalConfig.useManualTiming) {
135
+ if (!useManualTiming) {
133
136
  state.delta = useDefaultElapsed
134
137
  ? 1000 / 60
135
138
  : Math.max(Math.min(timestamp - state.timestamp, maxElapsed), 1);
@@ -1321,9 +1324,9 @@ function keyframes({ duration = 300, keyframes: keyframeValues, times, ease = "e
1321
1324
  };
1322
1325
  }
1323
1326
 
1324
- const isNotNull$1 = (value) => value !== null;
1325
- function getFinalKeyframe$1(keyframes, { repeat, repeatType = "loop" }, finalKeyframe, speed = 1) {
1326
- 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);
1327
1330
  const useFirstKeyframe = speed < 0 || (repeat && repeatType !== "loop" && repeat % 2 === 1);
1328
1331
  const index = useFirstKeyframe ? 0 : resolvedKeyframes.length - 1;
1329
1332
  return !index || finalKeyframe === undefined
@@ -1388,6 +1391,14 @@ class JSAnimation extends WithPromise {
1388
1391
  * Playback speed as a factor. 0 would be stopped, -1 reverse and 2 double speed.
1389
1392
  */
1390
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
+ };
1391
1402
  /**
1392
1403
  * This method is bound to the instance to fix a pattern where
1393
1404
  * animation.stop is returned as a reference from a useEffect.
@@ -1550,9 +1561,14 @@ class JSAnimation extends WithPromise {
1550
1561
  * This prevents delay: x, duration: 0 animations from finishing
1551
1562
  * instantly.
1552
1563
  */
1553
- const state = isInDelayPhase
1554
- ? { done: false, value: keyframes[0] }
1555
- : frameGenerator.next(elapsed);
1564
+ let state;
1565
+ if (isInDelayPhase) {
1566
+ this.delayState.value = keyframes[0];
1567
+ state = this.delayState;
1568
+ }
1569
+ else {
1570
+ state = frameGenerator.next(elapsed);
1571
+ }
1556
1572
  if (mixKeyframes && !isInDelayPhase) {
1557
1573
  state.value = mixKeyframes(state.value);
1558
1574
  }
@@ -1567,7 +1583,7 @@ class JSAnimation extends WithPromise {
1567
1583
  (this.state === "finished" || (this.state === "running" && done));
1568
1584
  // TODO: The exception for inertia could be cleaner here
1569
1585
  if (isAnimationFinished && type !== inertia) {
1570
- state.value = getFinalKeyframe$1(keyframes, this.options, finalKeyframe, this.speed);
1586
+ state.value = getFinalKeyframe(keyframes, this.options, finalKeyframe, this.speed);
1571
1587
  }
1572
1588
  if (onUpdate) {
1573
1589
  onUpdate(state.value);
@@ -1862,8 +1878,18 @@ function removeNonTranslationalTransform(visualElement) {
1862
1878
  }
1863
1879
  const positionalValues = {
1864
1880
  // Dimensions
1865
- width: ({ x }, { paddingLeft = "0", paddingRight = "0" }) => x.max - x.min - parseFloat(paddingLeft) - parseFloat(paddingRight),
1866
- height: ({ y }, { paddingTop = "0", paddingBottom = "0" }) => y.max - y.min - parseFloat(paddingTop) - parseFloat(paddingBottom),
1881
+ width: ({ x }, { paddingLeft = "0", paddingRight = "0", boxSizing }) => {
1882
+ const width = x.max - x.min;
1883
+ return boxSizing === "border-box"
1884
+ ? width
1885
+ : width - parseFloat(paddingLeft) - parseFloat(paddingRight);
1886
+ },
1887
+ height: ({ y }, { paddingTop = "0", paddingBottom = "0", boxSizing }) => {
1888
+ const height = y.max - y.min;
1889
+ return boxSizing === "border-box"
1890
+ ? height
1891
+ : height - parseFloat(paddingTop) - parseFloat(paddingBottom);
1892
+ },
1867
1893
  top: (_bbox, { top }) => parseFloat(top),
1868
1894
  left: (_bbox, { left }) => parseFloat(left),
1869
1895
  bottom: ({ y }, { top }) => parseFloat(top) + (y.max - y.min),
@@ -2165,7 +2191,7 @@ class NativeAnimation extends WithPromise {
2165
2191
  this.animation.onfinish = () => {
2166
2192
  this.finishedTime = this.time;
2167
2193
  if (!pseudoElement) {
2168
- const keyframe = getFinalKeyframe$1(keyframes, this.options, finalKeyframe, this.speed);
2194
+ const keyframe = getFinalKeyframe(keyframes, this.options, finalKeyframe, this.speed);
2169
2195
  if (this.updateMotionValue) {
2170
2196
  this.updateMotionValue(keyframe);
2171
2197
  }
@@ -2471,17 +2497,42 @@ function makeAnimationInstant(options) {
2471
2497
  /**
2472
2498
  * A list of values that can be hardware-accelerated.
2473
2499
  */
2474
- const acceleratedValues$1 = new Set([
2500
+ const acceleratedValues = new Set([
2475
2501
  "opacity",
2476
2502
  "clipPath",
2477
2503
  "filter",
2478
2504
  "transform",
2479
- // TODO: Could be re-enabled now we have support for linear() easing
2505
+ // TODO: Can be accelerated but currently disabled until https://issues.chromium.org/issues/41491098 is resolved
2506
+ // or until we implement support for linear() easing.
2480
2507
  // "background-color"
2481
2508
  ]);
2509
+
2510
+ const browserColorFunctions = /^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;
2511
+ function hasBrowserOnlyColors(keyframes) {
2512
+ for (let i = 0; i < keyframes.length; i++) {
2513
+ if (typeof keyframes[i] === "string" &&
2514
+ browserColorFunctions.test(keyframes[i])) {
2515
+ return true;
2516
+ }
2517
+ }
2518
+ return false;
2519
+ }
2520
+
2521
+ const colorProperties = new Set([
2522
+ "color",
2523
+ "backgroundColor",
2524
+ "outlineColor",
2525
+ "fill",
2526
+ "stroke",
2527
+ "borderColor",
2528
+ "borderTopColor",
2529
+ "borderRightColor",
2530
+ "borderBottomColor",
2531
+ "borderLeftColor",
2532
+ ]);
2482
2533
  const supportsWaapi = /*@__PURE__*/ motionUtils.memo(() => Object.hasOwnProperty.call(Element.prototype, "animate"));
2483
2534
  function supportsBrowserAnimation(options) {
2484
- const { motionValue, name, repeatDelay, repeatType, damping, type } = options;
2535
+ const { motionValue, name, repeatDelay, repeatType, damping, type, keyframes, } = options;
2485
2536
  const subject = motionValue?.owner?.current;
2486
2537
  /**
2487
2538
  * We use this check instead of isHTMLElement() because we explicitly
@@ -2495,7 +2546,13 @@ function supportsBrowserAnimation(options) {
2495
2546
  const { onUpdate, transformTemplate } = motionValue.owner.getProps();
2496
2547
  return (supportsWaapi() &&
2497
2548
  name &&
2498
- acceleratedValues$1.has(name) &&
2549
+ /**
2550
+ * Force WAAPI for color properties with browser-only color formats
2551
+ * (oklch, oklab, lab, lch, etc.) that the JS animation path can't parse.
2552
+ */
2553
+ (acceleratedValues.has(name) ||
2554
+ (colorProperties.has(name) &&
2555
+ hasBrowserOnlyColors(keyframes))) &&
2499
2556
  (name !== "transform" || !transformTemplate) &&
2500
2557
  /**
2501
2558
  * If we're outputting values to onUpdate then we can't use WAAPI as there's
@@ -2555,9 +2612,11 @@ class AsyncMotionValueAnimation extends WithPromise {
2555
2612
  * If we can't animate this value with the resolved keyframes
2556
2613
  * then we should complete it immediately.
2557
2614
  */
2615
+ let canAnimateValue = true;
2558
2616
  if (!canAnimate(keyframes, name, type, velocity)) {
2617
+ canAnimateValue = false;
2559
2618
  if (motionUtils.MotionGlobalConfig.instantAnimations || !delay) {
2560
- onUpdate?.(getFinalKeyframe$1(keyframes, options, finalKeyframe));
2619
+ onUpdate?.(getFinalKeyframe(keyframes, options, finalKeyframe));
2561
2620
  }
2562
2621
  keyframes[0] = keyframes[keyframes.length - 1];
2563
2622
  makeAnimationInstant(options);
@@ -2592,15 +2651,29 @@ class AsyncMotionValueAnimation extends WithPromise {
2592
2651
  * Animate via WAAPI if possible. If this is a handoff animation, the optimised animation will be running via
2593
2652
  * WAAPI. Therefore, this animation must be JS to ensure it runs "under" the
2594
2653
  * optimised animation.
2654
+ *
2655
+ * Also skip WAAPI when keyframes aren't animatable, as the resolved
2656
+ * values may not be valid CSS and would trigger browser warnings.
2595
2657
  */
2596
- const useWaapi = !isHandoff && supportsBrowserAnimation(resolvedOptions);
2658
+ const useWaapi = canAnimateValue &&
2659
+ !isHandoff &&
2660
+ supportsBrowserAnimation(resolvedOptions);
2597
2661
  const element = resolvedOptions.motionValue?.owner?.current;
2598
- const animation = useWaapi
2599
- ? new NativeAnimationExtended({
2600
- ...resolvedOptions,
2601
- element,
2602
- })
2603
- : new JSAnimation(resolvedOptions);
2662
+ let animation;
2663
+ if (useWaapi) {
2664
+ try {
2665
+ animation = new NativeAnimationExtended({
2666
+ ...resolvedOptions,
2667
+ element,
2668
+ });
2669
+ }
2670
+ catch {
2671
+ animation = new JSAnimation(resolvedOptions);
2672
+ }
2673
+ }
2674
+ else {
2675
+ animation = new JSAnimation(resolvedOptions);
2676
+ }
2604
2677
  animation.finished.then(() => {
2605
2678
  this.notifyFinished();
2606
2679
  }).catch(motionUtils.noop);
@@ -2778,8 +2851,11 @@ class NativeAnimationWrapper extends NativeAnimation {
2778
2851
  const animationMaps = new WeakMap();
2779
2852
  const animationMapKey = (name, pseudoElement = "") => `${name}:${pseudoElement}`;
2780
2853
  function getAnimationMap(element) {
2781
- const map = animationMaps.get(element) || new Map();
2782
- animationMaps.set(element, map);
2854
+ let map = animationMaps.get(element);
2855
+ if (!map) {
2856
+ map = new Map();
2857
+ animationMaps.set(element, map);
2858
+ }
2783
2859
  return map;
2784
2860
  }
2785
2861
 
@@ -2871,17 +2947,6 @@ const getDefaultTransition = (valueKey, { keyframes }) => {
2871
2947
  return ease;
2872
2948
  };
2873
2949
 
2874
- const isNotNull = (value) => value !== null;
2875
- function getFinalKeyframe(keyframes, { repeat, repeatType = "loop" }, finalKeyframe) {
2876
- const resolvedKeyframes = keyframes.filter(isNotNull);
2877
- const index = repeat && repeatType !== "loop" && repeat % 2 === 1
2878
- ? 0
2879
- : resolvedKeyframes.length - 1;
2880
- return !index || finalKeyframe === undefined
2881
- ? resolvedKeyframes[index]
2882
- : finalKeyframe;
2883
- }
2884
-
2885
2950
  /**
2886
2951
  * If `transition` has `inherit: true`, shallow-merge it with
2887
2952
  * `parentTransition` (child keys win) and strip the `inherit` key.
@@ -2905,13 +2970,29 @@ function getValueTransition(transition, key) {
2905
2970
  return valueTransition;
2906
2971
  }
2907
2972
 
2973
+ const orchestrationKeys = new Set([
2974
+ "when",
2975
+ "delay",
2976
+ "delayChildren",
2977
+ "staggerChildren",
2978
+ "staggerDirection",
2979
+ "repeat",
2980
+ "repeatType",
2981
+ "repeatDelay",
2982
+ "from",
2983
+ "elapsed",
2984
+ ]);
2908
2985
  /**
2909
2986
  * Decide whether a transition is defined on a given Transition.
2910
2987
  * This filters out orchestration options and returns true
2911
2988
  * if any options are left.
2912
2989
  */
2913
- function isTransitionDefined({ when, delay: _delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, elapsed, ...transition }) {
2914
- return !!Object.keys(transition).length;
2990
+ function isTransitionDefined(transition) {
2991
+ for (const key in transition) {
2992
+ if (!orchestrationKeys.has(key))
2993
+ return true;
2994
+ }
2995
+ return false;
2915
2996
  }
2916
2997
 
2917
2998
  const animateMotionValue = (name, value, target, transition = {}, element, isHandoff) => (onComplete) => {
@@ -4043,19 +4124,6 @@ const supportsPartialKeyframes = /*@__PURE__*/ motionUtils.memo(() => {
4043
4124
  return true;
4044
4125
  });
4045
4126
 
4046
- /**
4047
- * A list of values that can be hardware-accelerated.
4048
- */
4049
- const acceleratedValues = new Set([
4050
- "opacity",
4051
- "clipPath",
4052
- "filter",
4053
- "transform",
4054
- // TODO: Can be accelerated but currently disabled until https://issues.chromium.org/issues/41491098 is resolved
4055
- // or until we implement support for linear() easing.
4056
- // "background-color"
4057
- ]);
4058
-
4059
4127
  function resolveElements(elementOrSelector, scope, selectorCache) {
4060
4128
  if (elementOrSelector == null) {
4061
4129
  return [];
@@ -4201,7 +4269,9 @@ const propEffect = /*@__PURE__*/ createEffect((subject, state, key, value) => {
4201
4269
  * that works across iframes
4202
4270
  */
4203
4271
  function isHTMLElement(element) {
4204
- return motionUtils.isObject(element) && "offsetHeight" in element;
4272
+ return (motionUtils.isObject(element) &&
4273
+ "offsetHeight" in element &&
4274
+ !("ownerSVGElement" in element));
4205
4275
  }
4206
4276
 
4207
4277
  const translateAlias$1 = {
@@ -4939,6 +5009,7 @@ function attachFollow(value, source, options = {}) {
4939
5009
  activeAnimation.stop();
4940
5010
  activeAnimation = null;
4941
5011
  }
5012
+ value.animation = undefined;
4942
5013
  };
4943
5014
  const startAnimation = () => {
4944
5015
  const currentValue = asNumber$1(value.get());
@@ -4970,8 +5041,10 @@ function attachFollow(value, source, options = {}) {
4970
5041
  // multiple calls within the same frame (e.g. rapid mouse events)
4971
5042
  const scheduleAnimation = () => {
4972
5043
  startAnimation();
5044
+ value.animation = activeAnimation ?? undefined;
4973
5045
  value["events"].animationStart?.notify();
4974
5046
  activeAnimation?.then(() => {
5047
+ value.animation = undefined;
4975
5048
  value["events"].animationComplete?.notify();
4976
5049
  });
4977
5050
  };
@@ -4981,7 +5054,16 @@ function attachFollow(value, source, options = {}) {
4981
5054
  frame.postRender(scheduleAnimation);
4982
5055
  }, stopAnimation);
4983
5056
  if (isMotionValue(source)) {
4984
- const removeSourceOnChange = source.on("change", (v) => value.set(parseValue(v, unit)));
5057
+ let skipNextAnimation = options.skipInitialAnimation === true;
5058
+ const removeSourceOnChange = source.on("change", (v) => {
5059
+ if (skipNextAnimation) {
5060
+ skipNextAnimation = false;
5061
+ value.jump(parseValue(v, unit), false);
5062
+ }
5063
+ else {
5064
+ value.set(parseValue(v, unit));
5065
+ }
5066
+ });
4985
5067
  const removeValueOnDestroy = value.on("destroy", removeSourceOnChange);
4986
5068
  return () => {
4987
5069
  removeSourceOnChange();
@@ -6261,10 +6343,8 @@ function applyTreeDeltas(box, treeScale, treePath, isSharedTransition = false) {
6261
6343
  node.options.layoutScroll &&
6262
6344
  node.scroll &&
6263
6345
  node !== node.root) {
6264
- transformBox(box, {
6265
- x: -node.scroll.offset.x,
6266
- y: -node.scroll.offset.y,
6267
- });
6346
+ translateAxis(box.x, -node.scroll.offset.x);
6347
+ translateAxis(box.y, -node.scroll.offset.y);
6268
6348
  }
6269
6349
  if (delta) {
6270
6350
  // Incoporate each ancestor's scale into a cumulative treeScale for this component
@@ -6291,8 +6371,8 @@ function applyTreeDeltas(box, treeScale, treePath, isSharedTransition = false) {
6291
6371
  }
6292
6372
  }
6293
6373
  function translateAxis(axis, distance) {
6294
- axis.min = axis.min + distance;
6295
- axis.max = axis.max + distance;
6374
+ axis.min += distance;
6375
+ axis.max += distance;
6296
6376
  }
6297
6377
  /**
6298
6378
  * Apply a transform to an axis from the latest resolved motion values.
@@ -7459,8 +7539,13 @@ function buildProjectionTransform(delta, treeScale, latestTransform) {
7459
7539
  return transform || "none";
7460
7540
  }
7461
7541
 
7462
- const borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
7463
- const numBorders = borders.length;
7542
+ const borderLabels = [
7543
+ "borderTopLeftRadius",
7544
+ "borderTopRightRadius",
7545
+ "borderBottomLeftRadius",
7546
+ "borderBottomRightRadius",
7547
+ ];
7548
+ const numBorders = borderLabels.length;
7464
7549
  const asNumber = (value) => typeof value === "string" ? parseFloat(value) : value;
7465
7550
  const isPx = (value) => typeof value === "number" || px.test(value);
7466
7551
  function mixValues(target, follow, lead, progress, shouldCrossfadeOpacity, isOnlyMember) {
@@ -7475,7 +7560,7 @@ function mixValues(target, follow, lead, progress, shouldCrossfadeOpacity, isOnl
7475
7560
  * Mix border radius
7476
7561
  */
7477
7562
  for (let i = 0; i < numBorders; i++) {
7478
- const borderLabel = `border${borders[i]}Radius`;
7563
+ const borderLabel = borderLabels[i];
7479
7564
  let followRadius = getRadius(follow, borderLabel);
7480
7565
  let leadRadius = getRadius(lead, borderLabel);
7481
7566
  if (followRadius === undefined && leadRadius === undefined)
@@ -8120,6 +8205,11 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
8120
8205
  }
8121
8206
  else {
8122
8207
  this.isUpdating = false;
8208
+ /**
8209
+ * Ensure animation-blocked nodes (e.g. during drag)
8210
+ * get measured even when memoized (willUpdate skipped).
8211
+ */
8212
+ this.nodes.forEach(ensureDraggedNodesSnapshotted);
8123
8213
  /**
8124
8214
  * Write
8125
8215
  */
@@ -8218,7 +8308,8 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
8218
8308
  const prevLayout = this.layout;
8219
8309
  this.layout = this.measure(false);
8220
8310
  this.layoutVersion++;
8221
- this.layoutCorrected = createBox();
8311
+ if (!this.layoutCorrected)
8312
+ this.layoutCorrected = createBox();
8222
8313
  this.isLayoutDirty = false;
8223
8314
  this.projectionDelta = undefined;
8224
8315
  this.notifyListeners("measure", this.layout.layoutBox);
@@ -8329,8 +8420,8 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
8329
8420
  }
8330
8421
  return boxWithoutScroll;
8331
8422
  }
8332
- applyTransform(box, transformOnly = false) {
8333
- const withTransforms = createBox();
8423
+ applyTransform(box, transformOnly = false, output) {
8424
+ const withTransforms = output || createBox();
8334
8425
  copyBoxInto(withTransforms, box);
8335
8426
  for (let i = 0; i < this.path.length; i++) {
8336
8427
  const node = this.path[i];
@@ -8338,10 +8429,8 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
8338
8429
  node.options.layoutScroll &&
8339
8430
  node.scroll &&
8340
8431
  node !== node.root) {
8341
- transformBox(withTransforms, {
8342
- x: -node.scroll.offset.x,
8343
- y: -node.scroll.offset.y,
8344
- });
8432
+ translateAxis(withTransforms.x, -node.scroll.offset.x);
8433
+ translateAxis(withTransforms.y, -node.scroll.offset.y);
8345
8434
  }
8346
8435
  if (!hasTransform(node.latestValues))
8347
8436
  continue;
@@ -8484,8 +8573,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
8484
8573
  }
8485
8574
  else if (this.targetDelta) {
8486
8575
  if (Boolean(this.resumingFrom)) {
8487
- // TODO: This is creating a new object every frame
8488
- this.target = this.applyTransform(this.layout.layoutBox);
8576
+ this.applyTransform(this.layout.layoutBox, false, this.target);
8489
8577
  }
8490
8578
  else {
8491
8579
  copyBoxInto(this.target, this.layout.layoutBox);
@@ -9095,6 +9183,12 @@ function notifyLayoutUpdate(node) {
9095
9183
  axisSnapshot.max = axisSnapshot.min + length;
9096
9184
  });
9097
9185
  }
9186
+ else if (animationType === "x" || animationType === "y") {
9187
+ const snapAxis = animationType === "x" ? "y" : "x";
9188
+ copyAxisInto(isShared
9189
+ ? snapshot.measuredBox[snapAxis]
9190
+ : snapshot.layoutBox[snapAxis], layout[snapAxis]);
9191
+ }
9098
9192
  else if (shouldAnimatePositionOnly(animationType, snapshot.layoutBox, layout)) {
9099
9193
  eachAxis((axis) => {
9100
9194
  const axisSnapshot = isShared
@@ -9210,6 +9304,18 @@ function clearMeasurements(node) {
9210
9304
  function clearIsLayoutDirty(node) {
9211
9305
  node.isLayoutDirty = false;
9212
9306
  }
9307
+ /**
9308
+ * When a node is animation-blocked (e.g. during drag) and its component
9309
+ * didn't re-render (memoized), willUpdate() is never called so there's
9310
+ * no snapshot. Use the previous layout as a snapshot and mark dirty so
9311
+ * resetTransform/updateLayout/notifyLayoutUpdate process it normally.
9312
+ */
9313
+ function ensureDraggedNodesSnapshotted(node) {
9314
+ if (node.isAnimationBlocked && node.layout && !node.isLayoutDirty) {
9315
+ node.snapshot = node.layout;
9316
+ node.isLayoutDirty = true;
9317
+ }
9318
+ }
9213
9319
  function resetTransformStyle(node) {
9214
9320
  const { visualElement } = node.options;
9215
9321
  if (visualElement && visualElement.getProps().onBeforeLayoutMeasure) {