framer-motion 7.6.5 → 7.6.6
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 +59 -53
- package/dist/es/gestures/drag/VisualElementDragControls.mjs +5 -5
- package/dist/es/projection/node/create-projection-node.mjs +52 -46
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/value/index.mjs +1 -1
- package/dist/framer-motion.dev.js +59 -53
- package/dist/framer-motion.js +1 -1
- package/dist/index.d.ts +8 -11
- package/dist/projection.dev.js +54 -48
- package/dist/size-rollup-dom-animation.js +1 -1
- package/dist/size-rollup-dom-max.js +1 -1
- package/dist/size-rollup-motion.js +1 -1
- package/dist/size-webpack-dom-max.js +1 -1
- package/dist/three-entry.d.ts +8 -11
- package/package.json +3 -3
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.
|
|
2261
|
+
this.version = "7.6.6";
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
4524
|
+
warnOnce(nextValue.version === "7.6.6", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.6.6 may not work as expected.`);
|
|
4525
4525
|
}
|
|
4526
4526
|
}
|
|
4527
4527
|
else if (isMotionValue(prevValue)) {
|
|
@@ -5721,7 +5721,7 @@ const transformAxes = ["", "X", "Y", "Z"];
|
|
|
5721
5721
|
const animationTarget = 1000;
|
|
5722
5722
|
function createProjectionNode({ attachResizeListener, defaultParent, measureScroll, checkIsScrollRoot, resetTransform, }) {
|
|
5723
5723
|
return class ProjectionNode {
|
|
5724
|
-
constructor(
|
|
5724
|
+
constructor(elementId, latestValues = {}, parent = defaultParent === null || defaultParent === void 0 ? void 0 : defaultParent()) {
|
|
5725
5725
|
/**
|
|
5726
5726
|
* A Set containing all this component's children. This is used to iterate
|
|
5727
5727
|
* through the children.
|
|
@@ -5774,7 +5774,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
5774
5774
|
/**
|
|
5775
5775
|
* An object representing the calculated contextual/accumulated/tree scale.
|
|
5776
5776
|
* 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
|
|
5777
|
+
* calculated in screen-space but need to be scaled for elements to layoutly
|
|
5778
5778
|
* make it to their calculated destinations.
|
|
5779
5779
|
*
|
|
5780
5780
|
* TODO: Lazy-init
|
|
@@ -5804,13 +5804,13 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
5804
5804
|
*/
|
|
5805
5805
|
// TODO Only running on root node
|
|
5806
5806
|
this.sharedNodes = new Map();
|
|
5807
|
-
this.
|
|
5807
|
+
this.elementId = elementId;
|
|
5808
5808
|
this.latestValues = latestValues;
|
|
5809
5809
|
this.root = parent ? parent.root || parent : this;
|
|
5810
5810
|
this.path = parent ? [...parent.path, parent] : [];
|
|
5811
5811
|
this.parent = parent;
|
|
5812
5812
|
this.depth = parent ? parent.depth + 1 : 0;
|
|
5813
|
-
|
|
5813
|
+
elementId && this.root.registerPotentialNode(elementId, this);
|
|
5814
5814
|
for (let i = 0; i < this.path.length; i++) {
|
|
5815
5815
|
this.path[i].shouldResetTransform = true;
|
|
5816
5816
|
}
|
|
@@ -5849,7 +5849,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
5849
5849
|
}
|
|
5850
5850
|
this.root.nodes.add(this);
|
|
5851
5851
|
(_a = this.parent) === null || _a === void 0 ? void 0 : _a.children.add(this);
|
|
5852
|
-
this.
|
|
5852
|
+
this.elementId && this.root.potentialNodes.delete(this.elementId);
|
|
5853
5853
|
if (isLayoutDirty && (layout || layoutId)) {
|
|
5854
5854
|
this.isLayoutDirty = true;
|
|
5855
5855
|
}
|
|
@@ -6065,14 +6065,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
6065
6065
|
updateSnapshot() {
|
|
6066
6066
|
if (this.snapshot || !this.instance)
|
|
6067
6067
|
return;
|
|
6068
|
-
|
|
6069
|
-
const layout = this.removeTransform(this.removeElementScroll(measured));
|
|
6070
|
-
roundBox(layout);
|
|
6071
|
-
this.snapshot = {
|
|
6072
|
-
measured,
|
|
6073
|
-
layout,
|
|
6074
|
-
latestValues: {},
|
|
6075
|
-
};
|
|
6068
|
+
this.snapshot = this.measure();
|
|
6076
6069
|
}
|
|
6077
6070
|
updateLayout() {
|
|
6078
6071
|
var _a;
|
|
@@ -6097,18 +6090,13 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
6097
6090
|
node.updateScroll();
|
|
6098
6091
|
}
|
|
6099
6092
|
}
|
|
6100
|
-
const measured = this.measure();
|
|
6101
|
-
roundBox(measured);
|
|
6102
6093
|
const prevLayout = this.layout;
|
|
6103
|
-
this.layout =
|
|
6104
|
-
measured,
|
|
6105
|
-
actual: this.removeElementScroll(measured),
|
|
6106
|
-
};
|
|
6094
|
+
this.layout = this.measure(false);
|
|
6107
6095
|
this.layoutCorrected = createBox();
|
|
6108
6096
|
this.isLayoutDirty = false;
|
|
6109
6097
|
this.projectionDelta = undefined;
|
|
6110
|
-
this.notifyListeners("measure", this.layout.
|
|
6111
|
-
(_a = this.options.visualElement) === null || _a === void 0 ? void 0 : _a.notify("LayoutMeasure", this.layout.
|
|
6098
|
+
this.notifyListeners("measure", this.layout.layoutBox);
|
|
6099
|
+
(_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
6100
|
}
|
|
6113
6101
|
updateScroll() {
|
|
6114
6102
|
if (this.options.layoutScroll && this.instance) {
|
|
@@ -6134,7 +6122,25 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
6134
6122
|
this.scheduleRender();
|
|
6135
6123
|
}
|
|
6136
6124
|
}
|
|
6137
|
-
measure() {
|
|
6125
|
+
measure(removeTransform = true) {
|
|
6126
|
+
const pageBox = this.measurePageBox();
|
|
6127
|
+
let layoutBox = this.removeElementScroll(pageBox);
|
|
6128
|
+
/**
|
|
6129
|
+
* Measurements taken during the pre-render stage
|
|
6130
|
+
* still have transforms applied so we remove them
|
|
6131
|
+
* via calculation.
|
|
6132
|
+
*/
|
|
6133
|
+
if (removeTransform) {
|
|
6134
|
+
layoutBox = this.removeTransform(layoutBox);
|
|
6135
|
+
}
|
|
6136
|
+
roundBox(layoutBox);
|
|
6137
|
+
return {
|
|
6138
|
+
measuredBox: pageBox,
|
|
6139
|
+
layoutBox,
|
|
6140
|
+
latestValues: {},
|
|
6141
|
+
};
|
|
6142
|
+
}
|
|
6143
|
+
measurePageBox() {
|
|
6138
6144
|
const { visualElement } = this.options;
|
|
6139
6145
|
if (!visualElement)
|
|
6140
6146
|
return createBox();
|
|
@@ -6215,9 +6221,9 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
6215
6221
|
continue;
|
|
6216
6222
|
hasScale(node.latestValues) && node.updateSnapshot();
|
|
6217
6223
|
const sourceBox = createBox();
|
|
6218
|
-
const nodeBox = node.
|
|
6224
|
+
const nodeBox = node.measurePageBox();
|
|
6219
6225
|
copyBoxInto(sourceBox, nodeBox);
|
|
6220
|
-
removeBoxTransforms(boxWithoutTransform, node.latestValues, (_a = node.snapshot) === null || _a === void 0 ? void 0 : _a.
|
|
6226
|
+
removeBoxTransforms(boxWithoutTransform, node.latestValues, (_a = node.snapshot) === null || _a === void 0 ? void 0 : _a.layoutBox, sourceBox);
|
|
6221
6227
|
}
|
|
6222
6228
|
if (hasTransform(this.latestValues)) {
|
|
6223
6229
|
removeBoxTransforms(boxWithoutTransform, this.latestValues);
|
|
@@ -6271,7 +6277,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
6271
6277
|
this.relativeParent = relativeParent;
|
|
6272
6278
|
this.relativeTarget = createBox();
|
|
6273
6279
|
this.relativeTargetOrigin = createBox();
|
|
6274
|
-
calcRelativePosition(this.relativeTargetOrigin, this.layout.
|
|
6280
|
+
calcRelativePosition(this.relativeTargetOrigin, this.layout.layoutBox, relativeParent.layout.layoutBox);
|
|
6275
6281
|
copyBoxInto(this.relativeTarget, this.relativeTargetOrigin);
|
|
6276
6282
|
}
|
|
6277
6283
|
else {
|
|
@@ -6305,10 +6311,10 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
6305
6311
|
else if (this.targetDelta) {
|
|
6306
6312
|
if (Boolean(this.resumingFrom)) {
|
|
6307
6313
|
// TODO: This is creating a new object every frame
|
|
6308
|
-
this.target = this.applyTransform(this.layout.
|
|
6314
|
+
this.target = this.applyTransform(this.layout.layoutBox);
|
|
6309
6315
|
}
|
|
6310
6316
|
else {
|
|
6311
|
-
copyBoxInto(this.target, this.layout.
|
|
6317
|
+
copyBoxInto(this.target, this.layout.layoutBox);
|
|
6312
6318
|
}
|
|
6313
6319
|
applyBoxDelta(this.target, this.targetDelta);
|
|
6314
6320
|
}
|
|
@@ -6316,7 +6322,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
6316
6322
|
/**
|
|
6317
6323
|
* If no target, use own layout as target
|
|
6318
6324
|
*/
|
|
6319
|
-
copyBoxInto(this.target, this.layout.
|
|
6325
|
+
copyBoxInto(this.target, this.layout.layoutBox);
|
|
6320
6326
|
}
|
|
6321
6327
|
/**
|
|
6322
6328
|
* If we've been told to attempt to resolve a relative target, do so.
|
|
@@ -6373,7 +6379,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
6373
6379
|
* Reset the corrected box with the latest values from box, as we're then going
|
|
6374
6380
|
* to perform mutative operations on it.
|
|
6375
6381
|
*/
|
|
6376
|
-
copyBoxInto(this.layoutCorrected, this.layout.
|
|
6382
|
+
copyBoxInto(this.layoutCorrected, this.layout.layoutBox);
|
|
6377
6383
|
/**
|
|
6378
6384
|
* Apply all the parent deltas to this box to produce the corrected box. This
|
|
6379
6385
|
* is the layout box, as it will appear on screen as a result of the transforms of its parents.
|
|
@@ -6450,7 +6456,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
6450
6456
|
this.relativeTargetOrigin &&
|
|
6451
6457
|
this.layout &&
|
|
6452
6458
|
((_a = this.relativeParent) === null || _a === void 0 ? void 0 : _a.layout)) {
|
|
6453
|
-
calcRelativePosition(relativeLayout, this.layout.
|
|
6459
|
+
calcRelativePosition(relativeLayout, this.layout.layoutBox, this.relativeParent.layout.layoutBox);
|
|
6454
6460
|
mixBox(this.relativeTarget, this.relativeTargetOrigin, relativeLayout, progress);
|
|
6455
6461
|
}
|
|
6456
6462
|
if (isSharedLayoutAnimation) {
|
|
@@ -6534,12 +6540,12 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
6534
6540
|
if (this !== lead &&
|
|
6535
6541
|
this.layout &&
|
|
6536
6542
|
layout &&
|
|
6537
|
-
shouldAnimatePositionOnly(this.options.animationType, this.layout.
|
|
6543
|
+
shouldAnimatePositionOnly(this.options.animationType, this.layout.layoutBox, layout.layoutBox)) {
|
|
6538
6544
|
target = this.target || createBox();
|
|
6539
|
-
const xLength = calcLength(this.layout.
|
|
6545
|
+
const xLength = calcLength(this.layout.layoutBox.x);
|
|
6540
6546
|
target.x.min = lead.target.x.min;
|
|
6541
6547
|
target.x.max = target.x.min + xLength;
|
|
6542
|
-
const yLength = calcLength(this.layout.
|
|
6548
|
+
const yLength = calcLength(this.layout.layoutBox.y);
|
|
6543
6549
|
target.y.min = lead.target.y.min;
|
|
6544
6550
|
target.y.max = target.y.min + yLength;
|
|
6545
6551
|
}
|
|
@@ -6553,7 +6559,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
6553
6559
|
/**
|
|
6554
6560
|
* Update the delta between the corrected box and the final target box, after
|
|
6555
6561
|
* 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
|
|
6562
|
+
* create a transform style that will reproject the element from its layout layout
|
|
6557
6563
|
* into the desired bounding box.
|
|
6558
6564
|
*/
|
|
6559
6565
|
calcBoxDelta(this.projectionDeltaWithTransform, this.layoutCorrected, targetWithTransforms, latestValues);
|
|
@@ -6709,7 +6715,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
6709
6715
|
}
|
|
6710
6716
|
else {
|
|
6711
6717
|
/**
|
|
6712
|
-
* Or we're not animating at all, set the lead component to its
|
|
6718
|
+
* Or we're not animating at all, set the lead component to its layout
|
|
6713
6719
|
* opacity and other components to hidden.
|
|
6714
6720
|
*/
|
|
6715
6721
|
styles.opacity =
|
|
@@ -6773,37 +6779,37 @@ function notifyLayoutUpdate(node) {
|
|
|
6773
6779
|
node.layout &&
|
|
6774
6780
|
snapshot &&
|
|
6775
6781
|
node.hasListeners("didUpdate")) {
|
|
6776
|
-
const {
|
|
6782
|
+
const { layoutBox: layout, measuredBox: measuredLayout } = node.layout;
|
|
6777
6783
|
const { animationType } = node.options;
|
|
6778
6784
|
// TODO Maybe we want to also resize the layout snapshot so we don't trigger
|
|
6779
6785
|
// animations for instance if layout="size" and an element has only changed position
|
|
6780
6786
|
if (animationType === "size") {
|
|
6781
6787
|
eachAxis((axis) => {
|
|
6782
6788
|
const axisSnapshot = snapshot.isShared
|
|
6783
|
-
? snapshot.
|
|
6784
|
-
: snapshot.
|
|
6789
|
+
? snapshot.measuredBox[axis]
|
|
6790
|
+
: snapshot.layoutBox[axis];
|
|
6785
6791
|
const length = calcLength(axisSnapshot);
|
|
6786
6792
|
axisSnapshot.min = layout[axis].min;
|
|
6787
6793
|
axisSnapshot.max = axisSnapshot.min + length;
|
|
6788
6794
|
});
|
|
6789
6795
|
}
|
|
6790
|
-
else if (shouldAnimatePositionOnly(animationType, snapshot.
|
|
6796
|
+
else if (shouldAnimatePositionOnly(animationType, snapshot.layoutBox, layout)) {
|
|
6791
6797
|
eachAxis((axis) => {
|
|
6792
6798
|
const axisSnapshot = snapshot.isShared
|
|
6793
|
-
? snapshot.
|
|
6794
|
-
: snapshot.
|
|
6799
|
+
? snapshot.measuredBox[axis]
|
|
6800
|
+
: snapshot.layoutBox[axis];
|
|
6795
6801
|
const length = calcLength(layout[axis]);
|
|
6796
6802
|
axisSnapshot.max = axisSnapshot.min + length;
|
|
6797
6803
|
});
|
|
6798
6804
|
}
|
|
6799
6805
|
const layoutDelta = createDelta();
|
|
6800
|
-
calcBoxDelta(layoutDelta, layout, snapshot.
|
|
6806
|
+
calcBoxDelta(layoutDelta, layout, snapshot.layoutBox);
|
|
6801
6807
|
const visualDelta = createDelta();
|
|
6802
6808
|
if (snapshot.isShared) {
|
|
6803
|
-
calcBoxDelta(visualDelta, node.applyTransform(measuredLayout, true), snapshot.
|
|
6809
|
+
calcBoxDelta(visualDelta, node.applyTransform(measuredLayout, true), snapshot.measuredBox);
|
|
6804
6810
|
}
|
|
6805
6811
|
else {
|
|
6806
|
-
calcBoxDelta(visualDelta, layout, snapshot.
|
|
6812
|
+
calcBoxDelta(visualDelta, layout, snapshot.layoutBox);
|
|
6807
6813
|
}
|
|
6808
6814
|
const hasLayoutChanged = !isDeltaZero(layoutDelta);
|
|
6809
6815
|
let hasRelativeTargetChanged = false;
|
|
@@ -6817,9 +6823,9 @@ function notifyLayoutUpdate(node) {
|
|
|
6817
6823
|
const { snapshot: parentSnapshot, layout: parentLayout } = relativeParent;
|
|
6818
6824
|
if (parentSnapshot && parentLayout) {
|
|
6819
6825
|
const relativeSnapshot = createBox();
|
|
6820
|
-
calcRelativePosition(relativeSnapshot, snapshot.
|
|
6826
|
+
calcRelativePosition(relativeSnapshot, snapshot.layoutBox, parentSnapshot.layoutBox);
|
|
6821
6827
|
const relativeLayout = createBox();
|
|
6822
|
-
calcRelativePosition(relativeLayout, layout, parentLayout.
|
|
6828
|
+
calcRelativePosition(relativeLayout, layout, parentLayout.layoutBox);
|
|
6823
6829
|
if (!boxEquals(relativeSnapshot, relativeLayout)) {
|
|
6824
6830
|
hasRelativeTargetChanged = true;
|
|
6825
6831
|
}
|
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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(
|
|
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
|
|
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.
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
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.
|
|
418
|
-
(_a = this.options.visualElement) === null || _a === void 0 ? void 0 : _a.notify("LayoutMeasure", this.layout.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
621
|
+
this.target = this.applyTransform(this.layout.layoutBox);
|
|
616
622
|
}
|
|
617
623
|
else {
|
|
618
|
-
copyBoxInto(this.target, this.layout.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
850
|
+
shouldAnimatePositionOnly(this.options.animationType, this.layout.layoutBox, layout.layoutBox)) {
|
|
845
851
|
target = this.target || createBox();
|
|
846
|
-
const xLength = calcLength(this.layout.
|
|
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.
|
|
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
|
|
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
|
|
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 {
|
|
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.
|
|
1091
|
-
: snapshot.
|
|
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.
|
|
1103
|
+
else if (shouldAnimatePositionOnly(animationType, snapshot.layoutBox, layout)) {
|
|
1098
1104
|
eachAxis((axis) => {
|
|
1099
1105
|
const axisSnapshot = snapshot.isShared
|
|
1100
|
-
? snapshot.
|
|
1101
|
-
: snapshot.
|
|
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.
|
|
1113
|
+
calcBoxDelta(layoutDelta, layout, snapshot.layoutBox);
|
|
1108
1114
|
const visualDelta = createDelta();
|
|
1109
1115
|
if (snapshot.isShared) {
|
|
1110
|
-
calcBoxDelta(visualDelta, node.applyTransform(measuredLayout, true), snapshot.
|
|
1116
|
+
calcBoxDelta(visualDelta, node.applyTransform(measuredLayout, true), snapshot.measuredBox);
|
|
1111
1117
|
}
|
|
1112
1118
|
else {
|
|
1113
|
-
calcBoxDelta(visualDelta, layout, snapshot.
|
|
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.
|
|
1133
|
+
calcRelativePosition(relativeSnapshot, snapshot.layoutBox, parentSnapshot.layoutBox);
|
|
1128
1134
|
const relativeLayout = createBox();
|
|
1129
|
-
calcRelativePosition(relativeLayout, layout, parentLayout.
|
|
1135
|
+
calcRelativePosition(relativeLayout, layout, parentLayout.layoutBox);
|
|
1130
1136
|
if (!boxEquals(relativeSnapshot, relativeLayout)) {
|
|
1131
1137
|
hasRelativeTargetChanged = true;
|
|
1132
1138
|
}
|
|
@@ -22,7 +22,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
22
22
|
* and warn against mismatches.
|
|
23
23
|
*/
|
|
24
24
|
if (process.env.NODE_ENV === "development") {
|
|
25
|
-
warnOnce(nextValue.version === "7.6.
|
|
25
|
+
warnOnce(nextValue.version === "7.6.6", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.6.6 may not work as expected.`);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
else if (isMotionValue(prevValue)) {
|
package/dist/es/value/index.mjs
CHANGED
|
@@ -24,7 +24,7 @@ class MotionValue {
|
|
|
24
24
|
* This will be replaced by the build step with the latest version number.
|
|
25
25
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
26
26
|
*/
|
|
27
|
-
this.version = "7.6.
|
|
27
|
+
this.version = "7.6.6";
|
|
28
28
|
/**
|
|
29
29
|
* Duration, in milliseconds, since last updating frame.
|
|
30
30
|
*
|