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 +59 -64
- package/dist/es/gestures/drag/VisualElementDragControls.mjs +5 -5
- package/dist/es/projection/node/create-projection-node.mjs +52 -46
- package/dist/es/render/VisualElement.mjs +0 -11
- 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 -64
- package/dist/framer-motion.js +1 -1
- package/dist/index.d.ts +8 -11
- package/dist/projection.dev.js +54 -59
- 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-animation.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
|
@@ -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.7", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.6.7 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.7";
|
|
28
28
|
/**
|
|
29
29
|
* Duration, in milliseconds, since last updating frame.
|
|
30
30
|
*
|
|
@@ -3426,7 +3426,7 @@
|
|
|
3426
3426
|
* This will be replaced by the build step with the latest version number.
|
|
3427
3427
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
3428
3428
|
*/
|
|
3429
|
-
this.version = "7.6.
|
|
3429
|
+
this.version = "7.6.7";
|
|
3430
3430
|
/**
|
|
3431
3431
|
* Duration, in milliseconds, since last updating frame.
|
|
3432
3432
|
*
|
|
@@ -4906,7 +4906,7 @@
|
|
|
4906
4906
|
* If the MotionValue is a percentage value convert to px
|
|
4907
4907
|
*/
|
|
4908
4908
|
if (percent.test(current)) {
|
|
4909
|
-
const measuredAxis = (_b = (_a = this.visualElement.projection) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.
|
|
4909
|
+
const measuredAxis = (_b = (_a = this.visualElement.projection) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.layoutBox[axis];
|
|
4910
4910
|
if (measuredAxis) {
|
|
4911
4911
|
const length = calcLength(measuredAxis);
|
|
4912
4912
|
current = length * (parseFloat(current) / 100);
|
|
@@ -5007,7 +5007,7 @@
|
|
|
5007
5007
|
}
|
|
5008
5008
|
else {
|
|
5009
5009
|
if (dragConstraints && layout) {
|
|
5010
|
-
this.constraints = calcRelativeConstraints(layout.
|
|
5010
|
+
this.constraints = calcRelativeConstraints(layout.layoutBox, dragConstraints);
|
|
5011
5011
|
}
|
|
5012
5012
|
else {
|
|
5013
5013
|
this.constraints = false;
|
|
@@ -5024,7 +5024,7 @@
|
|
|
5024
5024
|
!this.hasMutatedConstraints) {
|
|
5025
5025
|
eachAxis((axis) => {
|
|
5026
5026
|
if (this.getAxisMotionValue(axis)) {
|
|
5027
|
-
this.constraints[axis] = rebaseAxisConstraints(layout.
|
|
5027
|
+
this.constraints[axis] = rebaseAxisConstraints(layout.layoutBox[axis], this.constraints[axis]);
|
|
5028
5028
|
}
|
|
5029
5029
|
});
|
|
5030
5030
|
}
|
|
@@ -5040,7 +5040,7 @@
|
|
|
5040
5040
|
if (!projection || !projection.layout)
|
|
5041
5041
|
return false;
|
|
5042
5042
|
const constraintsBox = measurePageBox(constraintsElement, projection.root, this.visualElement.getTransformPagePoint());
|
|
5043
|
-
let measuredConstraints = calcViewportConstraints(projection.layout.
|
|
5043
|
+
let measuredConstraints = calcViewportConstraints(projection.layout.layoutBox, constraintsBox);
|
|
5044
5044
|
/**
|
|
5045
5045
|
* If there's an onMeasureDragConstraints listener we call it and
|
|
5046
5046
|
* if different constraints are returned, set constraints to that
|
|
@@ -5122,7 +5122,7 @@
|
|
|
5122
5122
|
const { projection } = this.visualElement;
|
|
5123
5123
|
const axisValue = this.getAxisMotionValue(axis);
|
|
5124
5124
|
if (projection && projection.layout) {
|
|
5125
|
-
const { min, max } = projection.layout.
|
|
5125
|
+
const { min, max } = projection.layout.layoutBox[axis];
|
|
5126
5126
|
axisValue.set(point[axis] - mix$1(min, max, 0.5));
|
|
5127
5127
|
}
|
|
5128
5128
|
});
|
|
@@ -5689,7 +5689,7 @@
|
|
|
5689
5689
|
* and warn against mismatches.
|
|
5690
5690
|
*/
|
|
5691
5691
|
{
|
|
5692
|
-
warnOnce(nextValue.version === "7.6.
|
|
5692
|
+
warnOnce(nextValue.version === "7.6.7", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.6.7 may not work as expected.`);
|
|
5693
5693
|
}
|
|
5694
5694
|
}
|
|
5695
5695
|
else if (isMotionValue(prevValue)) {
|
|
@@ -5843,17 +5843,6 @@
|
|
|
5843
5843
|
}
|
|
5844
5844
|
}
|
|
5845
5845
|
}
|
|
5846
|
-
/**
|
|
5847
|
-
* Update external values with initial values
|
|
5848
|
-
*/
|
|
5849
|
-
if (props.values) {
|
|
5850
|
-
for (const key in props.values) {
|
|
5851
|
-
const value = props.values[key];
|
|
5852
|
-
if (latestValues[key] !== undefined && isMotionValue(value)) {
|
|
5853
|
-
value.set(latestValues[key]);
|
|
5854
|
-
}
|
|
5855
|
-
}
|
|
5856
|
-
}
|
|
5857
5846
|
}
|
|
5858
5847
|
/**
|
|
5859
5848
|
* This method takes React props and returns found MotionValues. For example, HTML
|
|
@@ -6889,7 +6878,7 @@
|
|
|
6889
6878
|
const animationTarget = 1000;
|
|
6890
6879
|
function createProjectionNode({ attachResizeListener, defaultParent, measureScroll, checkIsScrollRoot, resetTransform, }) {
|
|
6891
6880
|
return class ProjectionNode {
|
|
6892
|
-
constructor(
|
|
6881
|
+
constructor(elementId, latestValues = {}, parent = defaultParent === null || defaultParent === void 0 ? void 0 : defaultParent()) {
|
|
6893
6882
|
/**
|
|
6894
6883
|
* A Set containing all this component's children. This is used to iterate
|
|
6895
6884
|
* through the children.
|
|
@@ -6942,7 +6931,7 @@
|
|
|
6942
6931
|
/**
|
|
6943
6932
|
* An object representing the calculated contextual/accumulated/tree scale.
|
|
6944
6933
|
* This will be used to scale calculcated projection transforms, as these are
|
|
6945
|
-
* calculated in screen-space but need to be scaled for elements to
|
|
6934
|
+
* calculated in screen-space but need to be scaled for elements to layoutly
|
|
6946
6935
|
* make it to their calculated destinations.
|
|
6947
6936
|
*
|
|
6948
6937
|
* TODO: Lazy-init
|
|
@@ -6972,13 +6961,13 @@
|
|
|
6972
6961
|
*/
|
|
6973
6962
|
// TODO Only running on root node
|
|
6974
6963
|
this.sharedNodes = new Map();
|
|
6975
|
-
this.
|
|
6964
|
+
this.elementId = elementId;
|
|
6976
6965
|
this.latestValues = latestValues;
|
|
6977
6966
|
this.root = parent ? parent.root || parent : this;
|
|
6978
6967
|
this.path = parent ? [...parent.path, parent] : [];
|
|
6979
6968
|
this.parent = parent;
|
|
6980
6969
|
this.depth = parent ? parent.depth + 1 : 0;
|
|
6981
|
-
|
|
6970
|
+
elementId && this.root.registerPotentialNode(elementId, this);
|
|
6982
6971
|
for (let i = 0; i < this.path.length; i++) {
|
|
6983
6972
|
this.path[i].shouldResetTransform = true;
|
|
6984
6973
|
}
|
|
@@ -7017,7 +7006,7 @@
|
|
|
7017
7006
|
}
|
|
7018
7007
|
this.root.nodes.add(this);
|
|
7019
7008
|
(_a = this.parent) === null || _a === void 0 ? void 0 : _a.children.add(this);
|
|
7020
|
-
this.
|
|
7009
|
+
this.elementId && this.root.potentialNodes.delete(this.elementId);
|
|
7021
7010
|
if (isLayoutDirty && (layout || layoutId)) {
|
|
7022
7011
|
this.isLayoutDirty = true;
|
|
7023
7012
|
}
|
|
@@ -7233,14 +7222,7 @@
|
|
|
7233
7222
|
updateSnapshot() {
|
|
7234
7223
|
if (this.snapshot || !this.instance)
|
|
7235
7224
|
return;
|
|
7236
|
-
|
|
7237
|
-
const layout = this.removeTransform(this.removeElementScroll(measured));
|
|
7238
|
-
roundBox(layout);
|
|
7239
|
-
this.snapshot = {
|
|
7240
|
-
measured,
|
|
7241
|
-
layout,
|
|
7242
|
-
latestValues: {},
|
|
7243
|
-
};
|
|
7225
|
+
this.snapshot = this.measure();
|
|
7244
7226
|
}
|
|
7245
7227
|
updateLayout() {
|
|
7246
7228
|
var _a;
|
|
@@ -7265,18 +7247,13 @@
|
|
|
7265
7247
|
node.updateScroll();
|
|
7266
7248
|
}
|
|
7267
7249
|
}
|
|
7268
|
-
const measured = this.measure();
|
|
7269
|
-
roundBox(measured);
|
|
7270
7250
|
const prevLayout = this.layout;
|
|
7271
|
-
this.layout =
|
|
7272
|
-
measured,
|
|
7273
|
-
actual: this.removeElementScroll(measured),
|
|
7274
|
-
};
|
|
7251
|
+
this.layout = this.measure(false);
|
|
7275
7252
|
this.layoutCorrected = createBox();
|
|
7276
7253
|
this.isLayoutDirty = false;
|
|
7277
7254
|
this.projectionDelta = undefined;
|
|
7278
|
-
this.notifyListeners("measure", this.layout.
|
|
7279
|
-
(_a = this.options.visualElement) === null || _a === void 0 ? void 0 : _a.notify("LayoutMeasure", this.layout.
|
|
7255
|
+
this.notifyListeners("measure", this.layout.layoutBox);
|
|
7256
|
+
(_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);
|
|
7280
7257
|
}
|
|
7281
7258
|
updateScroll() {
|
|
7282
7259
|
if (this.options.layoutScroll && this.instance) {
|
|
@@ -7302,7 +7279,25 @@
|
|
|
7302
7279
|
this.scheduleRender();
|
|
7303
7280
|
}
|
|
7304
7281
|
}
|
|
7305
|
-
measure() {
|
|
7282
|
+
measure(removeTransform = true) {
|
|
7283
|
+
const pageBox = this.measurePageBox();
|
|
7284
|
+
let layoutBox = this.removeElementScroll(pageBox);
|
|
7285
|
+
/**
|
|
7286
|
+
* Measurements taken during the pre-render stage
|
|
7287
|
+
* still have transforms applied so we remove them
|
|
7288
|
+
* via calculation.
|
|
7289
|
+
*/
|
|
7290
|
+
if (removeTransform) {
|
|
7291
|
+
layoutBox = this.removeTransform(layoutBox);
|
|
7292
|
+
}
|
|
7293
|
+
roundBox(layoutBox);
|
|
7294
|
+
return {
|
|
7295
|
+
measuredBox: pageBox,
|
|
7296
|
+
layoutBox,
|
|
7297
|
+
latestValues: {},
|
|
7298
|
+
};
|
|
7299
|
+
}
|
|
7300
|
+
measurePageBox() {
|
|
7306
7301
|
const { visualElement } = this.options;
|
|
7307
7302
|
if (!visualElement)
|
|
7308
7303
|
return createBox();
|
|
@@ -7383,9 +7378,9 @@
|
|
|
7383
7378
|
continue;
|
|
7384
7379
|
hasScale(node.latestValues) && node.updateSnapshot();
|
|
7385
7380
|
const sourceBox = createBox();
|
|
7386
|
-
const nodeBox = node.
|
|
7381
|
+
const nodeBox = node.measurePageBox();
|
|
7387
7382
|
copyBoxInto(sourceBox, nodeBox);
|
|
7388
|
-
removeBoxTransforms(boxWithoutTransform, node.latestValues, (_a = node.snapshot) === null || _a === void 0 ? void 0 : _a.
|
|
7383
|
+
removeBoxTransforms(boxWithoutTransform, node.latestValues, (_a = node.snapshot) === null || _a === void 0 ? void 0 : _a.layoutBox, sourceBox);
|
|
7389
7384
|
}
|
|
7390
7385
|
if (hasTransform(this.latestValues)) {
|
|
7391
7386
|
removeBoxTransforms(boxWithoutTransform, this.latestValues);
|
|
@@ -7439,7 +7434,7 @@
|
|
|
7439
7434
|
this.relativeParent = relativeParent;
|
|
7440
7435
|
this.relativeTarget = createBox();
|
|
7441
7436
|
this.relativeTargetOrigin = createBox();
|
|
7442
|
-
calcRelativePosition(this.relativeTargetOrigin, this.layout.
|
|
7437
|
+
calcRelativePosition(this.relativeTargetOrigin, this.layout.layoutBox, relativeParent.layout.layoutBox);
|
|
7443
7438
|
copyBoxInto(this.relativeTarget, this.relativeTargetOrigin);
|
|
7444
7439
|
}
|
|
7445
7440
|
else {
|
|
@@ -7473,10 +7468,10 @@
|
|
|
7473
7468
|
else if (this.targetDelta) {
|
|
7474
7469
|
if (Boolean(this.resumingFrom)) {
|
|
7475
7470
|
// TODO: This is creating a new object every frame
|
|
7476
|
-
this.target = this.applyTransform(this.layout.
|
|
7471
|
+
this.target = this.applyTransform(this.layout.layoutBox);
|
|
7477
7472
|
}
|
|
7478
7473
|
else {
|
|
7479
|
-
copyBoxInto(this.target, this.layout.
|
|
7474
|
+
copyBoxInto(this.target, this.layout.layoutBox);
|
|
7480
7475
|
}
|
|
7481
7476
|
applyBoxDelta(this.target, this.targetDelta);
|
|
7482
7477
|
}
|
|
@@ -7484,7 +7479,7 @@
|
|
|
7484
7479
|
/**
|
|
7485
7480
|
* If no target, use own layout as target
|
|
7486
7481
|
*/
|
|
7487
|
-
copyBoxInto(this.target, this.layout.
|
|
7482
|
+
copyBoxInto(this.target, this.layout.layoutBox);
|
|
7488
7483
|
}
|
|
7489
7484
|
/**
|
|
7490
7485
|
* If we've been told to attempt to resolve a relative target, do so.
|
|
@@ -7541,7 +7536,7 @@
|
|
|
7541
7536
|
* Reset the corrected box with the latest values from box, as we're then going
|
|
7542
7537
|
* to perform mutative operations on it.
|
|
7543
7538
|
*/
|
|
7544
|
-
copyBoxInto(this.layoutCorrected, this.layout.
|
|
7539
|
+
copyBoxInto(this.layoutCorrected, this.layout.layoutBox);
|
|
7545
7540
|
/**
|
|
7546
7541
|
* Apply all the parent deltas to this box to produce the corrected box. This
|
|
7547
7542
|
* is the layout box, as it will appear on screen as a result of the transforms of its parents.
|
|
@@ -7618,7 +7613,7 @@
|
|
|
7618
7613
|
this.relativeTargetOrigin &&
|
|
7619
7614
|
this.layout &&
|
|
7620
7615
|
((_a = this.relativeParent) === null || _a === void 0 ? void 0 : _a.layout)) {
|
|
7621
|
-
calcRelativePosition(relativeLayout, this.layout.
|
|
7616
|
+
calcRelativePosition(relativeLayout, this.layout.layoutBox, this.relativeParent.layout.layoutBox);
|
|
7622
7617
|
mixBox(this.relativeTarget, this.relativeTargetOrigin, relativeLayout, progress);
|
|
7623
7618
|
}
|
|
7624
7619
|
if (isSharedLayoutAnimation) {
|
|
@@ -7702,12 +7697,12 @@
|
|
|
7702
7697
|
if (this !== lead &&
|
|
7703
7698
|
this.layout &&
|
|
7704
7699
|
layout &&
|
|
7705
|
-
shouldAnimatePositionOnly(this.options.animationType, this.layout.
|
|
7700
|
+
shouldAnimatePositionOnly(this.options.animationType, this.layout.layoutBox, layout.layoutBox)) {
|
|
7706
7701
|
target = this.target || createBox();
|
|
7707
|
-
const xLength = calcLength(this.layout.
|
|
7702
|
+
const xLength = calcLength(this.layout.layoutBox.x);
|
|
7708
7703
|
target.x.min = lead.target.x.min;
|
|
7709
7704
|
target.x.max = target.x.min + xLength;
|
|
7710
|
-
const yLength = calcLength(this.layout.
|
|
7705
|
+
const yLength = calcLength(this.layout.layoutBox.y);
|
|
7711
7706
|
target.y.min = lead.target.y.min;
|
|
7712
7707
|
target.y.max = target.y.min + yLength;
|
|
7713
7708
|
}
|
|
@@ -7721,7 +7716,7 @@
|
|
|
7721
7716
|
/**
|
|
7722
7717
|
* Update the delta between the corrected box and the final target box, after
|
|
7723
7718
|
* user-set transforms are applied to it. This will be used by the renderer to
|
|
7724
|
-
* create a transform style that will reproject the element from its
|
|
7719
|
+
* create a transform style that will reproject the element from its layout layout
|
|
7725
7720
|
* into the desired bounding box.
|
|
7726
7721
|
*/
|
|
7727
7722
|
calcBoxDelta(this.projectionDeltaWithTransform, this.layoutCorrected, targetWithTransforms, latestValues);
|
|
@@ -7877,7 +7872,7 @@
|
|
|
7877
7872
|
}
|
|
7878
7873
|
else {
|
|
7879
7874
|
/**
|
|
7880
|
-
* Or we're not animating at all, set the lead component to its
|
|
7875
|
+
* Or we're not animating at all, set the lead component to its layout
|
|
7881
7876
|
* opacity and other components to hidden.
|
|
7882
7877
|
*/
|
|
7883
7878
|
styles.opacity =
|
|
@@ -7941,37 +7936,37 @@
|
|
|
7941
7936
|
node.layout &&
|
|
7942
7937
|
snapshot &&
|
|
7943
7938
|
node.hasListeners("didUpdate")) {
|
|
7944
|
-
const {
|
|
7939
|
+
const { layoutBox: layout, measuredBox: measuredLayout } = node.layout;
|
|
7945
7940
|
const { animationType } = node.options;
|
|
7946
7941
|
// TODO Maybe we want to also resize the layout snapshot so we don't trigger
|
|
7947
7942
|
// animations for instance if layout="size" and an element has only changed position
|
|
7948
7943
|
if (animationType === "size") {
|
|
7949
7944
|
eachAxis((axis) => {
|
|
7950
7945
|
const axisSnapshot = snapshot.isShared
|
|
7951
|
-
? snapshot.
|
|
7952
|
-
: snapshot.
|
|
7946
|
+
? snapshot.measuredBox[axis]
|
|
7947
|
+
: snapshot.layoutBox[axis];
|
|
7953
7948
|
const length = calcLength(axisSnapshot);
|
|
7954
7949
|
axisSnapshot.min = layout[axis].min;
|
|
7955
7950
|
axisSnapshot.max = axisSnapshot.min + length;
|
|
7956
7951
|
});
|
|
7957
7952
|
}
|
|
7958
|
-
else if (shouldAnimatePositionOnly(animationType, snapshot.
|
|
7953
|
+
else if (shouldAnimatePositionOnly(animationType, snapshot.layoutBox, layout)) {
|
|
7959
7954
|
eachAxis((axis) => {
|
|
7960
7955
|
const axisSnapshot = snapshot.isShared
|
|
7961
|
-
? snapshot.
|
|
7962
|
-
: snapshot.
|
|
7956
|
+
? snapshot.measuredBox[axis]
|
|
7957
|
+
: snapshot.layoutBox[axis];
|
|
7963
7958
|
const length = calcLength(layout[axis]);
|
|
7964
7959
|
axisSnapshot.max = axisSnapshot.min + length;
|
|
7965
7960
|
});
|
|
7966
7961
|
}
|
|
7967
7962
|
const layoutDelta = createDelta();
|
|
7968
|
-
calcBoxDelta(layoutDelta, layout, snapshot.
|
|
7963
|
+
calcBoxDelta(layoutDelta, layout, snapshot.layoutBox);
|
|
7969
7964
|
const visualDelta = createDelta();
|
|
7970
7965
|
if (snapshot.isShared) {
|
|
7971
|
-
calcBoxDelta(visualDelta, node.applyTransform(measuredLayout, true), snapshot.
|
|
7966
|
+
calcBoxDelta(visualDelta, node.applyTransform(measuredLayout, true), snapshot.measuredBox);
|
|
7972
7967
|
}
|
|
7973
7968
|
else {
|
|
7974
|
-
calcBoxDelta(visualDelta, layout, snapshot.
|
|
7969
|
+
calcBoxDelta(visualDelta, layout, snapshot.layoutBox);
|
|
7975
7970
|
}
|
|
7976
7971
|
const hasLayoutChanged = !isDeltaZero(layoutDelta);
|
|
7977
7972
|
let hasRelativeTargetChanged = false;
|
|
@@ -7985,9 +7980,9 @@
|
|
|
7985
7980
|
const { snapshot: parentSnapshot, layout: parentLayout } = relativeParent;
|
|
7986
7981
|
if (parentSnapshot && parentLayout) {
|
|
7987
7982
|
const relativeSnapshot = createBox();
|
|
7988
|
-
calcRelativePosition(relativeSnapshot, snapshot.
|
|
7983
|
+
calcRelativePosition(relativeSnapshot, snapshot.layoutBox, parentSnapshot.layoutBox);
|
|
7989
7984
|
const relativeLayout = createBox();
|
|
7990
|
-
calcRelativePosition(relativeLayout, layout, parentLayout.
|
|
7985
|
+
calcRelativePosition(relativeLayout, layout, parentLayout.layoutBox);
|
|
7991
7986
|
if (!boxEquals(relativeSnapshot, relativeLayout)) {
|
|
7992
7987
|
hasRelativeTargetChanged = true;
|
|
7993
7988
|
}
|