framer-motion 5.5.5 → 5.5.6-beta.0
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 +27 -2
- package/dist/cjs/{three-entry.js → three.js} +0 -0
- package/dist/es/components/LayoutSVG.mjs +33 -0
- package/dist/es/index.mjs +1 -0
- package/dist/es/render/svg/utils/render.mjs +2 -2
- package/dist/es/{three-entry.mjs → three.mjs} +0 -0
- package/dist/framer-motion.dev.js +59 -34
- package/dist/framer-motion.js +1 -1
- package/dist/size-rollup-dom-animation.js +1 -1
- package/dist/size-rollup-dom-max.js +1 -1
- package/dist/size-rollup-m.js +1 -1
- package/package.json +8 -8
- package/types/components/LayoutSVG.d.ts +12 -0
- package/types/index.d.ts +1 -0
- package/types/render/svg/types.d.ts +1 -1
- package/types/render/svg/utils/render.d.ts +3 -1
- /package/types/{three-entry.d.ts → three.d.ts} +0 -0
package/dist/cjs/index.js
CHANGED
|
@@ -499,8 +499,8 @@ var camelCaseAttributes = new Set([
|
|
|
499
499
|
"pathLength",
|
|
500
500
|
]);
|
|
501
501
|
|
|
502
|
-
function renderSVG(element, renderState) {
|
|
503
|
-
renderHTML(element, renderState);
|
|
502
|
+
function renderSVG(element, renderState, styleProp, projection) {
|
|
503
|
+
renderHTML(element, renderState, styleProp, projection);
|
|
504
504
|
for (var key in renderState.attrs) {
|
|
505
505
|
element.setAttribute(!camelCaseAttributes.has(key) ? camelToDash(key) : key, renderState.attrs[key]);
|
|
506
506
|
}
|
|
@@ -2768,6 +2768,30 @@ function isLazyBundle(features) {
|
|
|
2768
2768
|
return typeof features === "function";
|
|
2769
2769
|
}
|
|
2770
2770
|
|
|
2771
|
+
function LayoutSVGComponent(_a, ref) {
|
|
2772
|
+
var children = _a.children, props = tslib.__rest(_a, ["children"]);
|
|
2773
|
+
var viewBox = useMotionValue.useMotionValue(props.viewBox);
|
|
2774
|
+
return (React__namespace.createElement(motion.svg, tslib.__assign({ ref: ref }, props, { viewBox: viewBox, layout: true, preserveAspectRatio: "none" }),
|
|
2775
|
+
React__namespace.createElement(ProjectViewBox, { viewBox: viewBox }),
|
|
2776
|
+
children));
|
|
2777
|
+
}
|
|
2778
|
+
function ProjectViewBox(_a) {
|
|
2779
|
+
var viewBox = _a.viewBox;
|
|
2780
|
+
var svgVisualElement = useMotionValue.useVisualElementContext();
|
|
2781
|
+
React.useEffect(function () {
|
|
2782
|
+
var _a;
|
|
2783
|
+
return (_a = svgVisualElement === null || svgVisualElement === void 0 ? void 0 : svgVisualElement.projection) === null || _a === void 0 ? void 0 : _a.addEventListener("projectionUpdate", function (_a) {
|
|
2784
|
+
var x = _a.x, y = _a.y;
|
|
2785
|
+
// TODO: A reveal option could be added where 0 0 is
|
|
2786
|
+
// x.min, y.min
|
|
2787
|
+
// viewBox.set(`0 0 ${calcLength(x)} ${calcLength(y)}`)
|
|
2788
|
+
viewBox.set("".concat(x.min, " ").concat(y.min, " ").concat(useMotionValue.calcLength(x), " ").concat(useMotionValue.calcLength(y)));
|
|
2789
|
+
});
|
|
2790
|
+
}, [svgVisualElement]);
|
|
2791
|
+
return null;
|
|
2792
|
+
}
|
|
2793
|
+
var LayoutSVG = React__namespace.forwardRef(LayoutSVGComponent);
|
|
2794
|
+
|
|
2771
2795
|
var ReorderContext = React.createContext(null);
|
|
2772
2796
|
|
|
2773
2797
|
function checkReorder(order, value, offset, velocity) {
|
|
@@ -3674,6 +3698,7 @@ exports.AnimateSharedLayout = AnimateSharedLayout;
|
|
|
3674
3698
|
exports.DeprecatedLayoutGroupContext = DeprecatedLayoutGroupContext;
|
|
3675
3699
|
exports.DragControls = DragControls;
|
|
3676
3700
|
exports.LayoutGroup = LayoutGroup;
|
|
3701
|
+
exports.LayoutSVG = LayoutSVG;
|
|
3677
3702
|
exports.LazyMotion = LazyMotion;
|
|
3678
3703
|
exports.MotionConfig = MotionConfig;
|
|
3679
3704
|
exports.Reorder = Reorder;
|
|
File without changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { __rest, __assign } from 'tslib';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
import { motion } from '../render/dom/motion.mjs';
|
|
5
|
+
import { useMotionValue } from '../value/use-motion-value.mjs';
|
|
6
|
+
import { useVisualElementContext } from '../context/MotionContext/index.mjs';
|
|
7
|
+
import { calcLength } from '../projection/geometry/delta-calc.mjs';
|
|
8
|
+
|
|
9
|
+
function LayoutSVGComponent(_a, ref) {
|
|
10
|
+
var children = _a.children, props = __rest(_a, ["children"]);
|
|
11
|
+
var viewBox = useMotionValue(props.viewBox);
|
|
12
|
+
return (React.createElement(motion.svg, __assign({ ref: ref }, props, { viewBox: viewBox, layout: true, preserveAspectRatio: "none" }),
|
|
13
|
+
React.createElement(ProjectViewBox, { viewBox: viewBox }),
|
|
14
|
+
children));
|
|
15
|
+
}
|
|
16
|
+
function ProjectViewBox(_a) {
|
|
17
|
+
var viewBox = _a.viewBox;
|
|
18
|
+
var svgVisualElement = useVisualElementContext();
|
|
19
|
+
useEffect(function () {
|
|
20
|
+
var _a;
|
|
21
|
+
return (_a = svgVisualElement === null || svgVisualElement === void 0 ? void 0 : svgVisualElement.projection) === null || _a === void 0 ? void 0 : _a.addEventListener("projectionUpdate", function (_a) {
|
|
22
|
+
var x = _a.x, y = _a.y;
|
|
23
|
+
// TODO: A reveal option could be added where 0 0 is
|
|
24
|
+
// x.min, y.min
|
|
25
|
+
// viewBox.set(`0 0 ${calcLength(x)} ${calcLength(y)}`)
|
|
26
|
+
viewBox.set("".concat(x.min, " ").concat(y.min, " ").concat(calcLength(x), " ").concat(calcLength(y)));
|
|
27
|
+
});
|
|
28
|
+
}, [svgVisualElement]);
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
var LayoutSVG = React.forwardRef(LayoutSVGComponent);
|
|
32
|
+
|
|
33
|
+
export { LayoutSVG, LayoutSVGComponent };
|
package/dist/es/index.mjs
CHANGED
|
@@ -5,6 +5,7 @@ export { AnimateSharedLayout } from './components/AnimateSharedLayout.mjs';
|
|
|
5
5
|
export { MotionConfig } from './components/MotionConfig/index.mjs';
|
|
6
6
|
export { LazyMotion } from './components/LazyMotion/index.mjs';
|
|
7
7
|
export { LayoutGroup } from './components/LayoutGroup/index.mjs';
|
|
8
|
+
export { LayoutSVG } from './components/LayoutSVG.mjs';
|
|
8
9
|
export { Reorder } from './components/Reorder/index.mjs';
|
|
9
10
|
export { domAnimation } from './render/dom/features-animation.mjs';
|
|
10
11
|
export { domMax } from './render/dom/features-max.mjs';
|
|
@@ -2,8 +2,8 @@ import { camelToDash } from '../../dom/utils/camel-to-dash.mjs';
|
|
|
2
2
|
import { renderHTML } from '../../html/utils/render.mjs';
|
|
3
3
|
import { camelCaseAttributes } from './camel-case-attrs.mjs';
|
|
4
4
|
|
|
5
|
-
function renderSVG(element, renderState) {
|
|
6
|
-
renderHTML(element, renderState);
|
|
5
|
+
function renderSVG(element, renderState, styleProp, projection) {
|
|
6
|
+
renderHTML(element, renderState, styleProp, projection);
|
|
7
7
|
for (var key in renderState.attrs) {
|
|
8
8
|
element.setAttribute(!camelCaseAttributes.has(key) ? camelToDash(key) : key, renderState.attrs[key]);
|
|
9
9
|
}
|
|
File without changes
|
|
@@ -4841,8 +4841,8 @@
|
|
|
4841
4841
|
"pathLength",
|
|
4842
4842
|
]);
|
|
4843
4843
|
|
|
4844
|
-
function renderSVG(element, renderState) {
|
|
4845
|
-
renderHTML(element, renderState);
|
|
4844
|
+
function renderSVG(element, renderState, styleProp, projection) {
|
|
4845
|
+
renderHTML(element, renderState, styleProp, projection);
|
|
4846
4846
|
for (var key in renderState.attrs) {
|
|
4847
4847
|
element.setAttribute(!camelCaseAttributes.has(key) ? camelToDash(key) : key, renderState.attrs[key]);
|
|
4848
4848
|
}
|
|
@@ -8608,6 +8608,62 @@
|
|
|
8608
8608
|
return typeof features === "function";
|
|
8609
8609
|
}
|
|
8610
8610
|
|
|
8611
|
+
/**
|
|
8612
|
+
* Creates a `MotionValue` to track the state and velocity of a value.
|
|
8613
|
+
*
|
|
8614
|
+
* Usually, these are created automatically. For advanced use-cases, like use with `useTransform`, you can create `MotionValue`s externally and pass them into the animated component via the `style` prop.
|
|
8615
|
+
*
|
|
8616
|
+
* ```jsx
|
|
8617
|
+
* export const MyComponent = () => {
|
|
8618
|
+
* const scale = useMotionValue(1)
|
|
8619
|
+
*
|
|
8620
|
+
* return <motion.div style={{ scale }} />
|
|
8621
|
+
* }
|
|
8622
|
+
* ```
|
|
8623
|
+
*
|
|
8624
|
+
* @param initial - The initial state.
|
|
8625
|
+
*
|
|
8626
|
+
* @public
|
|
8627
|
+
*/
|
|
8628
|
+
function useMotionValue(initial) {
|
|
8629
|
+
var value = useConstant(function () { return motionValue(initial); });
|
|
8630
|
+
/**
|
|
8631
|
+
* If this motion value is being used in static mode, like on
|
|
8632
|
+
* the Framer canvas, force components to rerender when the motion
|
|
8633
|
+
* value is updated.
|
|
8634
|
+
*/
|
|
8635
|
+
var isStatic = React.useContext(MotionConfigContext).isStatic;
|
|
8636
|
+
if (isStatic) {
|
|
8637
|
+
var _a = __read(React.useState(initial), 2), setLatest_1 = _a[1];
|
|
8638
|
+
React.useEffect(function () { return value.onChange(setLatest_1); }, []);
|
|
8639
|
+
}
|
|
8640
|
+
return value;
|
|
8641
|
+
}
|
|
8642
|
+
|
|
8643
|
+
function LayoutSVGComponent(_a, ref) {
|
|
8644
|
+
var children = _a.children, props = __rest(_a, ["children"]);
|
|
8645
|
+
var viewBox = useMotionValue(props.viewBox);
|
|
8646
|
+
return (React__namespace.createElement(motion.svg, __assign({ ref: ref }, props, { viewBox: viewBox, layout: true, preserveAspectRatio: "none" }),
|
|
8647
|
+
React__namespace.createElement(ProjectViewBox, { viewBox: viewBox }),
|
|
8648
|
+
children));
|
|
8649
|
+
}
|
|
8650
|
+
function ProjectViewBox(_a) {
|
|
8651
|
+
var viewBox = _a.viewBox;
|
|
8652
|
+
var svgVisualElement = useVisualElementContext();
|
|
8653
|
+
React.useEffect(function () {
|
|
8654
|
+
var _a;
|
|
8655
|
+
return (_a = svgVisualElement === null || svgVisualElement === void 0 ? void 0 : svgVisualElement.projection) === null || _a === void 0 ? void 0 : _a.addEventListener("projectionUpdate", function (_a) {
|
|
8656
|
+
var x = _a.x, y = _a.y;
|
|
8657
|
+
// TODO: A reveal option could be added where 0 0 is
|
|
8658
|
+
// x.min, y.min
|
|
8659
|
+
// viewBox.set(`0 0 ${calcLength(x)} ${calcLength(y)}`)
|
|
8660
|
+
viewBox.set("".concat(x.min, " ").concat(y.min, " ").concat(calcLength(x), " ").concat(calcLength(y)));
|
|
8661
|
+
});
|
|
8662
|
+
}, [svgVisualElement]);
|
|
8663
|
+
return null;
|
|
8664
|
+
}
|
|
8665
|
+
var LayoutSVG = React__namespace.forwardRef(LayoutSVGComponent);
|
|
8666
|
+
|
|
8611
8667
|
var ReorderContext = React.createContext(null);
|
|
8612
8668
|
|
|
8613
8669
|
function checkReorder(order, value, offset, velocity) {
|
|
@@ -8674,38 +8730,6 @@
|
|
|
8674
8730
|
return a.layout.min - b.layout.min;
|
|
8675
8731
|
}
|
|
8676
8732
|
|
|
8677
|
-
/**
|
|
8678
|
-
* Creates a `MotionValue` to track the state and velocity of a value.
|
|
8679
|
-
*
|
|
8680
|
-
* Usually, these are created automatically. For advanced use-cases, like use with `useTransform`, you can create `MotionValue`s externally and pass them into the animated component via the `style` prop.
|
|
8681
|
-
*
|
|
8682
|
-
* ```jsx
|
|
8683
|
-
* export const MyComponent = () => {
|
|
8684
|
-
* const scale = useMotionValue(1)
|
|
8685
|
-
*
|
|
8686
|
-
* return <motion.div style={{ scale }} />
|
|
8687
|
-
* }
|
|
8688
|
-
* ```
|
|
8689
|
-
*
|
|
8690
|
-
* @param initial - The initial state.
|
|
8691
|
-
*
|
|
8692
|
-
* @public
|
|
8693
|
-
*/
|
|
8694
|
-
function useMotionValue(initial) {
|
|
8695
|
-
var value = useConstant(function () { return motionValue(initial); });
|
|
8696
|
-
/**
|
|
8697
|
-
* If this motion value is being used in static mode, like on
|
|
8698
|
-
* the Framer canvas, force components to rerender when the motion
|
|
8699
|
-
* value is updated.
|
|
8700
|
-
*/
|
|
8701
|
-
var isStatic = React.useContext(MotionConfigContext).isStatic;
|
|
8702
|
-
if (isStatic) {
|
|
8703
|
-
var _a = __read(React.useState(initial), 2), setLatest_1 = _a[1];
|
|
8704
|
-
React.useEffect(function () { return value.onChange(setLatest_1); }, []);
|
|
8705
|
-
}
|
|
8706
|
-
return value;
|
|
8707
|
-
}
|
|
8708
|
-
|
|
8709
8733
|
var isCustomValueType = function (v) {
|
|
8710
8734
|
return typeof v === "object" && v.mix;
|
|
8711
8735
|
};
|
|
@@ -9529,6 +9553,7 @@
|
|
|
9529
9553
|
exports.FlatTree = FlatTree;
|
|
9530
9554
|
exports.LayoutGroup = LayoutGroup;
|
|
9531
9555
|
exports.LayoutGroupContext = LayoutGroupContext;
|
|
9556
|
+
exports.LayoutSVG = LayoutSVG;
|
|
9532
9557
|
exports.LazyMotion = LazyMotion;
|
|
9533
9558
|
exports.MotionConfig = MotionConfig;
|
|
9534
9559
|
exports.MotionConfigContext = MotionConfigContext;
|