framer-motion 7.6.5 → 7.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -2258,7 +2258,7 @@ class MotionValue {
2258
2258
  * This will be replaced by the build step with the latest version number.
2259
2259
  * When MotionValues are provided to motion components, warn if versions are mixed.
2260
2260
  */
2261
- this.version = "7.6.5";
2261
+ this.version = "7.6.7";
2262
2262
  /**
2263
2263
  * Duration, in milliseconds, since last updating frame.
2264
2264
  *
@@ -3738,7 +3738,7 @@ class VisualElementDragControls {
3738
3738
  * If the MotionValue is a percentage value convert to px
3739
3739
  */
3740
3740
  if (styleValueTypes.percent.test(current)) {
3741
- const measuredAxis = (_b = (_a = this.visualElement.projection) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.actual[axis];
3741
+ const measuredAxis = (_b = (_a = this.visualElement.projection) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.layoutBox[axis];
3742
3742
  if (measuredAxis) {
3743
3743
  const length = calcLength(measuredAxis);
3744
3744
  current = length * (parseFloat(current) / 100);
@@ -3839,7 +3839,7 @@ class VisualElementDragControls {
3839
3839
  }
3840
3840
  else {
3841
3841
  if (dragConstraints && layout) {
3842
- this.constraints = calcRelativeConstraints(layout.actual, dragConstraints);
3842
+ this.constraints = calcRelativeConstraints(layout.layoutBox, dragConstraints);
3843
3843
  }
3844
3844
  else {
3845
3845
  this.constraints = false;
@@ -3856,7 +3856,7 @@ class VisualElementDragControls {
3856
3856
  !this.hasMutatedConstraints) {
3857
3857
  eachAxis((axis) => {
3858
3858
  if (this.getAxisMotionValue(axis)) {
3859
- this.constraints[axis] = rebaseAxisConstraints(layout.actual[axis], this.constraints[axis]);
3859
+ this.constraints[axis] = rebaseAxisConstraints(layout.layoutBox[axis], this.constraints[axis]);
3860
3860
  }
3861
3861
  });
3862
3862
  }
@@ -3872,7 +3872,7 @@ class VisualElementDragControls {
3872
3872
  if (!projection || !projection.layout)
3873
3873
  return false;
3874
3874
  const constraintsBox = measurePageBox(constraintsElement, projection.root, this.visualElement.getTransformPagePoint());
3875
- let measuredConstraints = calcViewportConstraints(projection.layout.actual, constraintsBox);
3875
+ let measuredConstraints = calcViewportConstraints(projection.layout.layoutBox, constraintsBox);
3876
3876
  /**
3877
3877
  * If there's an onMeasureDragConstraints listener we call it and
3878
3878
  * if different constraints are returned, set constraints to that
@@ -3954,7 +3954,7 @@ class VisualElementDragControls {
3954
3954
  const { projection } = this.visualElement;
3955
3955
  const axisValue = this.getAxisMotionValue(axis);
3956
3956
  if (projection && projection.layout) {
3957
- const { min, max } = projection.layout.actual[axis];
3957
+ const { min, max } = projection.layout.layoutBox[axis];
3958
3958
  axisValue.set(point[axis] - popmotion.mix(min, max, 0.5));
3959
3959
  }
3960
3960
  });
@@ -4521,7 +4521,7 @@ function updateMotionValuesFromProps(element, next, prev) {
4521
4521
  * and warn against mismatches.
4522
4522
  */
4523
4523
  if (process.env.NODE_ENV === "development") {
4524
- warnOnce(nextValue.version === "7.6.5", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.6.5 may not work as expected.`);
4524
+ warnOnce(nextValue.version === "7.6.7", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.6.7 may not work as expected.`);
4525
4525
  }
4526
4526
  }
4527
4527
  else if (isMotionValue(prevValue)) {
@@ -4675,17 +4675,6 @@ class VisualElement {
4675
4675
  }
4676
4676
  }
4677
4677
  }
4678
- /**
4679
- * Update external values with initial values
4680
- */
4681
- if (props.values) {
4682
- for (const key in props.values) {
4683
- const value = props.values[key];
4684
- if (latestValues[key] !== undefined && isMotionValue(value)) {
4685
- value.set(latestValues[key]);
4686
- }
4687
- }
4688
- }
4689
4678
  }
4690
4679
  /**
4691
4680
  * This method takes React props and returns found MotionValues. For example, HTML
@@ -5721,7 +5710,7 @@ const transformAxes = ["", "X", "Y", "Z"];
5721
5710
  const animationTarget = 1000;
5722
5711
  function createProjectionNode({ attachResizeListener, defaultParent, measureScroll, checkIsScrollRoot, resetTransform, }) {
5723
5712
  return class ProjectionNode {
5724
- constructor(id, latestValues = {}, parent = defaultParent === null || defaultParent === void 0 ? void 0 : defaultParent()) {
5713
+ constructor(elementId, latestValues = {}, parent = defaultParent === null || defaultParent === void 0 ? void 0 : defaultParent()) {
5725
5714
  /**
5726
5715
  * A Set containing all this component's children. This is used to iterate
5727
5716
  * through the children.
@@ -5774,7 +5763,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
5774
5763
  /**
5775
5764
  * An object representing the calculated contextual/accumulated/tree scale.
5776
5765
  * This will be used to scale calculcated projection transforms, as these are
5777
- * calculated in screen-space but need to be scaled for elements to actually
5766
+ * calculated in screen-space but need to be scaled for elements to layoutly
5778
5767
  * make it to their calculated destinations.
5779
5768
  *
5780
5769
  * TODO: Lazy-init
@@ -5804,13 +5793,13 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
5804
5793
  */
5805
5794
  // TODO Only running on root node
5806
5795
  this.sharedNodes = new Map();
5807
- this.id = id;
5796
+ this.elementId = elementId;
5808
5797
  this.latestValues = latestValues;
5809
5798
  this.root = parent ? parent.root || parent : this;
5810
5799
  this.path = parent ? [...parent.path, parent] : [];
5811
5800
  this.parent = parent;
5812
5801
  this.depth = parent ? parent.depth + 1 : 0;
5813
- id && this.root.registerPotentialNode(id, this);
5802
+ elementId && this.root.registerPotentialNode(elementId, this);
5814
5803
  for (let i = 0; i < this.path.length; i++) {
5815
5804
  this.path[i].shouldResetTransform = true;
5816
5805
  }
@@ -5849,7 +5838,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
5849
5838
  }
5850
5839
  this.root.nodes.add(this);
5851
5840
  (_a = this.parent) === null || _a === void 0 ? void 0 : _a.children.add(this);
5852
- this.id && this.root.potentialNodes.delete(this.id);
5841
+ this.elementId && this.root.potentialNodes.delete(this.elementId);
5853
5842
  if (isLayoutDirty && (layout || layoutId)) {
5854
5843
  this.isLayoutDirty = true;
5855
5844
  }
@@ -6065,14 +6054,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
6065
6054
  updateSnapshot() {
6066
6055
  if (this.snapshot || !this.instance)
6067
6056
  return;
6068
- const measured = this.measure();
6069
- const layout = this.removeTransform(this.removeElementScroll(measured));
6070
- roundBox(layout);
6071
- this.snapshot = {
6072
- measured,
6073
- layout,
6074
- latestValues: {},
6075
- };
6057
+ this.snapshot = this.measure();
6076
6058
  }
6077
6059
  updateLayout() {
6078
6060
  var _a;
@@ -6097,18 +6079,13 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
6097
6079
  node.updateScroll();
6098
6080
  }
6099
6081
  }
6100
- const measured = this.measure();
6101
- roundBox(measured);
6102
6082
  const prevLayout = this.layout;
6103
- this.layout = {
6104
- measured,
6105
- actual: this.removeElementScroll(measured),
6106
- };
6083
+ this.layout = this.measure(false);
6107
6084
  this.layoutCorrected = createBox();
6108
6085
  this.isLayoutDirty = false;
6109
6086
  this.projectionDelta = undefined;
6110
- this.notifyListeners("measure", this.layout.actual);
6111
- (_a = this.options.visualElement) === null || _a === void 0 ? void 0 : _a.notify("LayoutMeasure", this.layout.actual, prevLayout === null || prevLayout === void 0 ? void 0 : prevLayout.actual);
6087
+ this.notifyListeners("measure", this.layout.layoutBox);
6088
+ (_a = this.options.visualElement) === null || _a === void 0 ? void 0 : _a.notify("LayoutMeasure", this.layout.layoutBox, prevLayout === null || prevLayout === void 0 ? void 0 : prevLayout.layoutBox);
6112
6089
  }
6113
6090
  updateScroll() {
6114
6091
  if (this.options.layoutScroll && this.instance) {
@@ -6134,7 +6111,25 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
6134
6111
  this.scheduleRender();
6135
6112
  }
6136
6113
  }
6137
- measure() {
6114
+ measure(removeTransform = true) {
6115
+ const pageBox = this.measurePageBox();
6116
+ let layoutBox = this.removeElementScroll(pageBox);
6117
+ /**
6118
+ * Measurements taken during the pre-render stage
6119
+ * still have transforms applied so we remove them
6120
+ * via calculation.
6121
+ */
6122
+ if (removeTransform) {
6123
+ layoutBox = this.removeTransform(layoutBox);
6124
+ }
6125
+ roundBox(layoutBox);
6126
+ return {
6127
+ measuredBox: pageBox,
6128
+ layoutBox,
6129
+ latestValues: {},
6130
+ };
6131
+ }
6132
+ measurePageBox() {
6138
6133
  const { visualElement } = this.options;
6139
6134
  if (!visualElement)
6140
6135
  return createBox();
@@ -6215,9 +6210,9 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
6215
6210
  continue;
6216
6211
  hasScale(node.latestValues) && node.updateSnapshot();
6217
6212
  const sourceBox = createBox();
6218
- const nodeBox = node.measure();
6213
+ const nodeBox = node.measurePageBox();
6219
6214
  copyBoxInto(sourceBox, nodeBox);
6220
- removeBoxTransforms(boxWithoutTransform, node.latestValues, (_a = node.snapshot) === null || _a === void 0 ? void 0 : _a.layout, sourceBox);
6215
+ removeBoxTransforms(boxWithoutTransform, node.latestValues, (_a = node.snapshot) === null || _a === void 0 ? void 0 : _a.layoutBox, sourceBox);
6221
6216
  }
6222
6217
  if (hasTransform(this.latestValues)) {
6223
6218
  removeBoxTransforms(boxWithoutTransform, this.latestValues);
@@ -6271,7 +6266,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
6271
6266
  this.relativeParent = relativeParent;
6272
6267
  this.relativeTarget = createBox();
6273
6268
  this.relativeTargetOrigin = createBox();
6274
- calcRelativePosition(this.relativeTargetOrigin, this.layout.actual, relativeParent.layout.actual);
6269
+ calcRelativePosition(this.relativeTargetOrigin, this.layout.layoutBox, relativeParent.layout.layoutBox);
6275
6270
  copyBoxInto(this.relativeTarget, this.relativeTargetOrigin);
6276
6271
  }
6277
6272
  else {
@@ -6305,10 +6300,10 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
6305
6300
  else if (this.targetDelta) {
6306
6301
  if (Boolean(this.resumingFrom)) {
6307
6302
  // TODO: This is creating a new object every frame
6308
- this.target = this.applyTransform(this.layout.actual);
6303
+ this.target = this.applyTransform(this.layout.layoutBox);
6309
6304
  }
6310
6305
  else {
6311
- copyBoxInto(this.target, this.layout.actual);
6306
+ copyBoxInto(this.target, this.layout.layoutBox);
6312
6307
  }
6313
6308
  applyBoxDelta(this.target, this.targetDelta);
6314
6309
  }
@@ -6316,7 +6311,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
6316
6311
  /**
6317
6312
  * If no target, use own layout as target
6318
6313
  */
6319
- copyBoxInto(this.target, this.layout.actual);
6314
+ copyBoxInto(this.target, this.layout.layoutBox);
6320
6315
  }
6321
6316
  /**
6322
6317
  * If we've been told to attempt to resolve a relative target, do so.
@@ -6373,7 +6368,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
6373
6368
  * Reset the corrected box with the latest values from box, as we're then going
6374
6369
  * to perform mutative operations on it.
6375
6370
  */
6376
- copyBoxInto(this.layoutCorrected, this.layout.actual);
6371
+ copyBoxInto(this.layoutCorrected, this.layout.layoutBox);
6377
6372
  /**
6378
6373
  * Apply all the parent deltas to this box to produce the corrected box. This
6379
6374
  * is the layout box, as it will appear on screen as a result of the transforms of its parents.
@@ -6450,7 +6445,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
6450
6445
  this.relativeTargetOrigin &&
6451
6446
  this.layout &&
6452
6447
  ((_a = this.relativeParent) === null || _a === void 0 ? void 0 : _a.layout)) {
6453
- calcRelativePosition(relativeLayout, this.layout.actual, this.relativeParent.layout.actual);
6448
+ calcRelativePosition(relativeLayout, this.layout.layoutBox, this.relativeParent.layout.layoutBox);
6454
6449
  mixBox(this.relativeTarget, this.relativeTargetOrigin, relativeLayout, progress);
6455
6450
  }
6456
6451
  if (isSharedLayoutAnimation) {
@@ -6534,12 +6529,12 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
6534
6529
  if (this !== lead &&
6535
6530
  this.layout &&
6536
6531
  layout &&
6537
- shouldAnimatePositionOnly(this.options.animationType, this.layout.actual, layout.actual)) {
6532
+ shouldAnimatePositionOnly(this.options.animationType, this.layout.layoutBox, layout.layoutBox)) {
6538
6533
  target = this.target || createBox();
6539
- const xLength = calcLength(this.layout.actual.x);
6534
+ const xLength = calcLength(this.layout.layoutBox.x);
6540
6535
  target.x.min = lead.target.x.min;
6541
6536
  target.x.max = target.x.min + xLength;
6542
- const yLength = calcLength(this.layout.actual.y);
6537
+ const yLength = calcLength(this.layout.layoutBox.y);
6543
6538
  target.y.min = lead.target.y.min;
6544
6539
  target.y.max = target.y.min + yLength;
6545
6540
  }
@@ -6553,7 +6548,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
6553
6548
  /**
6554
6549
  * Update the delta between the corrected box and the final target box, after
6555
6550
  * user-set transforms are applied to it. This will be used by the renderer to
6556
- * create a transform style that will reproject the element from its actual layout
6551
+ * create a transform style that will reproject the element from its layout layout
6557
6552
  * into the desired bounding box.
6558
6553
  */
6559
6554
  calcBoxDelta(this.projectionDeltaWithTransform, this.layoutCorrected, targetWithTransforms, latestValues);
@@ -6709,7 +6704,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
6709
6704
  }
6710
6705
  else {
6711
6706
  /**
6712
- * Or we're not animating at all, set the lead component to its actual
6707
+ * Or we're not animating at all, set the lead component to its layout
6713
6708
  * opacity and other components to hidden.
6714
6709
  */
6715
6710
  styles.opacity =
@@ -6773,37 +6768,37 @@ function notifyLayoutUpdate(node) {
6773
6768
  node.layout &&
6774
6769
  snapshot &&
6775
6770
  node.hasListeners("didUpdate")) {
6776
- const { actual: layout, measured: measuredLayout } = node.layout;
6771
+ const { layoutBox: layout, measuredBox: measuredLayout } = node.layout;
6777
6772
  const { animationType } = node.options;
6778
6773
  // TODO Maybe we want to also resize the layout snapshot so we don't trigger
6779
6774
  // animations for instance if layout="size" and an element has only changed position
6780
6775
  if (animationType === "size") {
6781
6776
  eachAxis((axis) => {
6782
6777
  const axisSnapshot = snapshot.isShared
6783
- ? snapshot.measured[axis]
6784
- : snapshot.layout[axis];
6778
+ ? snapshot.measuredBox[axis]
6779
+ : snapshot.layoutBox[axis];
6785
6780
  const length = calcLength(axisSnapshot);
6786
6781
  axisSnapshot.min = layout[axis].min;
6787
6782
  axisSnapshot.max = axisSnapshot.min + length;
6788
6783
  });
6789
6784
  }
6790
- else if (shouldAnimatePositionOnly(animationType, snapshot.layout, layout)) {
6785
+ else if (shouldAnimatePositionOnly(animationType, snapshot.layoutBox, layout)) {
6791
6786
  eachAxis((axis) => {
6792
6787
  const axisSnapshot = snapshot.isShared
6793
- ? snapshot.measured[axis]
6794
- : snapshot.layout[axis];
6788
+ ? snapshot.measuredBox[axis]
6789
+ : snapshot.layoutBox[axis];
6795
6790
  const length = calcLength(layout[axis]);
6796
6791
  axisSnapshot.max = axisSnapshot.min + length;
6797
6792
  });
6798
6793
  }
6799
6794
  const layoutDelta = createDelta();
6800
- calcBoxDelta(layoutDelta, layout, snapshot.layout);
6795
+ calcBoxDelta(layoutDelta, layout, snapshot.layoutBox);
6801
6796
  const visualDelta = createDelta();
6802
6797
  if (snapshot.isShared) {
6803
- calcBoxDelta(visualDelta, node.applyTransform(measuredLayout, true), snapshot.measured);
6798
+ calcBoxDelta(visualDelta, node.applyTransform(measuredLayout, true), snapshot.measuredBox);
6804
6799
  }
6805
6800
  else {
6806
- calcBoxDelta(visualDelta, layout, snapshot.layout);
6801
+ calcBoxDelta(visualDelta, layout, snapshot.layoutBox);
6807
6802
  }
6808
6803
  const hasLayoutChanged = !isDeltaZero(layoutDelta);
6809
6804
  let hasRelativeTargetChanged = false;
@@ -6817,9 +6812,9 @@ function notifyLayoutUpdate(node) {
6817
6812
  const { snapshot: parentSnapshot, layout: parentLayout } = relativeParent;
6818
6813
  if (parentSnapshot && parentLayout) {
6819
6814
  const relativeSnapshot = createBox();
6820
- calcRelativePosition(relativeSnapshot, snapshot.layout, parentSnapshot.layout);
6815
+ calcRelativePosition(relativeSnapshot, snapshot.layoutBox, parentSnapshot.layoutBox);
6821
6816
  const relativeLayout = createBox();
6822
- calcRelativePosition(relativeLayout, layout, parentLayout.actual);
6817
+ calcRelativePosition(relativeLayout, layout, parentLayout.layoutBox);
6823
6818
  if (!boxEquals(relativeSnapshot, relativeLayout)) {
6824
6819
  hasRelativeTargetChanged = true;
6825
6820
  }
@@ -84,7 +84,7 @@ class VisualElementDragControls {
84
84
  * If the MotionValue is a percentage value convert to px
85
85
  */
86
86
  if (percent.test(current)) {
87
- const measuredAxis = (_b = (_a = this.visualElement.projection) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.actual[axis];
87
+ const measuredAxis = (_b = (_a = this.visualElement.projection) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.layoutBox[axis];
88
88
  if (measuredAxis) {
89
89
  const length = calcLength(measuredAxis);
90
90
  current = length * (parseFloat(current) / 100);
@@ -185,7 +185,7 @@ class VisualElementDragControls {
185
185
  }
186
186
  else {
187
187
  if (dragConstraints && layout) {
188
- this.constraints = calcRelativeConstraints(layout.actual, dragConstraints);
188
+ this.constraints = calcRelativeConstraints(layout.layoutBox, dragConstraints);
189
189
  }
190
190
  else {
191
191
  this.constraints = false;
@@ -202,7 +202,7 @@ class VisualElementDragControls {
202
202
  !this.hasMutatedConstraints) {
203
203
  eachAxis((axis) => {
204
204
  if (this.getAxisMotionValue(axis)) {
205
- this.constraints[axis] = rebaseAxisConstraints(layout.actual[axis], this.constraints[axis]);
205
+ this.constraints[axis] = rebaseAxisConstraints(layout.layoutBox[axis], this.constraints[axis]);
206
206
  }
207
207
  });
208
208
  }
@@ -218,7 +218,7 @@ class VisualElementDragControls {
218
218
  if (!projection || !projection.layout)
219
219
  return false;
220
220
  const constraintsBox = measurePageBox(constraintsElement, projection.root, this.visualElement.getTransformPagePoint());
221
- let measuredConstraints = calcViewportConstraints(projection.layout.actual, constraintsBox);
221
+ let measuredConstraints = calcViewportConstraints(projection.layout.layoutBox, constraintsBox);
222
222
  /**
223
223
  * If there's an onMeasureDragConstraints listener we call it and
224
224
  * if different constraints are returned, set constraints to that
@@ -300,7 +300,7 @@ class VisualElementDragControls {
300
300
  const { projection } = this.visualElement;
301
301
  const axisValue = this.getAxisMotionValue(axis);
302
302
  if (projection && projection.layout) {
303
- const { min, max } = projection.layout.actual[axis];
303
+ const { min, max } = projection.layout.layoutBox[axis];
304
304
  axisValue.set(point[axis] - mix(min, max, 0.5));
305
305
  }
306
306
  });
@@ -28,7 +28,7 @@ const transformAxes = ["", "X", "Y", "Z"];
28
28
  const animationTarget = 1000;
29
29
  function createProjectionNode({ attachResizeListener, defaultParent, measureScroll, checkIsScrollRoot, resetTransform, }) {
30
30
  return class ProjectionNode {
31
- constructor(id, latestValues = {}, parent = defaultParent === null || defaultParent === void 0 ? void 0 : defaultParent()) {
31
+ constructor(elementId, latestValues = {}, parent = defaultParent === null || defaultParent === void 0 ? void 0 : defaultParent()) {
32
32
  /**
33
33
  * A Set containing all this component's children. This is used to iterate
34
34
  * through the children.
@@ -81,7 +81,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
81
81
  /**
82
82
  * An object representing the calculated contextual/accumulated/tree scale.
83
83
  * This will be used to scale calculcated projection transforms, as these are
84
- * calculated in screen-space but need to be scaled for elements to actually
84
+ * calculated in screen-space but need to be scaled for elements to layoutly
85
85
  * make it to their calculated destinations.
86
86
  *
87
87
  * TODO: Lazy-init
@@ -111,13 +111,13 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
111
111
  */
112
112
  // TODO Only running on root node
113
113
  this.sharedNodes = new Map();
114
- this.id = id;
114
+ this.elementId = elementId;
115
115
  this.latestValues = latestValues;
116
116
  this.root = parent ? parent.root || parent : this;
117
117
  this.path = parent ? [...parent.path, parent] : [];
118
118
  this.parent = parent;
119
119
  this.depth = parent ? parent.depth + 1 : 0;
120
- id && this.root.registerPotentialNode(id, this);
120
+ elementId && this.root.registerPotentialNode(elementId, this);
121
121
  for (let i = 0; i < this.path.length; i++) {
122
122
  this.path[i].shouldResetTransform = true;
123
123
  }
@@ -156,7 +156,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
156
156
  }
157
157
  this.root.nodes.add(this);
158
158
  (_a = this.parent) === null || _a === void 0 ? void 0 : _a.children.add(this);
159
- this.id && this.root.potentialNodes.delete(this.id);
159
+ this.elementId && this.root.potentialNodes.delete(this.elementId);
160
160
  if (isLayoutDirty && (layout || layoutId)) {
161
161
  this.isLayoutDirty = true;
162
162
  }
@@ -372,14 +372,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
372
372
  updateSnapshot() {
373
373
  if (this.snapshot || !this.instance)
374
374
  return;
375
- const measured = this.measure();
376
- const layout = this.removeTransform(this.removeElementScroll(measured));
377
- roundBox(layout);
378
- this.snapshot = {
379
- measured,
380
- layout,
381
- latestValues: {},
382
- };
375
+ this.snapshot = this.measure();
383
376
  }
384
377
  updateLayout() {
385
378
  var _a;
@@ -404,18 +397,13 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
404
397
  node.updateScroll();
405
398
  }
406
399
  }
407
- const measured = this.measure();
408
- roundBox(measured);
409
400
  const prevLayout = this.layout;
410
- this.layout = {
411
- measured,
412
- actual: this.removeElementScroll(measured),
413
- };
401
+ this.layout = this.measure(false);
414
402
  this.layoutCorrected = createBox();
415
403
  this.isLayoutDirty = false;
416
404
  this.projectionDelta = undefined;
417
- this.notifyListeners("measure", this.layout.actual);
418
- (_a = this.options.visualElement) === null || _a === void 0 ? void 0 : _a.notify("LayoutMeasure", this.layout.actual, prevLayout === null || prevLayout === void 0 ? void 0 : prevLayout.actual);
405
+ this.notifyListeners("measure", this.layout.layoutBox);
406
+ (_a = this.options.visualElement) === null || _a === void 0 ? void 0 : _a.notify("LayoutMeasure", this.layout.layoutBox, prevLayout === null || prevLayout === void 0 ? void 0 : prevLayout.layoutBox);
419
407
  }
420
408
  updateScroll() {
421
409
  if (this.options.layoutScroll && this.instance) {
@@ -441,7 +429,25 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
441
429
  this.scheduleRender();
442
430
  }
443
431
  }
444
- measure() {
432
+ measure(removeTransform = true) {
433
+ const pageBox = this.measurePageBox();
434
+ let layoutBox = this.removeElementScroll(pageBox);
435
+ /**
436
+ * Measurements taken during the pre-render stage
437
+ * still have transforms applied so we remove them
438
+ * via calculation.
439
+ */
440
+ if (removeTransform) {
441
+ layoutBox = this.removeTransform(layoutBox);
442
+ }
443
+ roundBox(layoutBox);
444
+ return {
445
+ measuredBox: pageBox,
446
+ layoutBox,
447
+ latestValues: {},
448
+ };
449
+ }
450
+ measurePageBox() {
445
451
  const { visualElement } = this.options;
446
452
  if (!visualElement)
447
453
  return createBox();
@@ -522,9 +528,9 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
522
528
  continue;
523
529
  hasScale(node.latestValues) && node.updateSnapshot();
524
530
  const sourceBox = createBox();
525
- const nodeBox = node.measure();
531
+ const nodeBox = node.measurePageBox();
526
532
  copyBoxInto(sourceBox, nodeBox);
527
- removeBoxTransforms(boxWithoutTransform, node.latestValues, (_a = node.snapshot) === null || _a === void 0 ? void 0 : _a.layout, sourceBox);
533
+ removeBoxTransforms(boxWithoutTransform, node.latestValues, (_a = node.snapshot) === null || _a === void 0 ? void 0 : _a.layoutBox, sourceBox);
528
534
  }
529
535
  if (hasTransform(this.latestValues)) {
530
536
  removeBoxTransforms(boxWithoutTransform, this.latestValues);
@@ -578,7 +584,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
578
584
  this.relativeParent = relativeParent;
579
585
  this.relativeTarget = createBox();
580
586
  this.relativeTargetOrigin = createBox();
581
- calcRelativePosition(this.relativeTargetOrigin, this.layout.actual, relativeParent.layout.actual);
587
+ calcRelativePosition(this.relativeTargetOrigin, this.layout.layoutBox, relativeParent.layout.layoutBox);
582
588
  copyBoxInto(this.relativeTarget, this.relativeTargetOrigin);
583
589
  }
584
590
  else {
@@ -612,10 +618,10 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
612
618
  else if (this.targetDelta) {
613
619
  if (Boolean(this.resumingFrom)) {
614
620
  // TODO: This is creating a new object every frame
615
- this.target = this.applyTransform(this.layout.actual);
621
+ this.target = this.applyTransform(this.layout.layoutBox);
616
622
  }
617
623
  else {
618
- copyBoxInto(this.target, this.layout.actual);
624
+ copyBoxInto(this.target, this.layout.layoutBox);
619
625
  }
620
626
  applyBoxDelta(this.target, this.targetDelta);
621
627
  }
@@ -623,7 +629,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
623
629
  /**
624
630
  * If no target, use own layout as target
625
631
  */
626
- copyBoxInto(this.target, this.layout.actual);
632
+ copyBoxInto(this.target, this.layout.layoutBox);
627
633
  }
628
634
  /**
629
635
  * If we've been told to attempt to resolve a relative target, do so.
@@ -680,7 +686,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
680
686
  * Reset the corrected box with the latest values from box, as we're then going
681
687
  * to perform mutative operations on it.
682
688
  */
683
- copyBoxInto(this.layoutCorrected, this.layout.actual);
689
+ copyBoxInto(this.layoutCorrected, this.layout.layoutBox);
684
690
  /**
685
691
  * Apply all the parent deltas to this box to produce the corrected box. This
686
692
  * is the layout box, as it will appear on screen as a result of the transforms of its parents.
@@ -757,7 +763,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
757
763
  this.relativeTargetOrigin &&
758
764
  this.layout &&
759
765
  ((_a = this.relativeParent) === null || _a === void 0 ? void 0 : _a.layout)) {
760
- calcRelativePosition(relativeLayout, this.layout.actual, this.relativeParent.layout.actual);
766
+ calcRelativePosition(relativeLayout, this.layout.layoutBox, this.relativeParent.layout.layoutBox);
761
767
  mixBox(this.relativeTarget, this.relativeTargetOrigin, relativeLayout, progress);
762
768
  }
763
769
  if (isSharedLayoutAnimation) {
@@ -841,12 +847,12 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
841
847
  if (this !== lead &&
842
848
  this.layout &&
843
849
  layout &&
844
- shouldAnimatePositionOnly(this.options.animationType, this.layout.actual, layout.actual)) {
850
+ shouldAnimatePositionOnly(this.options.animationType, this.layout.layoutBox, layout.layoutBox)) {
845
851
  target = this.target || createBox();
846
- const xLength = calcLength(this.layout.actual.x);
852
+ const xLength = calcLength(this.layout.layoutBox.x);
847
853
  target.x.min = lead.target.x.min;
848
854
  target.x.max = target.x.min + xLength;
849
- const yLength = calcLength(this.layout.actual.y);
855
+ const yLength = calcLength(this.layout.layoutBox.y);
850
856
  target.y.min = lead.target.y.min;
851
857
  target.y.max = target.y.min + yLength;
852
858
  }
@@ -860,7 +866,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
860
866
  /**
861
867
  * Update the delta between the corrected box and the final target box, after
862
868
  * user-set transforms are applied to it. This will be used by the renderer to
863
- * create a transform style that will reproject the element from its actual layout
869
+ * create a transform style that will reproject the element from its layout layout
864
870
  * into the desired bounding box.
865
871
  */
866
872
  calcBoxDelta(this.projectionDeltaWithTransform, this.layoutCorrected, targetWithTransforms, latestValues);
@@ -1016,7 +1022,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
1016
1022
  }
1017
1023
  else {
1018
1024
  /**
1019
- * Or we're not animating at all, set the lead component to its actual
1025
+ * Or we're not animating at all, set the lead component to its layout
1020
1026
  * opacity and other components to hidden.
1021
1027
  */
1022
1028
  styles.opacity =
@@ -1080,37 +1086,37 @@ function notifyLayoutUpdate(node) {
1080
1086
  node.layout &&
1081
1087
  snapshot &&
1082
1088
  node.hasListeners("didUpdate")) {
1083
- const { actual: layout, measured: measuredLayout } = node.layout;
1089
+ const { layoutBox: layout, measuredBox: measuredLayout } = node.layout;
1084
1090
  const { animationType } = node.options;
1085
1091
  // TODO Maybe we want to also resize the layout snapshot so we don't trigger
1086
1092
  // animations for instance if layout="size" and an element has only changed position
1087
1093
  if (animationType === "size") {
1088
1094
  eachAxis((axis) => {
1089
1095
  const axisSnapshot = snapshot.isShared
1090
- ? snapshot.measured[axis]
1091
- : snapshot.layout[axis];
1096
+ ? snapshot.measuredBox[axis]
1097
+ : snapshot.layoutBox[axis];
1092
1098
  const length = calcLength(axisSnapshot);
1093
1099
  axisSnapshot.min = layout[axis].min;
1094
1100
  axisSnapshot.max = axisSnapshot.min + length;
1095
1101
  });
1096
1102
  }
1097
- else if (shouldAnimatePositionOnly(animationType, snapshot.layout, layout)) {
1103
+ else if (shouldAnimatePositionOnly(animationType, snapshot.layoutBox, layout)) {
1098
1104
  eachAxis((axis) => {
1099
1105
  const axisSnapshot = snapshot.isShared
1100
- ? snapshot.measured[axis]
1101
- : snapshot.layout[axis];
1106
+ ? snapshot.measuredBox[axis]
1107
+ : snapshot.layoutBox[axis];
1102
1108
  const length = calcLength(layout[axis]);
1103
1109
  axisSnapshot.max = axisSnapshot.min + length;
1104
1110
  });
1105
1111
  }
1106
1112
  const layoutDelta = createDelta();
1107
- calcBoxDelta(layoutDelta, layout, snapshot.layout);
1113
+ calcBoxDelta(layoutDelta, layout, snapshot.layoutBox);
1108
1114
  const visualDelta = createDelta();
1109
1115
  if (snapshot.isShared) {
1110
- calcBoxDelta(visualDelta, node.applyTransform(measuredLayout, true), snapshot.measured);
1116
+ calcBoxDelta(visualDelta, node.applyTransform(measuredLayout, true), snapshot.measuredBox);
1111
1117
  }
1112
1118
  else {
1113
- calcBoxDelta(visualDelta, layout, snapshot.layout);
1119
+ calcBoxDelta(visualDelta, layout, snapshot.layoutBox);
1114
1120
  }
1115
1121
  const hasLayoutChanged = !isDeltaZero(layoutDelta);
1116
1122
  let hasRelativeTargetChanged = false;
@@ -1124,9 +1130,9 @@ function notifyLayoutUpdate(node) {
1124
1130
  const { snapshot: parentSnapshot, layout: parentLayout } = relativeParent;
1125
1131
  if (parentSnapshot && parentLayout) {
1126
1132
  const relativeSnapshot = createBox();
1127
- calcRelativePosition(relativeSnapshot, snapshot.layout, parentSnapshot.layout);
1133
+ calcRelativePosition(relativeSnapshot, snapshot.layoutBox, parentSnapshot.layoutBox);
1128
1134
  const relativeLayout = createBox();
1129
- calcRelativePosition(relativeLayout, layout, parentLayout.actual);
1135
+ calcRelativePosition(relativeLayout, layout, parentLayout.layoutBox);
1130
1136
  if (!boxEquals(relativeSnapshot, relativeLayout)) {
1131
1137
  hasRelativeTargetChanged = true;
1132
1138
  }
@@ -133,17 +133,6 @@ class VisualElement {
133
133
  }
134
134
  }
135
135
  }
136
- /**
137
- * Update external values with initial values
138
- */
139
- if (props.values) {
140
- for (const key in props.values) {
141
- const value = props.values[key];
142
- if (latestValues[key] !== undefined && isMotionValue(value)) {
143
- value.set(latestValues[key]);
144
- }
145
- }
146
- }
147
136
  }
148
137
  /**
149
138
  * This method takes React props and returns found MotionValues. For example, HTML