framer-motion 7.2.1 → 7.3.2
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 +65 -6
- package/dist/es/index.mjs +2 -0
- package/dist/es/motion/index.mjs +4 -1
- package/dist/es/motion/utils/is-motion-component.mjs +12 -0
- package/dist/es/motion/utils/symbol.mjs +3 -0
- package/dist/es/motion/utils/unwrap-motion-component.mjs +17 -0
- package/dist/es/projection/geometry/utils.mjs +10 -1
- package/dist/es/projection/node/create-projection-node.mjs +28 -4
- package/dist/es/render/html/utils/transform.mjs +1 -0
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/value/index.mjs +1 -1
- package/dist/framer-motion.dev.js +65 -6
- package/dist/framer-motion.js +1 -1
- package/dist/index.d.ts +19 -3
- package/dist/projection.dev.js +36 -5
- package/dist/size-rollup-dom-animation-assets.js +1 -1
- package/dist/size-rollup-dom-animation-m.js +1 -1
- package/dist/size-rollup-dom-animation.js +1 -1
- package/dist/size-rollup-dom-max-assets.js +1 -1
- package/dist/size-rollup-dom-max.js +1 -1
- package/dist/size-rollup-m.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/size-webpack-m.js +1 -1
- package/dist/three-entry.d.ts +5 -2
- package/package.json +5 -5
package/dist/cjs/index.js
CHANGED
|
@@ -286,6 +286,8 @@ class VisualElementHandler extends React__default["default"].Component {
|
|
|
286
286
|
*/
|
|
287
287
|
const SwitchLayoutGroupContext = React.createContext({});
|
|
288
288
|
|
|
289
|
+
const motionComponentSymbol = Symbol.for("motionComponentSymbol");
|
|
290
|
+
|
|
289
291
|
/**
|
|
290
292
|
* Create a `motion` component.
|
|
291
293
|
*
|
|
@@ -349,7 +351,9 @@ function createMotionComponent({ preloadedFeatures, createVisualElement, project
|
|
|
349
351
|
features,
|
|
350
352
|
React__namespace.createElement(MotionContext.Provider, { value: context }, useRender(Component, props, projectionId, useMotionRef(visualState, context.visualElement, externalRef), visualState, isStatic, context.visualElement))));
|
|
351
353
|
}
|
|
352
|
-
|
|
354
|
+
const ForwardRefComponent = React.forwardRef(MotionComponent);
|
|
355
|
+
ForwardRefComponent[motionComponentSymbol] = Component;
|
|
356
|
+
return ForwardRefComponent;
|
|
353
357
|
}
|
|
354
358
|
function useLayoutId({ layoutId }) {
|
|
355
359
|
const layoutGroupId = React.useContext(LayoutGroupContext).id;
|
|
@@ -483,6 +487,7 @@ const transformPropOrder = [
|
|
|
483
487
|
"rotate",
|
|
484
488
|
"rotateX",
|
|
485
489
|
"rotateY",
|
|
490
|
+
"rotateZ",
|
|
486
491
|
"skew",
|
|
487
492
|
"skewX",
|
|
488
493
|
"skewY",
|
|
@@ -2235,7 +2240,7 @@ class MotionValue {
|
|
|
2235
2240
|
* This will be replaced by the build step with the latest version number.
|
|
2236
2241
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
2237
2242
|
*/
|
|
2238
|
-
this.version = "7.2
|
|
2243
|
+
this.version = "7.3.2";
|
|
2239
2244
|
/**
|
|
2240
2245
|
* Duration, in milliseconds, since last updating frame.
|
|
2241
2246
|
*
|
|
@@ -4211,7 +4216,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
4211
4216
|
* and warn against mismatches.
|
|
4212
4217
|
*/
|
|
4213
4218
|
if (process.env.NODE_ENV === "development") {
|
|
4214
|
-
warnOnce(nextValue.version === "7.2
|
|
4219
|
+
warnOnce(nextValue.version === "7.3.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.3.2 may not work as expected.`);
|
|
4215
4220
|
}
|
|
4216
4221
|
}
|
|
4217
4222
|
else if (isMotionValue(prevValue)) {
|
|
@@ -5563,6 +5568,12 @@ function boxEquals(a, b) {
|
|
|
5563
5568
|
a.y.min === b.y.min &&
|
|
5564
5569
|
a.y.max === b.y.max);
|
|
5565
5570
|
}
|
|
5571
|
+
function aspectRatio(box) {
|
|
5572
|
+
return calcLength(box.x) / calcLength(box.y);
|
|
5573
|
+
}
|
|
5574
|
+
function isCloseTo(a, b, max = 0.01) {
|
|
5575
|
+
return popmotion.distance(a, b) <= max;
|
|
5576
|
+
}
|
|
5566
5577
|
|
|
5567
5578
|
class NodeStack {
|
|
5568
5579
|
constructor() {
|
|
@@ -6528,9 +6539,27 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
6528
6539
|
this.completeAnimation();
|
|
6529
6540
|
}
|
|
6530
6541
|
applyTransformsToTarget() {
|
|
6531
|
-
const
|
|
6542
|
+
const lead = this.getLead();
|
|
6543
|
+
let { targetWithTransforms, target, layout, latestValues } = lead;
|
|
6532
6544
|
if (!targetWithTransforms || !target || !layout)
|
|
6533
6545
|
return;
|
|
6546
|
+
/**
|
|
6547
|
+
* If we're only animating position, and this element isn't the lead element,
|
|
6548
|
+
* then instead of projecting into the lead box we instead want to calculate
|
|
6549
|
+
* a new target that aligns the two boxes but maintains the layout shape.
|
|
6550
|
+
*/
|
|
6551
|
+
if (this !== lead &&
|
|
6552
|
+
this.layout &&
|
|
6553
|
+
layout &&
|
|
6554
|
+
shouldAnimatePositionOnly(this.options.animationType, this.layout.actual, layout.actual)) {
|
|
6555
|
+
target = this.target || createBox();
|
|
6556
|
+
const xLength = calcLength(this.layout.actual.x);
|
|
6557
|
+
target.x.min = lead.target.x.min;
|
|
6558
|
+
target.x.max = target.x.min + xLength;
|
|
6559
|
+
const yLength = calcLength(this.layout.actual.y);
|
|
6560
|
+
target.y.min = lead.target.y.min;
|
|
6561
|
+
target.y.max = target.y.min + yLength;
|
|
6562
|
+
}
|
|
6534
6563
|
copyBoxInto(targetWithTransforms, target);
|
|
6535
6564
|
/**
|
|
6536
6565
|
* Apply the latest user-set transforms to the targetBox to produce the targetBoxFinal.
|
|
@@ -6762,9 +6791,10 @@ function notifyLayoutUpdate(node) {
|
|
|
6762
6791
|
snapshot &&
|
|
6763
6792
|
node.hasListeners("didUpdate")) {
|
|
6764
6793
|
const { actual: layout, measured: measuredLayout } = node.layout;
|
|
6794
|
+
const { animationType } = node.options;
|
|
6765
6795
|
// TODO Maybe we want to also resize the layout snapshot so we don't trigger
|
|
6766
6796
|
// animations for instance if layout="size" and an element has only changed position
|
|
6767
|
-
if (
|
|
6797
|
+
if (animationType === "size") {
|
|
6768
6798
|
eachAxis((axis) => {
|
|
6769
6799
|
const axisSnapshot = snapshot.isShared
|
|
6770
6800
|
? snapshot.measured[axis]
|
|
@@ -6774,7 +6804,7 @@ function notifyLayoutUpdate(node) {
|
|
|
6774
6804
|
axisSnapshot.max = axisSnapshot.min + length;
|
|
6775
6805
|
});
|
|
6776
6806
|
}
|
|
6777
|
-
else if (
|
|
6807
|
+
else if (shouldAnimatePositionOnly(animationType, snapshot.layout, layout)) {
|
|
6778
6808
|
eachAxis((axis) => {
|
|
6779
6809
|
const axisSnapshot = snapshot.isShared
|
|
6780
6810
|
? snapshot.measured[axis]
|
|
@@ -6907,6 +6937,11 @@ function roundBox(box) {
|
|
|
6907
6937
|
roundAxis(box.x);
|
|
6908
6938
|
roundAxis(box.y);
|
|
6909
6939
|
}
|
|
6940
|
+
function shouldAnimatePositionOnly(animationType, snapshot, layout) {
|
|
6941
|
+
return (animationType === "position" ||
|
|
6942
|
+
(animationType === "preserve-aspect" &&
|
|
6943
|
+
!isCloseTo(aspectRatio(snapshot), aspectRatio(layout))));
|
|
6944
|
+
}
|
|
6910
6945
|
|
|
6911
6946
|
const DocumentProjectionNode = createProjectionNode({
|
|
6912
6947
|
attachResizeListener: (ref, notify) => addDomEvent(ref, "resize", notify),
|
|
@@ -8168,6 +8203,28 @@ function useDragControls() {
|
|
|
8168
8203
|
return useConstant(createDragControls);
|
|
8169
8204
|
}
|
|
8170
8205
|
|
|
8206
|
+
/**
|
|
8207
|
+
* Checks if a component is a `motion` component.
|
|
8208
|
+
*/
|
|
8209
|
+
function isMotionComponent(component) {
|
|
8210
|
+
return (component !== null &&
|
|
8211
|
+
typeof component === "object" &&
|
|
8212
|
+
motionComponentSymbol in component);
|
|
8213
|
+
}
|
|
8214
|
+
|
|
8215
|
+
/**
|
|
8216
|
+
* Unwraps a `motion` component and returns either a string for `motion.div` or
|
|
8217
|
+
* the React component for `motion(Component)`.
|
|
8218
|
+
*
|
|
8219
|
+
* If the component is not a `motion` component it returns undefined.
|
|
8220
|
+
*/
|
|
8221
|
+
function unwrapMotionComponent(component) {
|
|
8222
|
+
if (isMotionComponent(component)) {
|
|
8223
|
+
return component[motionComponentSymbol];
|
|
8224
|
+
}
|
|
8225
|
+
return undefined;
|
|
8226
|
+
}
|
|
8227
|
+
|
|
8171
8228
|
function useInstantLayoutTransition() {
|
|
8172
8229
|
return startTransition;
|
|
8173
8230
|
}
|
|
@@ -8330,6 +8387,7 @@ exports.domMax = domMax;
|
|
|
8330
8387
|
exports.filterProps = filterProps;
|
|
8331
8388
|
exports.isBrowser = isBrowser;
|
|
8332
8389
|
exports.isDragActive = isDragActive;
|
|
8390
|
+
exports.isMotionComponent = isMotionComponent;
|
|
8333
8391
|
exports.isMotionValue = isMotionValue;
|
|
8334
8392
|
exports.isValidMotionProp = isValidMotionProp;
|
|
8335
8393
|
exports.m = m;
|
|
@@ -8338,6 +8396,7 @@ exports.motion = motion;
|
|
|
8338
8396
|
exports.motionValue = motionValue;
|
|
8339
8397
|
exports.resolveMotionValue = resolveMotionValue;
|
|
8340
8398
|
exports.transform = transform;
|
|
8399
|
+
exports.unwrapMotionComponent = unwrapMotionComponent;
|
|
8341
8400
|
exports.useAnimation = useAnimation;
|
|
8342
8401
|
exports.useAnimationControls = useAnimationControls;
|
|
8343
8402
|
exports.useAnimationFrame = useAnimationFrame;
|
package/dist/es/index.mjs
CHANGED
|
@@ -35,6 +35,8 @@ export { useInView } from './utils/use-in-view.mjs';
|
|
|
35
35
|
export { DragControls, useDragControls } from './gestures/drag/use-drag-controls.mjs';
|
|
36
36
|
export { useDomEvent } from './events/use-dom-event.mjs';
|
|
37
37
|
export { createMotionComponent } from './motion/index.mjs';
|
|
38
|
+
export { isMotionComponent } from './motion/utils/is-motion-component.mjs';
|
|
39
|
+
export { unwrapMotionComponent } from './motion/utils/unwrap-motion-component.mjs';
|
|
38
40
|
export { visualElement } from './render/index.mjs';
|
|
39
41
|
export { addScaleCorrector } from './projection/styles/scale-correction.mjs';
|
|
40
42
|
export { useInstantTransition } from './utils/use-instant-transition.mjs';
|
package/dist/es/motion/index.mjs
CHANGED
|
@@ -13,6 +13,7 @@ import { LayoutGroupContext } from '../context/LayoutGroupContext.mjs';
|
|
|
13
13
|
import { VisualElementHandler } from './utils/VisualElementHandler.mjs';
|
|
14
14
|
import { LazyContext } from '../context/LazyContext.mjs';
|
|
15
15
|
import { SwitchLayoutGroupContext } from '../context/SwitchLayoutGroupContext.mjs';
|
|
16
|
+
import { motionComponentSymbol } from './utils/symbol.mjs';
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Create a `motion` component.
|
|
@@ -77,7 +78,9 @@ function createMotionComponent({ preloadedFeatures, createVisualElement, project
|
|
|
77
78
|
features,
|
|
78
79
|
React.createElement(MotionContext.Provider, { value: context }, useRender(Component, props, projectionId, useMotionRef(visualState, context.visualElement, externalRef), visualState, isStatic, context.visualElement))));
|
|
79
80
|
}
|
|
80
|
-
|
|
81
|
+
const ForwardRefComponent = forwardRef(MotionComponent);
|
|
82
|
+
ForwardRefComponent[motionComponentSymbol] = Component;
|
|
83
|
+
return ForwardRefComponent;
|
|
81
84
|
}
|
|
82
85
|
function useLayoutId({ layoutId }) {
|
|
83
86
|
const layoutGroupId = useContext(LayoutGroupContext).id;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { motionComponentSymbol } from './symbol.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Checks if a component is a `motion` component.
|
|
5
|
+
*/
|
|
6
|
+
function isMotionComponent(component) {
|
|
7
|
+
return (component !== null &&
|
|
8
|
+
typeof component === "object" &&
|
|
9
|
+
motionComponentSymbol in component);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { isMotionComponent };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { isMotionComponent } from './is-motion-component.mjs';
|
|
2
|
+
import { motionComponentSymbol } from './symbol.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Unwraps a `motion` component and returns either a string for `motion.div` or
|
|
6
|
+
* the React component for `motion(Component)`.
|
|
7
|
+
*
|
|
8
|
+
* If the component is not a `motion` component it returns undefined.
|
|
9
|
+
*/
|
|
10
|
+
function unwrapMotionComponent(component) {
|
|
11
|
+
if (isMotionComponent(component)) {
|
|
12
|
+
return component[motionComponentSymbol];
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { unwrapMotionComponent };
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { distance } from 'popmotion';
|
|
2
|
+
import { calcLength } from './delta-calc.mjs';
|
|
3
|
+
|
|
1
4
|
function isAxisDeltaZero(delta) {
|
|
2
5
|
return delta.translate === 0 && delta.scale === 1;
|
|
3
6
|
}
|
|
@@ -10,5 +13,11 @@ function boxEquals(a, b) {
|
|
|
10
13
|
a.y.min === b.y.min &&
|
|
11
14
|
a.y.max === b.y.max);
|
|
12
15
|
}
|
|
16
|
+
function aspectRatio(box) {
|
|
17
|
+
return calcLength(box.x) / calcLength(box.y);
|
|
18
|
+
}
|
|
19
|
+
function isCloseTo(a, b, max = 0.01) {
|
|
20
|
+
return distance(a, b) <= max;
|
|
21
|
+
}
|
|
13
22
|
|
|
14
|
-
export { boxEquals, isDeltaZero };
|
|
23
|
+
export { aspectRatio, boxEquals, isCloseTo, isDeltaZero };
|
|
@@ -9,7 +9,7 @@ import { calcRelativePosition, calcRelativeBox, calcBoxDelta, calcLength } from
|
|
|
9
9
|
import { removeBoxTransforms } from '../geometry/delta-remove.mjs';
|
|
10
10
|
import { createBox, createDelta } from '../geometry/models.mjs';
|
|
11
11
|
import { getValueTransition } from '../../animation/utils/transitions.mjs';
|
|
12
|
-
import { boxEquals, isDeltaZero } from '../geometry/utils.mjs';
|
|
12
|
+
import { boxEquals, isDeltaZero, isCloseTo, aspectRatio } from '../geometry/utils.mjs';
|
|
13
13
|
import { NodeStack } from '../shared/stack.mjs';
|
|
14
14
|
import { scaleCorrectors } from '../styles/scale-correction.mjs';
|
|
15
15
|
import { buildProjectionTransform } from '../styles/transform.mjs';
|
|
@@ -818,9 +818,27 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
818
818
|
this.completeAnimation();
|
|
819
819
|
}
|
|
820
820
|
applyTransformsToTarget() {
|
|
821
|
-
const
|
|
821
|
+
const lead = this.getLead();
|
|
822
|
+
let { targetWithTransforms, target, layout, latestValues } = lead;
|
|
822
823
|
if (!targetWithTransforms || !target || !layout)
|
|
823
824
|
return;
|
|
825
|
+
/**
|
|
826
|
+
* If we're only animating position, and this element isn't the lead element,
|
|
827
|
+
* then instead of projecting into the lead box we instead want to calculate
|
|
828
|
+
* a new target that aligns the two boxes but maintains the layout shape.
|
|
829
|
+
*/
|
|
830
|
+
if (this !== lead &&
|
|
831
|
+
this.layout &&
|
|
832
|
+
layout &&
|
|
833
|
+
shouldAnimatePositionOnly(this.options.animationType, this.layout.actual, layout.actual)) {
|
|
834
|
+
target = this.target || createBox();
|
|
835
|
+
const xLength = calcLength(this.layout.actual.x);
|
|
836
|
+
target.x.min = lead.target.x.min;
|
|
837
|
+
target.x.max = target.x.min + xLength;
|
|
838
|
+
const yLength = calcLength(this.layout.actual.y);
|
|
839
|
+
target.y.min = lead.target.y.min;
|
|
840
|
+
target.y.max = target.y.min + yLength;
|
|
841
|
+
}
|
|
824
842
|
copyBoxInto(targetWithTransforms, target);
|
|
825
843
|
/**
|
|
826
844
|
* Apply the latest user-set transforms to the targetBox to produce the targetBoxFinal.
|
|
@@ -1052,9 +1070,10 @@ function notifyLayoutUpdate(node) {
|
|
|
1052
1070
|
snapshot &&
|
|
1053
1071
|
node.hasListeners("didUpdate")) {
|
|
1054
1072
|
const { actual: layout, measured: measuredLayout } = node.layout;
|
|
1073
|
+
const { animationType } = node.options;
|
|
1055
1074
|
// TODO Maybe we want to also resize the layout snapshot so we don't trigger
|
|
1056
1075
|
// animations for instance if layout="size" and an element has only changed position
|
|
1057
|
-
if (
|
|
1076
|
+
if (animationType === "size") {
|
|
1058
1077
|
eachAxis((axis) => {
|
|
1059
1078
|
const axisSnapshot = snapshot.isShared
|
|
1060
1079
|
? snapshot.measured[axis]
|
|
@@ -1064,7 +1083,7 @@ function notifyLayoutUpdate(node) {
|
|
|
1064
1083
|
axisSnapshot.max = axisSnapshot.min + length;
|
|
1065
1084
|
});
|
|
1066
1085
|
}
|
|
1067
|
-
else if (
|
|
1086
|
+
else if (shouldAnimatePositionOnly(animationType, snapshot.layout, layout)) {
|
|
1068
1087
|
eachAxis((axis) => {
|
|
1069
1088
|
const axisSnapshot = snapshot.isShared
|
|
1070
1089
|
? snapshot.measured[axis]
|
|
@@ -1197,5 +1216,10 @@ function roundBox(box) {
|
|
|
1197
1216
|
roundAxis(box.x);
|
|
1198
1217
|
roundAxis(box.y);
|
|
1199
1218
|
}
|
|
1219
|
+
function shouldAnimatePositionOnly(animationType, snapshot, layout) {
|
|
1220
|
+
return (animationType === "position" ||
|
|
1221
|
+
(animationType === "preserve-aspect" &&
|
|
1222
|
+
!isCloseTo(aspectRatio(snapshot), aspectRatio(layout))));
|
|
1223
|
+
}
|
|
1200
1224
|
|
|
1201
1225
|
export { createProjectionNode, mixAxis, mixAxisDelta, mixBox };
|
|
@@ -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.2
|
|
25
|
+
warnOnce(nextValue.version === "7.3.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.3.2 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.2
|
|
27
|
+
this.version = "7.3.2";
|
|
28
28
|
/**
|
|
29
29
|
* Duration, in milliseconds, since last updating frame.
|
|
30
30
|
*
|
|
@@ -280,6 +280,8 @@
|
|
|
280
280
|
*/
|
|
281
281
|
const SwitchLayoutGroupContext = React.createContext({});
|
|
282
282
|
|
|
283
|
+
const motionComponentSymbol = Symbol.for("motionComponentSymbol");
|
|
284
|
+
|
|
283
285
|
/**
|
|
284
286
|
* Create a `motion` component.
|
|
285
287
|
*
|
|
@@ -343,7 +345,9 @@
|
|
|
343
345
|
features,
|
|
344
346
|
React__namespace.createElement(MotionContext.Provider, { value: context }, useRender(Component, props, projectionId, useMotionRef(visualState, context.visualElement, externalRef), visualState, isStatic, context.visualElement))));
|
|
345
347
|
}
|
|
346
|
-
|
|
348
|
+
const ForwardRefComponent = React.forwardRef(MotionComponent);
|
|
349
|
+
ForwardRefComponent[motionComponentSymbol] = Component;
|
|
350
|
+
return ForwardRefComponent;
|
|
347
351
|
}
|
|
348
352
|
function useLayoutId({ layoutId }) {
|
|
349
353
|
const layoutGroupId = React.useContext(LayoutGroupContext).id;
|
|
@@ -477,6 +481,7 @@
|
|
|
477
481
|
"rotate",
|
|
478
482
|
"rotateX",
|
|
479
483
|
"rotateY",
|
|
484
|
+
"rotateZ",
|
|
480
485
|
"skew",
|
|
481
486
|
"skewX",
|
|
482
487
|
"skewY",
|
|
@@ -3403,7 +3408,7 @@
|
|
|
3403
3408
|
* This will be replaced by the build step with the latest version number.
|
|
3404
3409
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
3405
3410
|
*/
|
|
3406
|
-
this.version = "7.2
|
|
3411
|
+
this.version = "7.3.2";
|
|
3407
3412
|
/**
|
|
3408
3413
|
* Duration, in milliseconds, since last updating frame.
|
|
3409
3414
|
*
|
|
@@ -5379,7 +5384,7 @@
|
|
|
5379
5384
|
* and warn against mismatches.
|
|
5380
5385
|
*/
|
|
5381
5386
|
{
|
|
5382
|
-
warnOnce(nextValue.version === "7.2
|
|
5387
|
+
warnOnce(nextValue.version === "7.3.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.3.2 may not work as expected.`);
|
|
5383
5388
|
}
|
|
5384
5389
|
}
|
|
5385
5390
|
else if (isMotionValue(prevValue)) {
|
|
@@ -6731,6 +6736,12 @@
|
|
|
6731
6736
|
a.y.min === b.y.min &&
|
|
6732
6737
|
a.y.max === b.y.max);
|
|
6733
6738
|
}
|
|
6739
|
+
function aspectRatio(box) {
|
|
6740
|
+
return calcLength(box.x) / calcLength(box.y);
|
|
6741
|
+
}
|
|
6742
|
+
function isCloseTo(a, b, max = 0.01) {
|
|
6743
|
+
return distance(a, b) <= max;
|
|
6744
|
+
}
|
|
6734
6745
|
|
|
6735
6746
|
class NodeStack {
|
|
6736
6747
|
constructor() {
|
|
@@ -7696,9 +7707,27 @@
|
|
|
7696
7707
|
this.completeAnimation();
|
|
7697
7708
|
}
|
|
7698
7709
|
applyTransformsToTarget() {
|
|
7699
|
-
const
|
|
7710
|
+
const lead = this.getLead();
|
|
7711
|
+
let { targetWithTransforms, target, layout, latestValues } = lead;
|
|
7700
7712
|
if (!targetWithTransforms || !target || !layout)
|
|
7701
7713
|
return;
|
|
7714
|
+
/**
|
|
7715
|
+
* If we're only animating position, and this element isn't the lead element,
|
|
7716
|
+
* then instead of projecting into the lead box we instead want to calculate
|
|
7717
|
+
* a new target that aligns the two boxes but maintains the layout shape.
|
|
7718
|
+
*/
|
|
7719
|
+
if (this !== lead &&
|
|
7720
|
+
this.layout &&
|
|
7721
|
+
layout &&
|
|
7722
|
+
shouldAnimatePositionOnly(this.options.animationType, this.layout.actual, layout.actual)) {
|
|
7723
|
+
target = this.target || createBox();
|
|
7724
|
+
const xLength = calcLength(this.layout.actual.x);
|
|
7725
|
+
target.x.min = lead.target.x.min;
|
|
7726
|
+
target.x.max = target.x.min + xLength;
|
|
7727
|
+
const yLength = calcLength(this.layout.actual.y);
|
|
7728
|
+
target.y.min = lead.target.y.min;
|
|
7729
|
+
target.y.max = target.y.min + yLength;
|
|
7730
|
+
}
|
|
7702
7731
|
copyBoxInto(targetWithTransforms, target);
|
|
7703
7732
|
/**
|
|
7704
7733
|
* Apply the latest user-set transforms to the targetBox to produce the targetBoxFinal.
|
|
@@ -7930,9 +7959,10 @@
|
|
|
7930
7959
|
snapshot &&
|
|
7931
7960
|
node.hasListeners("didUpdate")) {
|
|
7932
7961
|
const { actual: layout, measured: measuredLayout } = node.layout;
|
|
7962
|
+
const { animationType } = node.options;
|
|
7933
7963
|
// TODO Maybe we want to also resize the layout snapshot so we don't trigger
|
|
7934
7964
|
// animations for instance if layout="size" and an element has only changed position
|
|
7935
|
-
if (
|
|
7965
|
+
if (animationType === "size") {
|
|
7936
7966
|
eachAxis((axis) => {
|
|
7937
7967
|
const axisSnapshot = snapshot.isShared
|
|
7938
7968
|
? snapshot.measured[axis]
|
|
@@ -7942,7 +7972,7 @@
|
|
|
7942
7972
|
axisSnapshot.max = axisSnapshot.min + length;
|
|
7943
7973
|
});
|
|
7944
7974
|
}
|
|
7945
|
-
else if (
|
|
7975
|
+
else if (shouldAnimatePositionOnly(animationType, snapshot.layout, layout)) {
|
|
7946
7976
|
eachAxis((axis) => {
|
|
7947
7977
|
const axisSnapshot = snapshot.isShared
|
|
7948
7978
|
? snapshot.measured[axis]
|
|
@@ -8075,6 +8105,11 @@
|
|
|
8075
8105
|
roundAxis(box.x);
|
|
8076
8106
|
roundAxis(box.y);
|
|
8077
8107
|
}
|
|
8108
|
+
function shouldAnimatePositionOnly(animationType, snapshot, layout) {
|
|
8109
|
+
return (animationType === "position" ||
|
|
8110
|
+
(animationType === "preserve-aspect" &&
|
|
8111
|
+
!isCloseTo(aspectRatio(snapshot), aspectRatio(layout))));
|
|
8112
|
+
}
|
|
8078
8113
|
|
|
8079
8114
|
const DocumentProjectionNode = createProjectionNode({
|
|
8080
8115
|
attachResizeListener: (ref, notify) => addDomEvent(ref, "resize", notify),
|
|
@@ -9917,6 +9952,28 @@
|
|
|
9917
9952
|
return useConstant(createDragControls);
|
|
9918
9953
|
}
|
|
9919
9954
|
|
|
9955
|
+
/**
|
|
9956
|
+
* Checks if a component is a `motion` component.
|
|
9957
|
+
*/
|
|
9958
|
+
function isMotionComponent(component) {
|
|
9959
|
+
return (component !== null &&
|
|
9960
|
+
typeof component === "object" &&
|
|
9961
|
+
motionComponentSymbol in component);
|
|
9962
|
+
}
|
|
9963
|
+
|
|
9964
|
+
/**
|
|
9965
|
+
* Unwraps a `motion` component and returns either a string for `motion.div` or
|
|
9966
|
+
* the React component for `motion(Component)`.
|
|
9967
|
+
*
|
|
9968
|
+
* If the component is not a `motion` component it returns undefined.
|
|
9969
|
+
*/
|
|
9970
|
+
function unwrapMotionComponent(component) {
|
|
9971
|
+
if (isMotionComponent(component)) {
|
|
9972
|
+
return component[motionComponentSymbol];
|
|
9973
|
+
}
|
|
9974
|
+
return undefined;
|
|
9975
|
+
}
|
|
9976
|
+
|
|
9920
9977
|
function useInstantLayoutTransition() {
|
|
9921
9978
|
return startTransition;
|
|
9922
9979
|
}
|
|
@@ -10079,6 +10136,7 @@
|
|
|
10079
10136
|
exports.filterProps = filterProps;
|
|
10080
10137
|
exports.isBrowser = isBrowser;
|
|
10081
10138
|
exports.isDragActive = isDragActive;
|
|
10139
|
+
exports.isMotionComponent = isMotionComponent;
|
|
10082
10140
|
exports.isMotionValue = isMotionValue;
|
|
10083
10141
|
exports.isValidMotionProp = isValidMotionProp;
|
|
10084
10142
|
exports.m = m;
|
|
@@ -10087,6 +10145,7 @@
|
|
|
10087
10145
|
exports.motionValue = motionValue;
|
|
10088
10146
|
exports.resolveMotionValue = resolveMotionValue;
|
|
10089
10147
|
exports.transform = transform;
|
|
10148
|
+
exports.unwrapMotionComponent = unwrapMotionComponent;
|
|
10090
10149
|
exports.useAnimation = useAnimation;
|
|
10091
10150
|
exports.useAnimationControls = useAnimationControls;
|
|
10092
10151
|
exports.useAnimationFrame = useAnimationFrame;
|