framer-motion 5.5.4 → 5.5.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 +2 -8
- package/dist/cjs/three-entry.js +15 -5
- package/dist/cjs/{use-motion-value-3615b5bb.js → use-motion-value-1c6ad062.js} +17 -9
- package/dist/es/components/MotionConfig/index.mjs +1 -7
- package/dist/es/components/three/MotionCanvas.mjs +12 -1
- package/dist/es/components/three/use-layout-camera.mjs +3 -3
- package/dist/es/projection/animation/mix-values.mjs +18 -9
- package/dist/framer-motion.dev.js +18 -16
- package/dist/framer-motion.js +1 -1
- package/dist/projection.dev.js +17 -9
- package/dist/size-rollup-dom-max.js +1 -1
- package/package.json +2 -2
- package/types/components/three/MotionCanvasContext.d.ts +1 -0
package/dist/cjs/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
|
-
var useMotionValue = require('./use-motion-value-
|
|
6
|
+
var useMotionValue = require('./use-motion-value-1c6ad062.js');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var styleValueTypes = require('style-value-types');
|
|
9
9
|
var popmotion = require('popmotion');
|
|
@@ -2695,13 +2695,7 @@ function MotionConfig(_a) {
|
|
|
2695
2695
|
* Creating a new config context object will re-render every `motion` component
|
|
2696
2696
|
* every time it renders. So we only want to create a new one sparingly.
|
|
2697
2697
|
*/
|
|
2698
|
-
var
|
|
2699
|
-
? config.transition.toString()
|
|
2700
|
-
: "";
|
|
2701
|
-
var context = React.useMemo(function () { return config; }, [
|
|
2702
|
-
transitionDependency,
|
|
2703
|
-
config.transformPagePoint,
|
|
2704
|
-
]);
|
|
2698
|
+
var context = React.useMemo(function () { return config; }, [JSON.stringify(config.transition), config.transformPagePoint]);
|
|
2705
2699
|
return (React__namespace.createElement(useMotionValue.MotionConfigContext.Provider, { value: context }, children));
|
|
2706
2700
|
}
|
|
2707
2701
|
|
package/dist/cjs/three-entry.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
|
-
var useMotionValue = require('./use-motion-value-
|
|
6
|
+
var useMotionValue = require('./use-motion-value-1c6ad062.js');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var popmotion = require('popmotion');
|
|
9
9
|
var three = require('three');
|
|
@@ -295,6 +295,12 @@ var motion = new Proxy(custom, {
|
|
|
295
295
|
|
|
296
296
|
var MotionCanvasContext = React.createContext(undefined);
|
|
297
297
|
|
|
298
|
+
var devicePixelRatio = typeof window !== "undefined" ? window.devicePixelRatio : 1;
|
|
299
|
+
var calculateDpr = function (dpr) {
|
|
300
|
+
return Array.isArray(dpr)
|
|
301
|
+
? popmotion.clamp(dpr[0], dpr[1], devicePixelRatio)
|
|
302
|
+
: dpr || devicePixelRatio;
|
|
303
|
+
};
|
|
298
304
|
/**
|
|
299
305
|
* This file contains a version of R3F's Canvas component that uses our projection
|
|
300
306
|
* system for layout measurements instead of use-react-measure so we can keep the
|
|
@@ -368,7 +374,11 @@ function CanvasComponent(_a, forwardedRef) {
|
|
|
368
374
|
if (size.width > 0 && size.height > 0) {
|
|
369
375
|
fiber.render(React__namespace.createElement(ErrorBoundary, { set: setError },
|
|
370
376
|
React__namespace.createElement(React__namespace.Suspense, { fallback: React__namespace.createElement(Block, { set: setBlock }) },
|
|
371
|
-
React__namespace.createElement(MotionCanvasContext.Provider, { value: {
|
|
377
|
+
React__namespace.createElement(MotionCanvasContext.Provider, { value: {
|
|
378
|
+
dimensions: dimensions,
|
|
379
|
+
layoutCamera: layoutCamera,
|
|
380
|
+
requestedDpr: calculateDpr(props.dpr),
|
|
381
|
+
} },
|
|
372
382
|
React__namespace.createElement(useMotionValue.MotionConfigContext.Provider, { value: configContext },
|
|
373
383
|
React__namespace.createElement(useMotionValue.MotionContext.Provider, { value: motionContext }, children))))), canvasRef.current, tslib.__assign(tslib.__assign({}, props), { dpr: dpr || props.dpr, size: size, events: events || fiber.events }));
|
|
374
384
|
}
|
|
@@ -392,7 +402,7 @@ function useLayoutCamera(_a, updateCamera) {
|
|
|
392
402
|
var _b = _a.makeDefault, makeDefault = _b === void 0 ? true : _b;
|
|
393
403
|
var context = React.useContext(MotionCanvasContext);
|
|
394
404
|
heyListen.invariant(Boolean(context), "No MotionCanvas detected. Replace Canvas from @react-three/fiber with MotionCanvas from framer-motion.");
|
|
395
|
-
var _c = context, dimensions = _c.dimensions, layoutCamera = _c.layoutCamera;
|
|
405
|
+
var _c = context, dimensions = _c.dimensions, layoutCamera = _c.layoutCamera, requestedDpr = _c.requestedDpr;
|
|
396
406
|
var advance = fiber.useThree(function (three) { return three.advance; });
|
|
397
407
|
var set = fiber.useThree(function (three) { return three.set; });
|
|
398
408
|
var camera = fiber.useThree(function (three) { return three.camera; });
|
|
@@ -418,7 +428,7 @@ function useLayoutCamera(_a, updateCamera) {
|
|
|
418
428
|
*/
|
|
419
429
|
var removeLayoutMeasureListener = projection.addEventListener("measure", function (newLayout) {
|
|
420
430
|
var newSize = calcBoxSize(newLayout);
|
|
421
|
-
var dpr =
|
|
431
|
+
var dpr = requestedDpr;
|
|
422
432
|
var _a = dimensions.current.size, width = _a.width, height = _a.height;
|
|
423
433
|
var xScale = width / newSize.width;
|
|
424
434
|
var yScale = height / newSize.height;
|
|
@@ -443,7 +453,7 @@ function useLayoutCamera(_a, updateCamera) {
|
|
|
443
453
|
updateCamera(newSize);
|
|
444
454
|
dimensions.current = { size: newSize };
|
|
445
455
|
gl.setSize(newSize.width, newSize.height);
|
|
446
|
-
gl.setPixelRatio(
|
|
456
|
+
gl.setPixelRatio(requestedDpr);
|
|
447
457
|
}, 50);
|
|
448
458
|
}
|
|
449
459
|
});
|
|
@@ -1139,6 +1139,12 @@ function animate(from, to, transition) {
|
|
|
1139
1139
|
|
|
1140
1140
|
var borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
|
|
1141
1141
|
var numBorders = borders.length;
|
|
1142
|
+
var asNumber = function (value) {
|
|
1143
|
+
return typeof value === "string" ? parseFloat(value) : value;
|
|
1144
|
+
};
|
|
1145
|
+
var isPx = function (value) {
|
|
1146
|
+
return typeof value === "number" || styleValueTypes.px.test(value);
|
|
1147
|
+
};
|
|
1142
1148
|
function mixValues(target, follow, lead, progress, shouldCrossfadeOpacity, isOnlyMember) {
|
|
1143
1149
|
var _a, _b, _c, _d;
|
|
1144
1150
|
if (shouldCrossfadeOpacity) {
|
|
@@ -1162,15 +1168,17 @@ function mixValues(target, follow, lead, progress, shouldCrossfadeOpacity, isOnl
|
|
|
1162
1168
|
continue;
|
|
1163
1169
|
followRadius || (followRadius = 0);
|
|
1164
1170
|
leadRadius || (leadRadius = 0);
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1171
|
+
var canMix = followRadius === 0 ||
|
|
1172
|
+
leadRadius === 0 ||
|
|
1173
|
+
isPx(followRadius) === isPx(leadRadius);
|
|
1174
|
+
if (canMix) {
|
|
1175
|
+
target[borderLabel] = Math.max(popmotion.mix(asNumber(followRadius), asNumber(leadRadius), progress), 0);
|
|
1176
|
+
if (styleValueTypes.percent.test(leadRadius) || styleValueTypes.percent.test(followRadius)) {
|
|
1177
|
+
target[borderLabel] += "%";
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
else {
|
|
1181
|
+
target[borderLabel] = leadRadius;
|
|
1174
1182
|
}
|
|
1175
1183
|
}
|
|
1176
1184
|
/**
|
|
@@ -36,13 +36,7 @@ function MotionConfig(_a) {
|
|
|
36
36
|
* Creating a new config context object will re-render every `motion` component
|
|
37
37
|
* every time it renders. So we only want to create a new one sparingly.
|
|
38
38
|
*/
|
|
39
|
-
var
|
|
40
|
-
? config.transition.toString()
|
|
41
|
-
: "";
|
|
42
|
-
var context = useMemo(function () { return config; }, [
|
|
43
|
-
transitionDependency,
|
|
44
|
-
config.transformPagePoint,
|
|
45
|
-
]);
|
|
39
|
+
var context = useMemo(function () { return config; }, [JSON.stringify(config.transition), config.transformPagePoint]);
|
|
46
40
|
return (React.createElement(MotionConfigContext.Provider, { value: context }, children));
|
|
47
41
|
}
|
|
48
42
|
|
|
@@ -8,7 +8,14 @@ import { useIsomorphicLayoutEffect } from '../../utils/use-isomorphic-effect.mjs
|
|
|
8
8
|
import { MotionConfigContext } from '../../context/MotionConfigContext.mjs';
|
|
9
9
|
import { MotionCanvasContext } from './MotionCanvasContext.mjs';
|
|
10
10
|
import { useForceUpdate } from '../../utils/use-force-update.mjs';
|
|
11
|
+
import { clamp } from 'popmotion';
|
|
11
12
|
|
|
13
|
+
var devicePixelRatio = typeof window !== "undefined" ? window.devicePixelRatio : 1;
|
|
14
|
+
var calculateDpr = function (dpr) {
|
|
15
|
+
return Array.isArray(dpr)
|
|
16
|
+
? clamp(dpr[0], dpr[1], devicePixelRatio)
|
|
17
|
+
: dpr || devicePixelRatio;
|
|
18
|
+
};
|
|
12
19
|
/**
|
|
13
20
|
* This file contains a version of R3F's Canvas component that uses our projection
|
|
14
21
|
* system for layout measurements instead of use-react-measure so we can keep the
|
|
@@ -82,7 +89,11 @@ function CanvasComponent(_a, forwardedRef) {
|
|
|
82
89
|
if (size.width > 0 && size.height > 0) {
|
|
83
90
|
render(React.createElement(ErrorBoundary, { set: setError },
|
|
84
91
|
React.createElement(React.Suspense, { fallback: React.createElement(Block, { set: setBlock }) },
|
|
85
|
-
React.createElement(MotionCanvasContext.Provider, { value: {
|
|
92
|
+
React.createElement(MotionCanvasContext.Provider, { value: {
|
|
93
|
+
dimensions: dimensions,
|
|
94
|
+
layoutCamera: layoutCamera,
|
|
95
|
+
requestedDpr: calculateDpr(props.dpr),
|
|
96
|
+
} },
|
|
86
97
|
React.createElement(MotionConfigContext.Provider, { value: configContext },
|
|
87
98
|
React.createElement(MotionContext.Provider, { value: motionContext }, children))))), canvasRef.current, __assign(__assign({}, props), { dpr: dpr || props.dpr, size: size, events: events$1 || events }));
|
|
88
99
|
}
|
|
@@ -17,7 +17,7 @@ function useLayoutCamera(_a, updateCamera) {
|
|
|
17
17
|
var _b = _a.makeDefault, makeDefault = _b === void 0 ? true : _b;
|
|
18
18
|
var context = useContext(MotionCanvasContext);
|
|
19
19
|
invariant(Boolean(context), "No MotionCanvas detected. Replace Canvas from @react-three/fiber with MotionCanvas from framer-motion.");
|
|
20
|
-
var _c = context, dimensions = _c.dimensions, layoutCamera = _c.layoutCamera;
|
|
20
|
+
var _c = context, dimensions = _c.dimensions, layoutCamera = _c.layoutCamera, requestedDpr = _c.requestedDpr;
|
|
21
21
|
var advance = useThree(function (three) { return three.advance; });
|
|
22
22
|
var set = useThree(function (three) { return three.set; });
|
|
23
23
|
var camera = useThree(function (three) { return three.camera; });
|
|
@@ -43,7 +43,7 @@ function useLayoutCamera(_a, updateCamera) {
|
|
|
43
43
|
*/
|
|
44
44
|
var removeLayoutMeasureListener = projection.addEventListener("measure", function (newLayout) {
|
|
45
45
|
var newSize = calcBoxSize(newLayout);
|
|
46
|
-
var dpr =
|
|
46
|
+
var dpr = requestedDpr;
|
|
47
47
|
var _a = dimensions.current.size, width = _a.width, height = _a.height;
|
|
48
48
|
var xScale = width / newSize.width;
|
|
49
49
|
var yScale = height / newSize.height;
|
|
@@ -68,7 +68,7 @@ function useLayoutCamera(_a, updateCamera) {
|
|
|
68
68
|
updateCamera(newSize);
|
|
69
69
|
dimensions.current = { size: newSize };
|
|
70
70
|
gl.setSize(newSize.width, newSize.height);
|
|
71
|
-
gl.setPixelRatio(
|
|
71
|
+
gl.setPixelRatio(requestedDpr);
|
|
72
72
|
}, 50);
|
|
73
73
|
}
|
|
74
74
|
});
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { mix, progress, linear, circOut } from 'popmotion';
|
|
2
|
+
import { px, percent } from 'style-value-types';
|
|
2
3
|
|
|
3
4
|
var borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
|
|
4
5
|
var numBorders = borders.length;
|
|
6
|
+
var asNumber = function (value) {
|
|
7
|
+
return typeof value === "string" ? parseFloat(value) : value;
|
|
8
|
+
};
|
|
9
|
+
var isPx = function (value) {
|
|
10
|
+
return typeof value === "number" || px.test(value);
|
|
11
|
+
};
|
|
5
12
|
function mixValues(target, follow, lead, progress, shouldCrossfadeOpacity, isOnlyMember) {
|
|
6
13
|
var _a, _b, _c, _d;
|
|
7
14
|
if (shouldCrossfadeOpacity) {
|
|
@@ -25,15 +32,17 @@ function mixValues(target, follow, lead, progress, shouldCrossfadeOpacity, isOnl
|
|
|
25
32
|
continue;
|
|
26
33
|
followRadius || (followRadius = 0);
|
|
27
34
|
leadRadius || (leadRadius = 0);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
var canMix = followRadius === 0 ||
|
|
36
|
+
leadRadius === 0 ||
|
|
37
|
+
isPx(followRadius) === isPx(leadRadius);
|
|
38
|
+
if (canMix) {
|
|
39
|
+
target[borderLabel] = Math.max(mix(asNumber(followRadius), asNumber(leadRadius), progress), 0);
|
|
40
|
+
if (percent.test(leadRadius) || percent.test(followRadius)) {
|
|
41
|
+
target[borderLabel] += "%";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
target[borderLabel] = leadRadius;
|
|
37
46
|
}
|
|
38
47
|
}
|
|
39
48
|
/**
|
|
@@ -2374,6 +2374,12 @@
|
|
|
2374
2374
|
|
|
2375
2375
|
var borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
|
|
2376
2376
|
var numBorders = borders.length;
|
|
2377
|
+
var asNumber = function (value) {
|
|
2378
|
+
return typeof value === "string" ? parseFloat(value) : value;
|
|
2379
|
+
};
|
|
2380
|
+
var isPx = function (value) {
|
|
2381
|
+
return typeof value === "number" || px.test(value);
|
|
2382
|
+
};
|
|
2377
2383
|
function mixValues(target, follow, lead, progress, shouldCrossfadeOpacity, isOnlyMember) {
|
|
2378
2384
|
var _a, _b, _c, _d;
|
|
2379
2385
|
if (shouldCrossfadeOpacity) {
|
|
@@ -2397,15 +2403,17 @@
|
|
|
2397
2403
|
continue;
|
|
2398
2404
|
followRadius || (followRadius = 0);
|
|
2399
2405
|
leadRadius || (leadRadius = 0);
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2406
|
+
var canMix = followRadius === 0 ||
|
|
2407
|
+
leadRadius === 0 ||
|
|
2408
|
+
isPx(followRadius) === isPx(leadRadius);
|
|
2409
|
+
if (canMix) {
|
|
2410
|
+
target[borderLabel] = Math.max(mix(asNumber(followRadius), asNumber(leadRadius), progress), 0);
|
|
2411
|
+
if (percent.test(leadRadius) || percent.test(followRadius)) {
|
|
2412
|
+
target[borderLabel] += "%";
|
|
2413
|
+
}
|
|
2414
|
+
}
|
|
2415
|
+
else {
|
|
2416
|
+
target[borderLabel] = leadRadius;
|
|
2409
2417
|
}
|
|
2410
2418
|
}
|
|
2411
2419
|
/**
|
|
@@ -8535,13 +8543,7 @@
|
|
|
8535
8543
|
* Creating a new config context object will re-render every `motion` component
|
|
8536
8544
|
* every time it renders. So we only want to create a new one sparingly.
|
|
8537
8545
|
*/
|
|
8538
|
-
var
|
|
8539
|
-
? config.transition.toString()
|
|
8540
|
-
: "";
|
|
8541
|
-
var context = React.useMemo(function () { return config; }, [
|
|
8542
|
-
transitionDependency,
|
|
8543
|
-
config.transformPagePoint,
|
|
8544
|
-
]);
|
|
8546
|
+
var context = React.useMemo(function () { return config; }, [JSON.stringify(config.transition), config.transformPagePoint]);
|
|
8545
8547
|
return (React__namespace.createElement(MotionConfigContext.Provider, { value: context }, children));
|
|
8546
8548
|
}
|
|
8547
8549
|
|