framer-motion 12.23.28 → 12.24.1
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/client.js +1 -1
- package/dist/cjs/dom.js +15 -0
- package/dist/cjs/dom.js.map +1 -1
- package/dist/cjs/{feature-bundle-Dt2VtvSZ.js → feature-bundle-DRMwxyzS.js} +45 -13
- package/dist/cjs/feature-bundle-DRMwxyzS.js.map +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/m.js +29 -11
- package/dist/cjs/m.js.map +1 -1
- package/dist/dom-mini.js +1 -1
- package/dist/dom.js +1 -1
- package/dist/es/components/Reorder/Group.mjs.map +1 -1
- package/dist/es/components/Reorder/Item.mjs.map +1 -1
- package/dist/es/gestures/drag/index.mjs +10 -0
- package/dist/es/gestures/drag/index.mjs.map +1 -1
- package/dist/es/motion/index.mjs +10 -6
- package/dist/es/motion/index.mjs.map +1 -1
- package/dist/es/motion/utils/use-visual-element.mjs +2 -1
- package/dist/es/motion/utils/use-visual-element.mjs.map +1 -1
- package/dist/es/render/dom/create-visual-element.mjs +5 -1
- package/dist/es/render/dom/create-visual-element.mjs.map +1 -1
- package/dist/es/render/dom/use-render.mjs +2 -4
- package/dist/es/render/dom/use-render.mjs.map +1 -1
- package/dist/es/render/svg/utils/build-attrs.mjs +15 -0
- package/dist/es/render/svg/utils/build-attrs.mjs.map +1 -1
- package/dist/framer-motion.dev.js +82 -34
- package/dist/framer-motion.js +1 -1
- package/dist/m.d.ts +8 -0
- package/dist/mini.js +1 -1
- package/dist/size-rollup-animate.js +1 -1
- package/dist/size-rollup-animate.js.map +1 -1
- 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-m.js.map +1 -1
- package/dist/size-rollup-motion.js +1 -1
- package/dist/size-rollup-motion.js.map +1 -1
- package/dist/size-rollup-scroll.js.map +1 -1
- package/dist/size-rollup-waapi-animate.js +1 -1
- package/dist/size-rollup-waapi-animate.js.map +1 -1
- package/dist/types/client.d.ts +1 -1
- package/dist/types/index.d.ts +13 -5
- package/dist/{types.d-C8SDx5n-.d.ts → types.d-a9pt5qxk.d.ts} +5 -0
- package/package.json +3 -3
- package/dist/cjs/feature-bundle-Dt2VtvSZ.js.map +0 -1
package/dist/cjs/m.js
CHANGED
|
@@ -369,6 +369,15 @@ function buildSVGPath(attrs, length, spacing = 1, offset = 0, useDashCase = true
|
|
|
369
369
|
attrs[keys.array] = `${pathLength} ${pathSpacing}`;
|
|
370
370
|
}
|
|
371
371
|
|
|
372
|
+
/**
|
|
373
|
+
* CSS Motion Path properties that should remain as CSS styles on SVG elements.
|
|
374
|
+
*/
|
|
375
|
+
const cssMotionPathProperties = [
|
|
376
|
+
"offsetDistance",
|
|
377
|
+
"offsetPath",
|
|
378
|
+
"offsetRotate",
|
|
379
|
+
"offsetAnchor",
|
|
380
|
+
];
|
|
372
381
|
/**
|
|
373
382
|
* Build SVG visual attributes, like cx and style.transform
|
|
374
383
|
*/
|
|
@@ -409,6 +418,12 @@ function buildSVGAttrs(state, { attrX, attrY, attrScale, pathLength, pathSpacing
|
|
|
409
418
|
style.transformBox = styleProp?.transformBox ?? "fill-box";
|
|
410
419
|
delete attrs.transformBox;
|
|
411
420
|
}
|
|
421
|
+
for (const key of cssMotionPathProperties) {
|
|
422
|
+
if (attrs[key] !== undefined) {
|
|
423
|
+
style[key] = attrs[key];
|
|
424
|
+
delete attrs[key];
|
|
425
|
+
}
|
|
426
|
+
}
|
|
412
427
|
// Render attrX/attrY/attrScale as attributes
|
|
413
428
|
if (attrX !== undefined)
|
|
414
429
|
attrs.x = attrX;
|
|
@@ -617,10 +632,8 @@ function isSVGComponent(Component) {
|
|
|
617
632
|
return false;
|
|
618
633
|
}
|
|
619
634
|
|
|
620
|
-
function useRender(Component, props, ref, { latestValues, }, isStatic, forwardMotionProps = false) {
|
|
621
|
-
const useVisualProps = isSVGComponent(Component)
|
|
622
|
-
? useSVGProps
|
|
623
|
-
: useHTMLProps;
|
|
635
|
+
function useRender(Component, props, ref, { latestValues, }, isStatic, forwardMotionProps = false, isSVG) {
|
|
636
|
+
const useVisualProps = (isSVG ?? isSVGComponent(Component)) ? useSVGProps : useHTMLProps;
|
|
624
637
|
const visualProps = useVisualProps(props, latestValues, isStatic, Component);
|
|
625
638
|
const filteredProps = filterProps(props, typeof Component === "string", forwardMotionProps);
|
|
626
639
|
const elementProps = Component !== react.Fragment ? { ...filteredProps, ...visualProps, ref } : {};
|
|
@@ -891,7 +904,7 @@ const SwitchLayoutGroupContext = react.createContext({});
|
|
|
891
904
|
|
|
892
905
|
const useIsomorphicLayoutEffect = isBrowser ? react.useLayoutEffect : react.useEffect;
|
|
893
906
|
|
|
894
|
-
function useVisualElement(Component, visualState, props, createVisualElement, ProjectionNodeConstructor) {
|
|
907
|
+
function useVisualElement(Component, visualState, props, createVisualElement, ProjectionNodeConstructor, isSVG) {
|
|
895
908
|
const { visualElement: parent } = react.useContext(MotionContext);
|
|
896
909
|
const lazyContext = react.useContext(LazyContext);
|
|
897
910
|
const presenceContext = react.useContext(PresenceContext);
|
|
@@ -913,6 +926,7 @@ function useVisualElement(Component, visualState, props, createVisualElement, Pr
|
|
|
913
926
|
? presenceContext.initial === false
|
|
914
927
|
: false,
|
|
915
928
|
reducedMotionConfig,
|
|
929
|
+
isSVG,
|
|
916
930
|
});
|
|
917
931
|
}
|
|
918
932
|
const visualElement = visualElementRef.current;
|
|
@@ -1028,10 +1042,14 @@ function getClosestProjectingNode(visualElement) {
|
|
|
1028
1042
|
* Alongside this is a config option which provides a way of rendering the provided
|
|
1029
1043
|
* component "offline", or outside the React render cycle.
|
|
1030
1044
|
*/
|
|
1031
|
-
function createMotionComponent(Component, { forwardMotionProps = false } = {}, preloadedFeatures, createVisualElement) {
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1045
|
+
function createMotionComponent(Component, { forwardMotionProps = false, type } = {}, preloadedFeatures, createVisualElement) {
|
|
1046
|
+
/**
|
|
1047
|
+
* Determine whether to use SVG or HTML rendering based on:
|
|
1048
|
+
* 1. Explicit `type` option (highest priority)
|
|
1049
|
+
* 2. Auto-detection via `isSVGComponent`
|
|
1050
|
+
*/
|
|
1051
|
+
const isSVG = type ? type === "svg" : isSVGComponent(Component);
|
|
1052
|
+
const useVisualState = isSVG ? useSVGVisualState : useHTMLVisualState;
|
|
1035
1053
|
function MotionDOMComponent(props, externalRef) {
|
|
1036
1054
|
/**
|
|
1037
1055
|
* If we need to measure the element we load this functionality in a
|
|
@@ -1056,13 +1074,13 @@ function createMotionComponent(Component, { forwardMotionProps = false } = {}, p
|
|
|
1056
1074
|
* providing a way of rendering to these APIs outside of the React render loop
|
|
1057
1075
|
* for more performant animations and interactions
|
|
1058
1076
|
*/
|
|
1059
|
-
context.visualElement = useVisualElement(Component, visualState, configAndProps, createVisualElement, layoutProjection.ProjectionNode);
|
|
1077
|
+
context.visualElement = useVisualElement(Component, visualState, configAndProps, createVisualElement, layoutProjection.ProjectionNode, isSVG);
|
|
1060
1078
|
}
|
|
1061
1079
|
/**
|
|
1062
1080
|
* The mount order and hierarchy is specific to ensure our element ref
|
|
1063
1081
|
* is hydrated by the time features fire their effects.
|
|
1064
1082
|
*/
|
|
1065
|
-
return (jsxRuntime.jsxs(MotionContext.Provider, { value: context, children: [MeasureLayout && context.visualElement ? (jsxRuntime.jsx(MeasureLayout, { visualElement: context.visualElement, ...configAndProps })) : null, useRender(Component, props, useMotionRef(visualState, context.visualElement, externalRef), visualState, isStatic, forwardMotionProps)] }));
|
|
1083
|
+
return (jsxRuntime.jsxs(MotionContext.Provider, { value: context, children: [MeasureLayout && context.visualElement ? (jsxRuntime.jsx(MeasureLayout, { visualElement: context.visualElement, ...configAndProps })) : null, useRender(Component, props, useMotionRef(visualState, context.visualElement, externalRef), visualState, isStatic, forwardMotionProps, isSVG)] }));
|
|
1066
1084
|
}
|
|
1067
1085
|
MotionDOMComponent.displayName = `motion.${typeof Component === "string"
|
|
1068
1086
|
? Component
|