motion-dom 14.7.1 → 14.9.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 (56) hide show
  1. package/dist/cjs/index.js +408 -168
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/es/animation/JSAnimation.mjs +7 -1
  4. package/dist/es/animation/JSAnimation.mjs.map +1 -1
  5. package/dist/es/animation/generators/keyframes.mjs +12 -3
  6. package/dist/es/animation/generators/keyframes.mjs.map +1 -1
  7. package/dist/es/animation/utils/is-transition-defined.mjs +1 -0
  8. package/dist/es/animation/utils/is-transition-defined.mjs.map +1 -1
  9. package/dist/es/animation/waapi/supports/waapi.mjs +3 -1
  10. package/dist/es/animation/waapi/supports/waapi.mjs.map +1 -1
  11. package/dist/es/animation/waapi/transforms/TransformAnimation.mjs +31 -35
  12. package/dist/es/animation/waapi/transforms/TransformAnimation.mjs.map +1 -1
  13. package/dist/es/animation/waapi/utils/needs-mixer.mjs +11 -0
  14. package/dist/es/animation/waapi/utils/needs-mixer.mjs.map +1 -0
  15. package/dist/es/effects/svg/index.mjs +14 -0
  16. package/dist/es/effects/svg/index.mjs.map +1 -1
  17. package/dist/es/gestures/drag/VisualElementDragControls.mjs +35 -19
  18. package/dist/es/gestures/drag/VisualElementDragControls.mjs.map +1 -1
  19. package/dist/es/gestures/drag/index.mjs +4 -3
  20. package/dist/es/gestures/drag/index.mjs.map +1 -1
  21. package/dist/es/gestures/drag/projection.mjs +85 -0
  22. package/dist/es/gestures/drag/projection.mjs.map +1 -0
  23. package/dist/es/index.mjs +1 -1
  24. package/dist/es/layout/LayoutAnimationBuilder.mjs +34 -51
  25. package/dist/es/layout/LayoutAnimationBuilder.mjs.map +1 -1
  26. package/dist/es/layout/visual-element.mjs +48 -0
  27. package/dist/es/layout/visual-element.mjs.map +1 -0
  28. package/dist/es/projection/geometry/round.mjs +25 -0
  29. package/dist/es/projection/geometry/round.mjs.map +1 -0
  30. package/dist/es/projection/node/DocumentProjectionNode.mjs +2 -8
  31. package/dist/es/projection/node/DocumentProjectionNode.mjs.map +1 -1
  32. package/dist/es/projection/node/create-projection-node.mjs +68 -48
  33. package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
  34. package/dist/es/projection/utils/measure.mjs +5 -1
  35. package/dist/es/projection/utils/measure.mjs.map +1 -1
  36. package/dist/es/render/VisualElement.mjs +3 -2
  37. package/dist/es/render/VisualElement.mjs.map +1 -1
  38. package/dist/es/stats/buffer.mjs +1 -0
  39. package/dist/es/stats/buffer.mjs.map +1 -1
  40. package/dist/es/stats/index.mjs +31 -0
  41. package/dist/es/stats/index.mjs.map +1 -1
  42. package/dist/es/utils/interpolate.mjs +3 -2
  43. package/dist/es/utils/interpolate.mjs.map +1 -1
  44. package/dist/es/utils/is-ref-object.mjs +8 -0
  45. package/dist/es/utils/is-ref-object.mjs.map +1 -0
  46. package/dist/es/utils/transform.mjs.map +1 -1
  47. package/dist/es/value/index.mjs +10 -1
  48. package/dist/es/value/index.mjs.map +1 -1
  49. package/dist/index.d.ts +2048 -1931
  50. package/dist/motion-dom.dev.js +408 -168
  51. package/dist/motion-dom.js +1 -1
  52. package/dist/size-rollup-motion-value.js +1 -1
  53. package/dist/size-rollup-motion-value.js.map +1 -1
  54. package/dist/size-rollup-style-effect.js +1 -1
  55. package/dist/size-rollup-style-effect.js.map +1 -1
  56. package/package.json +2 -2
package/dist/cjs/index.js CHANGED
@@ -1311,10 +1311,11 @@ function inertia({ keyframes, velocity = 0.0, power = 0.8, timeConstant = 325, b
1311
1311
 
1312
1312
  function createMixers(output, ease, customMixer) {
1313
1313
  const mixers = [];
1314
- const mixerFactory = customMixer || motionUtils.MotionGlobalConfig.mix || mix;
1314
+ const mixerFactory = motionUtils.MotionGlobalConfig.mix || mix;
1315
1315
  const numMixers = output.length - 1;
1316
1316
  for (let i = 0; i < numMixers; i++) {
1317
- let mixer = mixerFactory(output[i], output[i + 1]);
1317
+ let mixer = customMixer?.(output[i], output[i + 1]) ||
1318
+ mixerFactory(output[i], output[i + 1]);
1318
1319
  if (ease) {
1319
1320
  const easingFunction = Array.isArray(ease) ? ease[i] || motionUtils.noop : ease;
1320
1321
  mixer = motionUtils.pipe(easingFunction, mixer);
@@ -1401,7 +1402,13 @@ function convertOffsetToTimes(offset, duration) {
1401
1402
  function defaultEasing(values, easing) {
1402
1403
  return values.map(() => easing || motionUtils.easeInOut).splice(0, values.length - 1);
1403
1404
  }
1404
- function keyframes({ duration = 300, keyframes: keyframeValues, times, ease = "easeInOut", }) {
1405
+ function keyframes({ duration = 300, keyframes: keyframeValues, times, ease = "easeInOut", mixer: transitionMixer, }) {
1406
+ /**
1407
+ * A mixer only blends values that aren't numbers. Numbers blend as
1408
+ * usual, as they do in springs, and so do the progress animations
1409
+ * behind layout and path animations, which take the same transition.
1410
+ */
1411
+ const customMixer = typeof keyframeValues[0] === "number" ? undefined : transitionMixer;
1405
1412
  /**
1406
1413
  * Easing functions can be externally defined as strings. Here we convert them
1407
1414
  * into actual functions.
@@ -1418,9 +1425,11 @@ function keyframes({ duration = 300, keyframes: keyframeValues, times, ease = "e
1418
1425
  value: keyframeValues[0],
1419
1426
  };
1420
1427
  /**
1421
- * Fast setup path for two keyframes one easing.
1428
+ * Fast setup path for two keyframes one easing. interpolate() handles
1429
+ * a custom mixer, and falls back to the usual one where it declines.
1422
1430
  */
1423
- if (keyframeValues.length === 2 &&
1431
+ if (!customMixer &&
1432
+ keyframeValues.length === 2 &&
1424
1433
  !Array.isArray(easingFunctions) &&
1425
1434
  (!times ||
1426
1435
  times.length !== 2 ||
@@ -1453,6 +1462,7 @@ function keyframes({ duration = 300, keyframes: keyframeValues, times, ease = "e
1453
1462
  ease: Array.isArray(easingFunctions)
1454
1463
  ? easingFunctions
1455
1464
  : defaultEasing(keyframeValues, easingFunctions),
1465
+ mixer: customMixer,
1456
1466
  });
1457
1467
  return {
1458
1468
  calculatedDuration: duration,
@@ -1661,9 +1671,15 @@ class JSAnimation extends WithPromise {
1661
1671
  generatorFactory !== keyframes) {
1662
1672
  motionUtils.invariant(keyframes$1.length <= 2, `Only two keyframes currently supported with spring and inertia animations. Trying to animate ${keyframes$1}`, "spring-two-frames");
1663
1673
  }
1674
+ /**
1675
+ * This runs again when a spring is flattened to attach it to a
1676
+ * timeline, and the keyframes generator blends values itself.
1677
+ */
1678
+ this.mixKeyframes = undefined;
1664
1679
  if (generatorFactory !== keyframes &&
1665
1680
  typeof keyframes$1[0] !== "number") {
1666
- this.mixKeyframes = motionUtils.pipe(percentToProgress, mix(keyframes$1[0], keyframes$1[1]));
1681
+ this.mixKeyframes = motionUtils.pipe(percentToProgress, options.mixer?.(keyframes$1[0], keyframes$1[1]) ||
1682
+ mix(keyframes$1[0], keyframes$1[1]));
1667
1683
  keyframes$1 = [0, 100];
1668
1684
  }
1669
1685
  const generator = generatorFactory(keyframes$1 === options.keyframes
@@ -3017,6 +3033,15 @@ function hasBrowserOnlyColors(keyframes) {
3017
3033
  return false;
3018
3034
  }
3019
3035
 
3036
+ /**
3037
+ * Whether an animation needs its mixer, which WAAPI can't call. Numbers
3038
+ * blend as usual, and an animation whose mixer declines every pair runs
3039
+ * as it would without one.
3040
+ */
3041
+ const needsMixer = ({ mixer, keyframes }) => mixer &&
3042
+ typeof keyframes[0] !== "number" &&
3043
+ keyframes.some((keyframe, i) => i && mixer(keyframes[i - 1], keyframe));
3044
+
3020
3045
  const colorProperties = new Set([
3021
3046
  "color",
3022
3047
  "backgroundColor",
@@ -3076,7 +3101,8 @@ function supportsBrowserAnimation(options) {
3076
3101
  !repeatDelay &&
3077
3102
  repeatType !== "mirror" &&
3078
3103
  damping !== 0 &&
3079
- type !== "inertia");
3104
+ type !== "inertia" &&
3105
+ !needsMixer(options));
3080
3106
  }
3081
3107
 
3082
3108
  /**
@@ -3175,18 +3201,21 @@ const churnWindow = 100;
3175
3201
  * Named easings that are the same cubic-bezier in JS and CSS.
3176
3202
  */
3177
3203
  const isNativeEasing = (ease) => /^(linear|ease(In|Out|InOut))$/.test(ease);
3204
+ /**
3205
+ * Whether two eased progresses match. False if either is NaN.
3206
+ */
3207
+ const isNear$1 = (a, b) => Math.abs(a - b) <= easingTolerance;
3178
3208
  const byTime = (a, b) => a - b;
3179
3209
  /**
3180
3210
  * n + 1 evenly spaced timestamps, from one timestamp to another.
3181
3211
  */
3182
- const spread = (from, to, n) => {
3183
- const result = [];
3184
- for (let i = 0; i <= n; i++)
3185
- result.push(mixNumber$1(from, to, i / n));
3186
- return result;
3187
- };
3212
+ const spread = (from, to, n) => defaultOffset(Array(n + 1)).map((p) => mixNumber$1(from, to, p));
3188
3213
  const getOwner = (options) => options.motionValue.owner;
3189
3214
  const getGroup = (element) => transformGroups.get(element);
3215
+ /**
3216
+ * Whether an animation has ended, so can leave its group.
3217
+ */
3218
+ const hasEnded = ({ state }) => state === "idle" || state === "finished";
3190
3219
  const read = (owner, key) => owner.latestValues ? owner.latestValues[key] : owner.getValue(key)?.get();
3191
3220
  /**
3192
3221
  * Whether this animation should join its element's transform group.
@@ -3225,7 +3254,12 @@ function canAccelerateTransform(options) {
3225
3254
  /**
3226
3255
  * Layout animations write transform every frame.
3227
3256
  */
3228
- !owner.projection?.isProjecting());
3257
+ !owner.projection?.isProjecting() &&
3258
+ /**
3259
+ * A mixer that blends these values makes them every frame. It's
3260
+ * asked last, as it's user code.
3261
+ */
3262
+ !needsMixer(options));
3229
3263
  }
3230
3264
  class TransformAnimation extends JSAnimation {
3231
3265
  constructor(options) {
@@ -3582,9 +3616,8 @@ function createGroup(owner) {
3582
3616
  let shared;
3583
3617
  let progressAt;
3584
3618
  for (const track of moving) {
3585
- const values = at.map((t) => track.numberAt(t));
3586
- const [first] = values;
3587
- const changes = values.map((value) => value - first);
3619
+ const first = track.numberAt(from);
3620
+ const changes = at.map((t) => track.numberAt(t) - first);
3588
3621
  const end = changes[changes.length - 1];
3589
3622
  /**
3590
3623
  * A value that ends only a tiny way from where it started, as
@@ -3598,25 +3631,20 @@ function createGroup(owner) {
3598
3631
  : end;
3599
3632
  const progress = changes.map((change) => range ? change / range : change);
3600
3633
  /**
3601
- * A value that doesn't change, like one still in its delay,
3602
- * fits any easing. One that changes but ends where it started
3603
- * fits none.
3634
+ * The first value that moves sets the easing, and every other
3635
+ * one must follow it. A value that doesn't change, like one
3636
+ * still in its delay, fits any easing. One that changes but
3637
+ * ends where it started fits none.
3604
3638
  */
3605
- if (!range) {
3606
- if (progress.some((p) => !(Math.abs(p) <= easingTolerance))) {
3607
- return;
3608
- }
3609
- }
3610
- else if (!shared) {
3639
+ if (range && !shared) {
3611
3640
  shared = progress;
3612
3641
  progressAt = (t) => (track.numberAt(t) - first) / range;
3613
3642
  }
3614
- else if (progress.some((p, i) => !(Math.abs(p - shared[i]) <= easingTolerance))) {
3643
+ else if (progress.some((p, i) => !isNear$1(p, range && shared[i]))) {
3615
3644
  return;
3616
3645
  }
3617
3646
  }
3618
- if (!shared ||
3619
- shared.every((p, i) => Math.abs(p - position(at[i])) <= easingTolerance)) {
3647
+ if (!shared || shared.every((p, i) => isNear$1(p, position(at[i])))) {
3620
3648
  return "linear";
3621
3649
  }
3622
3650
  /**
@@ -3703,7 +3731,7 @@ function createGroup(owner) {
3703
3731
  /**
3704
3732
  * A WAAPI animation of the composed transform between two timestamps.
3705
3733
  */
3706
- const run = (moving, from, to, options = { fill: "both" }, settled, nativeEasing) => {
3734
+ const run = (moving, from, to, nativeEasing, options = { fill: "both" }, settled) => {
3707
3735
  const bounds = moving.flatMap((track) => track.boundaries(from, to));
3708
3736
  const easing = nativeEasing || getEasing(moving, from, to, bounds);
3709
3737
  const times = easing ? [from, to] : sample(moving, from, to, bounds);
@@ -3789,9 +3817,7 @@ function createGroup(owner) {
3789
3817
  if (byKey.has(key))
3790
3818
  return true;
3791
3819
  const value = (statics[key] = read(owner, key));
3792
- return (value !== undefined &&
3793
- parseFloat(value) !==
3794
- (key.startsWith("scale") ? 1 : 0));
3820
+ return value !== undefined && !isDefaultTransform(key, value);
3795
3821
  });
3796
3822
  stop(false);
3797
3823
  /**
@@ -3802,7 +3828,7 @@ function createGroup(owner) {
3802
3828
  try {
3803
3829
  if (tween && tween[1] > now) {
3804
3830
  const [from, to, easing] = tween;
3805
- add(run(moving, from, to, undefined, undefined, easing), from - now, to - from);
3831
+ add(run(moving, from, to, easing), from - now, to - from);
3806
3832
  }
3807
3833
  else if (end > now) {
3808
3834
  add(run(moving, now, end), 0, end - now);
@@ -3819,7 +3845,7 @@ function createGroup(owner) {
3819
3845
  * seamlessly, and start it part way through.
3820
3846
  */
3821
3847
  const from = cycleStart + Math.floor((end - cycleStart) / cycle) * cycle;
3822
- add(run(looping, from, from + cycle, {
3848
+ add(run(looping, from, from + cycle, undefined, {
3823
3849
  iterations: Infinity,
3824
3850
  iterationStart: (end - from) / cycle,
3825
3851
  /**
@@ -3958,10 +3984,7 @@ function createGroup(owner) {
3958
3984
  isScheduled = false;
3959
3985
  if (isEnded)
3960
3986
  return;
3961
- tracks.forEach(({ state }, track) => {
3962
- if (state === "idle" || state === "finished")
3963
- tracks.delete(track);
3964
- });
3987
+ tracks.forEach((track) => hasEnded(track) && tracks.delete(track));
3965
3988
  if (end())
3966
3989
  return;
3967
3990
  for (const track of tracks) {
@@ -4021,9 +4044,7 @@ function createGroup(owner) {
4021
4044
  * Only drop the stopped animation. Others can be idle because
4022
4045
  * they're part way through play(), and are about to run.
4023
4046
  */
4024
- const { state } = track;
4025
- if (state === "idle" || state === "finished")
4026
- tracks.delete(track);
4047
+ hasEnded(track) && tracks.delete(track);
4027
4048
  end() || group.schedule(true);
4028
4049
  },
4029
4050
  /**
@@ -4580,10 +4601,19 @@ class MotionValue {
4580
4601
  * effects, and resets velocity to `0`.
4581
4602
  */
4582
4603
  jump(v, endAnimation = true) {
4604
+ if (endAnimation) {
4605
+ /**
4606
+ * Stop first, as stopping a running animation can set the
4607
+ * value it's showing, which would replace v. Marking the value
4608
+ * as updated now skips a JS animation's catch-up tick on stop,
4609
+ * which could otherwise complete it.
4610
+ */
4611
+ this.updatedAt = time.now();
4612
+ this.stop();
4613
+ }
4583
4614
  this.updateAndNotify(v);
4584
4615
  this.prev = v;
4585
4616
  this.prevUpdatedAt = this.prevFrameValue = undefined;
4586
- endAnimation && this.stop();
4587
4617
  this.stopPassiveEffect?.();
4588
4618
  }
4589
4619
  dirty() {
@@ -4802,6 +4832,7 @@ const orchestrationKeys = new Set([
4802
4832
  "from",
4803
4833
  "elapsed",
4804
4834
  "out",
4835
+ "mixer",
4805
4836
  ]);
4806
4837
  /**
4807
4838
  * Decide whether a transition is defined on a given Transition.
@@ -6361,6 +6392,20 @@ const addSVGValue = (element, state, key, value) => {
6361
6392
  else if (key.startsWith("attr")) {
6362
6393
  return addAttrValue(element, state, key, value, convertAttrKey(key));
6363
6394
  }
6395
+ else if (key === "d") {
6396
+ /**
6397
+ * `d` is a CSS property in Chrome and Firefox, but only as
6398
+ * `path(...)`, so path data goes to the attribute, taken out of
6399
+ * `path(...)` if it's written that way. Path data itself has no
6400
+ * quotes or brackets.
6401
+ */
6402
+ return state.set(key, value, () => {
6403
+ const d = value.get()?.replace(/path\(|["')]/g, "");
6404
+ d === undefined
6405
+ ? element.removeAttribute(key)
6406
+ : element.setAttribute(key, d);
6407
+ });
6408
+ }
6364
6409
  /**
6365
6410
  * Transforms and origins aren't CSS properties (bar `x`/`y` in some
6366
6411
  * browsers), so check them by name rather than `key in element.style`.
@@ -6617,6 +6662,10 @@ function measurePageBox(element, rootProjectionNode, transformPagePoint) {
6617
6662
  }
6618
6663
  return viewportBox;
6619
6664
  }
6665
+ const measureDocumentScroll = () => ({
6666
+ x: document.documentElement.scrollLeft || document.body?.scrollLeft || 0,
6667
+ y: document.documentElement.scrollTop || document.body?.scrollTop || 0,
6668
+ });
6620
6669
 
6621
6670
  const noProps = {};
6622
6671
  const getElementEffect = (element) => (isSVGElement(element)
@@ -6793,6 +6842,7 @@ function isForcedMotionValue(key, { layout, layoutId }) {
6793
6842
  const statsBuffer = {
6794
6843
  value: null,
6795
6844
  addProjectionMetrics: null,
6845
+ countProjection: undefined,
6796
6846
  };
6797
6847
 
6798
6848
  /**
@@ -6815,6 +6865,12 @@ function delayInSeconds(callback, timeout) {
6815
6865
  return delay(callback, motionUtils.secondsToMilliseconds(timeout));
6816
6866
  }
6817
6867
 
6868
+ function isRefObject(ref) {
6869
+ return (ref &&
6870
+ typeof ref === "object" &&
6871
+ Object.prototype.hasOwnProperty.call(ref, "current"));
6872
+ }
6873
+
6818
6874
  /**
6819
6875
  * Checks if an element is specifically an SVGSVGElement (the root SVG element)
6820
6876
  * in a way that works across iframes
@@ -7029,6 +7085,27 @@ function removeBoxTransforms(box, transforms, originBox, sourceBox) {
7029
7085
  removeAxisTransforms(box.y, transforms, yKeys, originBox?.y, sourceBox?.y);
7030
7086
  }
7031
7087
 
7088
+ const userAgentContains = (string) => typeof navigator !== "undefined" &&
7089
+ navigator.userAgent &&
7090
+ navigator.userAgent.toLowerCase().includes(string);
7091
+ /**
7092
+ * Measured bounding boxes must be rounded in Safari and
7093
+ * left untouched in Chrome, otherwise non-integer layouts within scaled-up elements
7094
+ * can appear to jump.
7095
+ */
7096
+ const roundPoint = userAgentContains("applewebkit/") && !userAgentContains("chrome/")
7097
+ ? Math.round
7098
+ : motionUtils.noop;
7099
+ function roundAxis(axis) {
7100
+ // Round to the nearest .5 pixels to support subpixel layouts
7101
+ axis.min = roundPoint(axis.min);
7102
+ axis.max = roundPoint(axis.max);
7103
+ }
7104
+ function roundBox(box) {
7105
+ roundAxis(box.x);
7106
+ roundAxis(box.y);
7107
+ }
7108
+
7032
7109
  const createAxisDelta = () => ({
7033
7110
  translate: 0,
7034
7111
  scale: 1,
@@ -7325,11 +7402,6 @@ const globalProjectionState = {
7325
7402
  hasEverUpdated: false,
7326
7403
  };
7327
7404
 
7328
- const metrics = {
7329
- nodes: 0,
7330
- calculatedTargetDeltas: 0,
7331
- calculatedProjections: 0,
7332
- };
7333
7405
  /**
7334
7406
  * Transforms that distort an element's layout, so must be reset before measuring.
7335
7407
  */
@@ -7377,6 +7449,13 @@ function cancelTreeOptimisedTransformAnimations(projectionNode) {
7377
7449
  cancelTreeOptimisedTransformAnimations(parent);
7378
7450
  }
7379
7451
  }
7452
+ function getClosestProjectingNode(visualElement) {
7453
+ if (!visualElement)
7454
+ return undefined;
7455
+ return visualElement.options.allowProjection !== false
7456
+ ? visualElement.projection
7457
+ : getClosestProjectingNode(visualElement.parent);
7458
+ }
7380
7459
  function createProjectionNode({ attachResizeListener, defaultParent, measureScroll, checkIsScrollRoot, resetTransform, }) {
7381
7460
  /**
7382
7461
  * Correctors registered via addScaleCorrector before projection loaded
@@ -7389,6 +7468,57 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
7389
7468
  ...scaleCorrectors,
7390
7469
  });
7391
7470
  return class ProjectionNode {
7471
+ /**
7472
+ * Create the projection node of a `motion` component's VisualElement,
7473
+ * from its props. This runs while the component renders, before its
7474
+ * children. It's here rather than in the component so React
7475
+ * bundles only include it with the features that supply a
7476
+ * ProjectionNode. Vanilla bundles that use the projection node
7477
+ * (drag(), animateLayout()) include it too, as a class static
7478
+ * can't be tree-shaken.
7479
+ */
7480
+ static create(visualElement, props, initialPromotionConfig) {
7481
+ const { layoutId, layout, drag, dragConstraints, layoutScroll, layoutRoot, layoutAnchor, layoutCrossfade, } = props;
7482
+ const projection = (visualElement.projection = new this(visualElement.latestValues, props["data-framer-portal-id"]
7483
+ ? undefined
7484
+ : getClosestProjectingNode(visualElement.parent)));
7485
+ projection.setOptions({
7486
+ layoutId,
7487
+ layout,
7488
+ alwaysMeasureLayout: Boolean(drag) ||
7489
+ (dragConstraints && isRefObject(dragConstraints)),
7490
+ visualElement,
7491
+ /**
7492
+ * TODO: Update options in an effect. This could be tricky as it'll be too late
7493
+ * to update by the time layout animations run.
7494
+ * We also need to fix this safeToRemove by linking it up to the one returned by usePresence,
7495
+ * ensuring it gets called if there's no potential layout animations.
7496
+ *
7497
+ */
7498
+ animationType: typeof layout === "string" ? layout : "both",
7499
+ initialPromotionConfig,
7500
+ crossfade: layoutCrossfade,
7501
+ layoutScroll,
7502
+ layoutRoot,
7503
+ layoutAnchor,
7504
+ });
7505
+ /**
7506
+ * This node will take over from its layoutId's current lead, so snapshot
7507
+ * the lead now, while rendering. By the time the lead unmounts (or this
7508
+ * node mounts) React may already have committed DOM changes that come
7509
+ * before it in the tree, like a sibling changing height, and a snapshot
7510
+ * taken then starts the animation from a position never seen on screen.
7511
+ *
7512
+ * If React discards this render (e.g. it suspends), nothing else
7513
+ * completes the update, so check it after the next frame as an
7514
+ * unmounting node does.
7515
+ */
7516
+ const lead = projection.getStack()?.lead;
7517
+ if (lead && !projection.root.isUpdateBlocked()) {
7518
+ lead.willUpdate();
7519
+ lead.scheduleCheckAfterUnmount();
7520
+ }
7521
+ }
7392
7522
  constructor(latestValues = {}, parent = defaultParent?.()) {
7393
7523
  /**
7394
7524
  * A unique ID generated for every projection node.
@@ -7501,23 +7631,14 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
7501
7631
  */
7502
7632
  this.updateProjection = () => {
7503
7633
  this.projectionUpdateScheduled = false;
7504
- /**
7505
- * Reset debug counts. Manually resetting rather than creating a new
7506
- * object each frame.
7507
- */
7508
- if (statsBuffer.value) {
7509
- metrics.nodes =
7510
- metrics.calculatedTargetDeltas =
7511
- metrics.calculatedProjections =
7512
- 0;
7513
- }
7514
7634
  this.nodes.forEach(propagateDirtyNodes);
7515
7635
  this.nodes.forEach(resolveTargetDelta);
7516
7636
  this.nodes.forEach(calcProjection);
7517
7637
  this.nodes.forEach(cleanDirtyNodes);
7518
- if (statsBuffer.addProjectionMetrics) {
7519
- statsBuffer.addProjectionMetrics(metrics);
7520
- }
7638
+ /**
7639
+ * Record this frame's debug counts, if recordStats() is running.
7640
+ */
7641
+ statsBuffer.countProjection?.();
7521
7642
  };
7522
7643
  /**
7523
7644
  * Frame calculations
@@ -8233,9 +8354,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
8233
8354
  /**
8234
8355
  * Increase debug counter for resolved target deltas
8235
8356
  */
8236
- if (statsBuffer.value) {
8237
- metrics.calculatedTargetDeltas++;
8238
- }
8357
+ statsBuffer.countProjection?.(1); // calculatedTargetDeltas
8239
8358
  }
8240
8359
  getClosestProjectingParent() {
8241
8360
  if (!this.parent ||
@@ -8383,9 +8502,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
8383
8502
  /**
8384
8503
  * Increase debug counter for recalculated projections
8385
8504
  */
8386
- if (statsBuffer.value) {
8387
- metrics.calculatedProjections++;
8388
- }
8505
+ statsBuffer.countProjection?.(2); // calculatedProjections
8389
8506
  }
8390
8507
  hide() {
8391
8508
  this.isVisible = false;
@@ -8912,9 +9029,7 @@ function propagateDirtyNodes(node) {
8912
9029
  /**
8913
9030
  * Increase debug counter for nodes encountered this frame
8914
9031
  */
8915
- if (statsBuffer.value) {
8916
- metrics.nodes++;
8917
- }
9032
+ statsBuffer.countProjection?.(0); // nodes
8918
9033
  if (!node.parent)
8919
9034
  return;
8920
9035
  /**
@@ -9045,26 +9160,6 @@ const defaultLayoutTransition = {
9045
9160
  duration: 0.45,
9046
9161
  ease: [0.4, 0, 0.1, 1],
9047
9162
  };
9048
- const userAgentContains = (string) => typeof navigator !== "undefined" &&
9049
- navigator.userAgent &&
9050
- navigator.userAgent.toLowerCase().includes(string);
9051
- /**
9052
- * Measured bounding boxes must be rounded in Safari and
9053
- * left untouched in Chrome, otherwise non-integer layouts within scaled-up elements
9054
- * can appear to jump.
9055
- */
9056
- const roundPoint = userAgentContains("applewebkit/") && !userAgentContains("chrome/")
9057
- ? Math.round
9058
- : motionUtils.noop;
9059
- function roundAxis(axis) {
9060
- // Round to the nearest .5 pixels to support subpixel layouts
9061
- axis.min = roundPoint(axis.min);
9062
- axis.max = roundPoint(axis.max);
9063
- }
9064
- function roundBox(box) {
9065
- roundAxis(box.x);
9066
- roundAxis(box.y);
9067
- }
9068
9163
  /**
9069
9164
  * Align an axis to the start of another, keeping the length of a layout axis.
9070
9165
  * The length is read first, as output can be the layout axis itself.
@@ -9089,14 +9184,7 @@ function addDomEvent(target, eventName, handler, options = { passive: true }) {
9089
9184
  const DocumentProjectionNode =
9090
9185
  /* @__PURE__ */ createProjectionNode({
9091
9186
  attachResizeListener: (ref, notify) => addDomEvent(ref, "resize", notify),
9092
- measureScroll: () => ({
9093
- x: document.documentElement.scrollLeft ||
9094
- document.body?.scrollLeft ||
9095
- 0,
9096
- y: document.documentElement.scrollTop ||
9097
- document.body?.scrollTop ||
9098
- 0,
9099
- }),
9187
+ measureScroll: measureDocumentScroll,
9100
9188
  checkIsScrollRoot: () => true,
9101
9189
  });
9102
9190
 
@@ -9398,9 +9486,10 @@ class VisualElement {
9398
9486
  /**
9399
9487
  * If this element has been mounted before (e.g. after a Suspense
9400
9488
  * unmount/remount), reset motion values to their initial state
9401
- * so animations replay correctly from initial → animate.
9489
+ * so animations replay correctly from initial → animate, unless
9490
+ * the presence asks to keep them.
9402
9491
  */
9403
- if (this.hasBeenMounted) {
9492
+ if (this.hasBeenMounted && !this.presenceContext?.keepValuesOnRemount) {
9404
9493
  for (const key in this.initialValues) {
9405
9494
  this.values.get(key)?.jump(this.initialValues[key]);
9406
9495
  this.latestValues[key] = this.initialValues[key];
@@ -9863,6 +9952,124 @@ class HTMLVisualElement extends DOMVisualElement {
9863
9952
  }
9864
9953
  }
9865
9954
 
9955
+ /**
9956
+ * Get the VisualElement that imperative APIs like animateLayout() and
9957
+ * drag() render an element with, creating one if it has none, ready for
9958
+ * a projection node to be attached.
9959
+ */
9960
+ function resolveVisualElement(element) {
9961
+ let visualElement = visualElementStore.get(element);
9962
+ if (!visualElement) {
9963
+ visualElement = new HTMLVisualElement({
9964
+ props: {},
9965
+ presenceContext: null,
9966
+ visualState: {
9967
+ latestValues: {},
9968
+ renderState: {
9969
+ transform: {},
9970
+ transformOrigin: {},
9971
+ style: {},
9972
+ vars: {},
9973
+ },
9974
+ },
9975
+ }, { allowProjection: true });
9976
+ /**
9977
+ * Values animate() has been rendering on this element move to
9978
+ * the VisualElement, so the layout animation composes with
9979
+ * them instead of overwriting them.
9980
+ */
9981
+ handOffElementState(element, visualElement);
9982
+ }
9983
+ /**
9984
+ * A first-time element may carry a projection transform in its
9985
+ * inline style (e.g. it was cloned from an element mid-animation).
9986
+ * That transform isn't tracked in latestValues so the engine can't
9987
+ * reset it before measuring - clear it now so the first layout
9988
+ * measurement isn't inflated.
9989
+ */
9990
+ if (element.style.transform && !hasTransform(visualElement.latestValues)) {
9991
+ element.style.transform = "";
9992
+ }
9993
+ return visualElement;
9994
+ }
9995
+
9996
+ /**
9997
+ * animateLayout() registers a function here that creates nodes in the
9998
+ * layout projection tree. When it's in the bundle, drag() uses those, so
9999
+ * the two work together (e.g. a drag follows a layout change mid-gesture).
10000
+ * Otherwise drag() makes do with a node that only measures. Bundles that
10001
+ * don't tree-shake (dev pre-bundling, CDN builds) always register it, and
10002
+ * a drag() started before animateLayout() is lazy loaded keeps its node.
10003
+ */
10004
+ const layoutProjection = {};
10005
+ /**
10006
+ * The document root of measurement-only nodes. Like the projection tree's
10007
+ * root, it keeps its scroll until drag controls clear it to re-measure.
10008
+ */
10009
+ const root = {
10010
+ updateScroll: () => {
10011
+ root.scroll || (root.scroll = { offset: measureDocumentScroll() });
10012
+ },
10013
+ };
10014
+ /**
10015
+ * The part of a projection node that drag controls use: measuring the
10016
+ * element's page box, for its layout and constraints. It never projects
10017
+ * or joins a layout update.
10018
+ */
10019
+ const createMeasureNode = (element) => {
10020
+ const visualElement = resolveVisualElement(element);
10021
+ const measureListeners = new motionUtils.SubscriptionManager();
10022
+ const node = {
10023
+ instance: element,
10024
+ root,
10025
+ path: [root],
10026
+ setOptions: motionUtils.noop,
10027
+ /**
10028
+ * Truthy like the full node's method, which HTMLVisualElement reads
10029
+ * (rather than calls) to default transform values.
10030
+ */
10031
+ isProjecting: motionUtils.noop,
10032
+ applyProjectionStyles: motionUtils.noop,
10033
+ removeElementScroll: (box) => box,
10034
+ updateLayout: () => {
10035
+ const layoutBox = measurePageBox(element, root, visualElement.getTransformPagePoint());
10036
+ roundBox(layoutBox);
10037
+ node.layout = { layoutBox };
10038
+ measureListeners.notify();
10039
+ },
10040
+ addEventListener: (name, handler) => name === "measure" ? measureListeners.add(handler) : motionUtils.noop,
10041
+ /**
10042
+ * Detach from the VisualElement too, so it doesn't later remount
10043
+ * (or a `motion` component's layout feature adopt) a node that
10044
+ * can't do either.
10045
+ */
10046
+ unmount: () => {
10047
+ node.instance = undefined;
10048
+ if (visualElement.projection === node) {
10049
+ visualElement.projection = undefined;
10050
+ }
10051
+ },
10052
+ };
10053
+ visualElement.projection = node;
10054
+ visualElement.current || visualElement.mount(element);
10055
+ return [node, node.unmount];
10056
+ };
10057
+ /**
10058
+ * Get a projection node for drag() to measure an element with, and a
10059
+ * function that releases it. Reuses a node a `motion` component or
10060
+ * animateLayout() owns.
10061
+ */
10062
+ const acquireDragNode = (element) => {
10063
+ const owned = visualElementStore.get(element)?.projection;
10064
+ /**
10065
+ * A VisualElement can outlive its node (e.g. an unmounted `motion`
10066
+ * component's), so only reuse a node that's still mounted.
10067
+ */
10068
+ return owned?.instance
10069
+ ? [owned, motionUtils.noop]
10070
+ : (layoutProjection.create || createMeasureNode)(element);
10071
+ };
10072
+
9866
10073
  const layoutSelector = "[data-layout],[data-layout-id]";
9867
10074
  /**
9868
10075
  * All imperatively-created projection nodes live in one persistent tree,
@@ -9915,21 +10122,6 @@ function getProjectionParent(element) {
9915
10122
  }
9916
10123
  return undefined;
9917
10124
  }
9918
- function createVisualElement() {
9919
- return new HTMLVisualElement({
9920
- props: {},
9921
- presenceContext: null,
9922
- visualState: {
9923
- latestValues: {},
9924
- renderState: {
9925
- transform: {},
9926
- transformOrigin: {},
9927
- style: {},
9928
- vars: {},
9929
- },
9930
- },
9931
- }, { allowProjection: true });
9932
- }
9933
10125
  function readNodeOptions(element, transition) {
9934
10126
  const layoutAttr = element.getAttribute("data-layout");
9935
10127
  const layoutId = element.getAttribute("data-layout-id") ?? undefined;
@@ -9945,27 +10137,7 @@ function readNodeOptions(element, transition) {
9945
10137
  function prepareNode(element, transition) {
9946
10138
  let node = layoutNodes.get(element);
9947
10139
  if (!node) {
9948
- let visualElement = visualElementStore.get(element);
9949
- if (!visualElement) {
9950
- visualElement = createVisualElement();
9951
- /**
9952
- * Values animate() has been rendering on this element move to
9953
- * the VisualElement, so the layout animation composes with
9954
- * them instead of overwriting them.
9955
- */
9956
- handOffElementState(element, visualElement);
9957
- }
9958
- /**
9959
- * A first-time element may carry a projection transform in its
9960
- * inline style (e.g. it was cloned from an element mid-animation).
9961
- * That transform isn't tracked in latestValues so the engine can't
9962
- * reset it before measuring - clear it now so the first layout
9963
- * measurement isn't inflated.
9964
- */
9965
- if (element.style.transform &&
9966
- !hasTransform(visualElement.latestValues)) {
9967
- element.style.transform = "";
9968
- }
10140
+ const visualElement = resolveVisualElement(element);
9969
10141
  node = new HTMLProjectionNode(visualElement.latestValues, getProjectionParent(element));
9970
10142
  visualElement.projection = node;
9971
10143
  node.setOptions({
@@ -9985,10 +10157,26 @@ function prepareNode(element, transition) {
9985
10157
  return node;
9986
10158
  }
9987
10159
  /**
9988
- * Get a projection node for an element, so imperative gestures like
9989
- * drag() can measure its layout. Reuses a node owned by a `motion`
9990
- * component or animateLayout(), otherwise creates one in the shared
9991
- * imperative tree. Returns the node and a function that releases it.
10160
+ * Create a node for an element in the shared imperative tree. Returns the
10161
+ * node and a function that releases it.
10162
+ */
10163
+ function createLayoutNode(element) {
10164
+ const node = prepareNode(element);
10165
+ return [
10166
+ node,
10167
+ () => layoutNodes.get(element) === node && dropNode(element, node),
10168
+ ];
10169
+ }
10170
+ /**
10171
+ * Let drag() create its nodes in the shared imperative tree, so drag
10172
+ * gestures and layout animations work together.
10173
+ */
10174
+ layoutProjection.create = createLayoutNode;
10175
+ /**
10176
+ * Get a projection node for an element, so motion/remix can measure and
10177
+ * animate its layout. Reuses a node owned by a `motion` component or
10178
+ * animateLayout(), otherwise creates one in the shared imperative tree.
10179
+ * Returns the node and a function that releases it.
9992
10180
  */
9993
10181
  function acquireProjectionNode(element) {
9994
10182
  const owned = layoutNodes.get(element) || visualElementStore.get(element)?.projection;
@@ -9996,13 +10184,7 @@ function acquireProjectionNode(element) {
9996
10184
  * A VisualElement can outlive a node we released (e.g. a stopped
9997
10185
  * drag()), so only reuse a node that's still mounted.
9998
10186
  */
9999
- if (owned?.instance)
10000
- return [owned, () => { }];
10001
- const node = prepareNode(element);
10002
- return [
10003
- node,
10004
- () => layoutNodes.get(element) === node && dropNode(element, node),
10005
- ];
10187
+ return owned?.instance ? [owned, () => { }] : createLayoutNode(element);
10006
10188
  }
10007
10189
  function sortDocumentOrder(elements) {
10008
10190
  return [...elements].sort((a, b) => a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1);
@@ -10022,6 +10204,8 @@ function dropNode(element, node) {
10022
10204
  }
10023
10205
  function flushPendingBuilders() {
10024
10206
  const builders = pendingBuilders;
10207
+ if (!builders)
10208
+ return;
10025
10209
  pendingBuilders = undefined;
10026
10210
  flushPendingFrame();
10027
10211
  /**
@@ -10086,6 +10270,13 @@ function flushPendingBuilders() {
10086
10270
  };
10087
10271
  updatePromises.length ? Promise.all(updatePromises).then(commit) : commit();
10088
10272
  }
10273
+ /**
10274
+ * Snapshot every pending animateLayout() now, rather than on the next
10275
+ * microtask. For renderers that tell us a DOM update is about to happen
10276
+ * and then make it synchronously (e.g. a beforeUpdate/commit pair), with
10277
+ * updateDom returning a promise that resolves on commit.
10278
+ */
10279
+ const flushLayoutSnapshots = flushPendingBuilders;
10089
10280
  class LayoutAnimationBuilder {
10090
10281
  constructor(scope, updateDom, defaultOptions) {
10091
10282
  this.scope = scope;
@@ -10863,7 +11054,7 @@ class VisualElementDragControls {
10863
11054
  };
10864
11055
  const onStart = (event, info) => {
10865
11056
  // Attempt to grab the global drag gesture lock - maybe make this part of PanSession
10866
- const { drag, dragPropagation, onDragStart } = this.getProps();
11057
+ const { drag, dragConstraints, dragPropagation, onDragStart } = this.getProps();
10867
11058
  if (drag && !dragPropagation) {
10868
11059
  this.openDragLock?.();
10869
11060
  this.openDragLock = setDragLock(drag);
@@ -10910,6 +11101,8 @@ class VisualElementDragControls {
10910
11101
  }
10911
11102
  this.originPoint[axis] = current;
10912
11103
  });
11104
+ this.point =
11105
+ typeof dragConstraints === "function" && dragConstraints(this);
10913
11106
  // Fire onDragStart event
10914
11107
  if (onDragStart) {
10915
11108
  frame.update(() => onDragStart(event, info), false, true);
@@ -10940,6 +11133,7 @@ class VisualElementDragControls {
10940
11133
  // Update each point with the latest position
10941
11134
  this.updateAxis("x", offset);
10942
11135
  this.updateAxis("y", offset);
11136
+ this.point && this.point.move();
10943
11137
  /**
10944
11138
  * Ideally we would leave the renderer to fire naturally at the end of
10945
11139
  * this frame but if the element is about to change layout as the result
@@ -10964,7 +11158,7 @@ class VisualElementDragControls {
10964
11158
  };
10965
11159
  const resumeAnimation = () => {
10966
11160
  const { dragSnapToOrigin: snap } = this.getProps();
10967
- if (snap || this.constraints) {
11161
+ if (snap || this.constraints || this.point) {
10968
11162
  this.startAnimation({ x: 0, y: 0 });
10969
11163
  }
10970
11164
  };
@@ -11039,7 +11233,7 @@ class VisualElementDragControls {
11039
11233
  if (constraints) {
11040
11234
  next = applyConstraints(next, constraints, this.elastic[axis]);
11041
11235
  }
11042
- axisValue.set(next);
11236
+ this.point ? (this.point[axis] = next) : axisValue.set(next);
11043
11237
  }
11044
11238
  resolveConstraints() {
11045
11239
  const { dragConstraints, dragElastic } = this.getProps();
@@ -11060,7 +11254,9 @@ class VisualElementDragControls {
11060
11254
  }
11061
11255
  }
11062
11256
  else {
11063
- if (dragConstraints && layout) {
11257
+ if (dragConstraints &&
11258
+ layout &&
11259
+ typeof dragConstraints === "object") {
11064
11260
  this.constraints = calcRelativeConstraints(layout.layoutBox, dragConstraints);
11065
11261
  }
11066
11262
  else {
@@ -11128,6 +11324,30 @@ class VisualElementDragControls {
11128
11324
  }
11129
11325
  startAnimation(velocity, dragAxes) {
11130
11326
  const { drag, dragMomentum, dragElastic, dragTransition, dragSnapToOrigin, onDragTransitionEnd, } = this.getProps();
11327
+ /**
11328
+ * Overdamp the boundary spring if `dragElastic` is disabled. There's still a frame
11329
+ * of spring animations so we should look into adding a disable spring option to `inertia`.
11330
+ * We could do something here where we affect the `bounceStiffness` and `bounceDamping`
11331
+ * using the value of `dragElastic`.
11332
+ */
11333
+ const options = {
11334
+ bounceStiffness: dragElastic ? 200 : 1000000,
11335
+ bounceDamping: dragElastic ? 40 : 10000000,
11336
+ timeConstant: 750,
11337
+ restDelta: 1,
11338
+ restSpeed: 10,
11339
+ ...dragTransition,
11340
+ };
11341
+ const axisVelocity = (axis) => dragMomentum &&
11342
+ !(this.point && dragSnapToOrigin) &&
11343
+ shouldDrag(axis, dragAxes || drag, this.currentDirection)
11344
+ ? velocity[axis]
11345
+ : 0;
11346
+ if (this.point && !dragSnapToOrigin) {
11347
+ return this.point
11348
+ .release({ x: axisVelocity("x"), y: axisVelocity("y") }, options)
11349
+ .then(onDragTransitionEnd);
11350
+ }
11131
11351
  const constraints = this.constraints || {};
11132
11352
  const momentumAnimations = eachAxis((axis) => {
11133
11353
  if (!shouldDrag(axis, dragAxes || drag, this.currentDirection)) {
@@ -11137,23 +11357,10 @@ class VisualElementDragControls {
11137
11357
  if (dragSnapToOrigin === true ||
11138
11358
  dragSnapToOrigin === axis)
11139
11359
  transition = { min: 0, max: 0 };
11140
- /**
11141
- * Overdamp the boundary spring if `dragElastic` is disabled. There's still a frame
11142
- * of spring animations so we should look into adding a disable spring option to `inertia`.
11143
- * We could do something here where we affect the `bounceStiffness` and `bounceDamping`
11144
- * using the value of `dragElastic`.
11145
- */
11146
- const bounceStiffness = dragElastic ? 200 : 1000000;
11147
- const bounceDamping = dragElastic ? 40 : 10000000;
11148
11360
  const inertia = {
11149
11361
  type: "inertia",
11150
- velocity: dragMomentum ? velocity[axis] : 0,
11151
- bounceStiffness,
11152
- bounceDamping,
11153
- timeConstant: 750,
11154
- restDelta: 1,
11155
- restSpeed: 10,
11156
- ...dragTransition,
11362
+ velocity: axisVelocity(axis),
11363
+ ...options,
11157
11364
  ...transition,
11158
11365
  };
11159
11366
  // If we're not animating on an externally-provided `MotionValue` we can use the
@@ -11484,13 +11691,13 @@ function drag(elementOrSelector, options = {}) {
11484
11691
  }
11485
11692
  const cleanups = resolveElements(elementOrSelector).map((element) => {
11486
11693
  scope?.track(element);
11487
- const [node, release] = acquireProjectionNode(element);
11694
+ const [node, release] = acquireDragNode(element);
11488
11695
  /**
11489
11696
  * Measure layout even when not animating it, as constraints and
11490
11697
  * layout-shift correction are computed from it.
11491
11698
  */
11492
11699
  node.setOptions({ alwaysMeasureLayout: true });
11493
- const controls = new VisualElementDragControls(node.options.visualElement, () => props);
11700
+ const controls = new VisualElementDragControls(visualElementStore.get(element), () => props);
11494
11701
  const removeListeners = controls.addListeners();
11495
11702
  const removeStyles = applyDragStyles(element, options.axis);
11496
11703
  return () => {
@@ -11896,9 +12103,19 @@ function scopeMotion(...args) {
11896
12103
  return scope;
11897
12104
  }
11898
12105
 
12106
+ /**
12107
+ * The metrics projection counts, in the order of the index it passes to
12108
+ * statsBuffer.countProjection.
12109
+ */
12110
+ const projectionMetrics = [
12111
+ "nodes",
12112
+ "calculatedTargetDeltas",
12113
+ "calculatedProjections",
12114
+ ];
11899
12115
  function clearStatsBuffer() {
11900
12116
  statsBuffer.value = null;
11901
12117
  statsBuffer.addProjectionMetrics = null;
12118
+ statsBuffer.countProjection = undefined;
11902
12119
  }
11903
12120
  function recordStats() {
11904
12121
  if (statsBuffer.value) {
@@ -11919,6 +12136,27 @@ function recordStats() {
11919
12136
  layoutProjection.calculatedTargetDeltas.push(metrics.calculatedTargetDeltas);
11920
12137
  layoutProjection.calculatedProjections.push(metrics.calculatedProjections);
11921
12138
  };
12139
+ /**
12140
+ * Counting lives here rather than in projection, so bundles that never
12141
+ * call recordStats() don't ship it.
12142
+ */
12143
+ const metrics = {
12144
+ nodes: 0,
12145
+ calculatedTargetDeltas: 0,
12146
+ calculatedProjections: 0,
12147
+ };
12148
+ buffer.countProjection = (metric) => {
12149
+ if (metric !== undefined) {
12150
+ metrics[projectionMetrics[metric]]++;
12151
+ }
12152
+ else {
12153
+ buffer.addProjectionMetrics(metrics);
12154
+ metrics.nodes =
12155
+ metrics.calculatedTargetDeltas =
12156
+ metrics.calculatedProjections =
12157
+ 0;
12158
+ }
12159
+ };
11922
12160
  }
11923
12161
 
11924
12162
  function getOriginIndex(from, total) {
@@ -14117,6 +14355,7 @@ exports.ViewTransitionBuilder = ViewTransitionBuilder;
14117
14355
  exports.VisualElement = VisualElement;
14118
14356
  exports.VisualElementDragControls = VisualElementDragControls;
14119
14357
  exports.acceleratedValues = acceleratedValues;
14358
+ exports.acquireProjectionNode = acquireProjectionNode;
14120
14359
  exports.activeScope = activeScope;
14121
14360
  exports.addAttrValue = addAttrValue;
14122
14361
  exports.addBuilderToScope = addBuilderToScope;
@@ -14226,6 +14465,7 @@ exports.findDimensionValueType = findDimensionValueType;
14226
14465
  exports.findEffect = findEffect;
14227
14466
  exports.findValueType = findValueType;
14228
14467
  exports.flushKeyframeResolvers = flushKeyframeResolvers;
14468
+ exports.flushLayoutSnapshots = flushLayoutSnapshots;
14229
14469
  exports.followValue = followValue;
14230
14470
  exports.frame = frame;
14231
14471
  exports.frameData = frameData;