framer-motion 12.24.8 → 12.24.10
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/{feature-bundle-C6mMBZjn.js → feature-bundle-OJqyiRBo.js} +54 -53
- package/dist/cjs/feature-bundle-OJqyiRBo.js.map +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/m.js +34 -46
- package/dist/cjs/m.js.map +1 -1
- package/dist/dom.js +1 -1
- package/dist/es/gestures/drag/VisualElementDragControls.mjs +16 -6
- package/dist/es/gestures/drag/VisualElementDragControls.mjs.map +1 -1
- package/dist/es/gestures/pan/PanSession.mjs +4 -1
- package/dist/es/gestures/pan/PanSession.mjs.map +1 -1
- package/dist/es/motion/utils/use-motion-ref.mjs +29 -42
- package/dist/es/motion/utils/use-motion-ref.mjs.map +1 -1
- package/dist/framer-motion.dev.js +68 -58
- package/dist/framer-motion.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/package.json +5 -4
- package/dist/cjs/feature-bundle-C6mMBZjn.js.map +0 -1
package/dist/cjs/client.js
CHANGED
|
@@ -4105,69 +4105,51 @@ const useSVGVisualState = /*@__PURE__*/ makeUseVisualState({
|
|
|
4105
4105
|
|
|
4106
4106
|
const motionComponentSymbol = Symbol.for("motionComponentSymbol");
|
|
4107
4107
|
|
|
4108
|
-
function isRefObject(ref) {
|
|
4109
|
-
return (ref &&
|
|
4110
|
-
typeof ref === "object" &&
|
|
4111
|
-
Object.prototype.hasOwnProperty.call(ref, "current"));
|
|
4112
|
-
}
|
|
4113
|
-
|
|
4114
|
-
/**
|
|
4115
|
-
* Set a given ref to a given value
|
|
4116
|
-
* This utility takes care of different types of refs: callback refs and RefObject(s)
|
|
4117
|
-
* Returns a cleanup function if the ref callback returns one (React 19 feature)
|
|
4118
|
-
*/
|
|
4119
|
-
function setRef(ref, value) {
|
|
4120
|
-
if (typeof ref === "function") {
|
|
4121
|
-
return ref(value);
|
|
4122
|
-
}
|
|
4123
|
-
else if (isRefObject(ref)) {
|
|
4124
|
-
ref.current = value;
|
|
4125
|
-
}
|
|
4126
|
-
}
|
|
4127
4108
|
/**
|
|
4128
4109
|
* Creates a ref function that, when called, hydrates the provided
|
|
4129
4110
|
* external ref and VisualElement.
|
|
4130
4111
|
*/
|
|
4131
4112
|
function useMotionRef(visualState, visualElement, externalRef) {
|
|
4132
|
-
|
|
4133
|
-
|
|
4113
|
+
/**
|
|
4114
|
+
* Store externalRef in a ref to avoid including it in the useCallback
|
|
4115
|
+
* dependency array. Including externalRef in dependencies causes issues
|
|
4116
|
+
* with libraries like Radix UI that create new callback refs on each render
|
|
4117
|
+
* when using asChild - this would cause the callback to be recreated,
|
|
4118
|
+
* triggering element remounts and breaking AnimatePresence exit animations.
|
|
4119
|
+
*/
|
|
4120
|
+
const externalRefContainer = React.useRef(externalRef);
|
|
4121
|
+
React.useInsertionEffect(() => {
|
|
4122
|
+
externalRefContainer.current = externalRef;
|
|
4123
|
+
});
|
|
4124
|
+
// Store cleanup function returned by callback refs (React 19 feature)
|
|
4125
|
+
const refCleanup = React.useRef(null);
|
|
4134
4126
|
return React.useCallback((instance) => {
|
|
4135
4127
|
if (instance) {
|
|
4136
|
-
visualState.onMount
|
|
4128
|
+
visualState.onMount?.(instance);
|
|
4137
4129
|
}
|
|
4138
4130
|
if (visualElement) {
|
|
4139
|
-
|
|
4140
|
-
visualElement.mount(instance);
|
|
4141
|
-
}
|
|
4142
|
-
else {
|
|
4143
|
-
visualElement.unmount();
|
|
4144
|
-
}
|
|
4131
|
+
instance ? visualElement.mount(instance) : visualElement.unmount();
|
|
4145
4132
|
}
|
|
4146
|
-
|
|
4133
|
+
const ref = externalRefContainer.current;
|
|
4134
|
+
if (typeof ref === "function") {
|
|
4147
4135
|
if (instance) {
|
|
4148
|
-
|
|
4149
|
-
const cleanup = setRef(externalRef, instance);
|
|
4136
|
+
const cleanup = ref(instance);
|
|
4150
4137
|
if (typeof cleanup === "function") {
|
|
4151
|
-
|
|
4138
|
+
refCleanup.current = cleanup;
|
|
4152
4139
|
}
|
|
4153
4140
|
}
|
|
4141
|
+
else if (refCleanup.current) {
|
|
4142
|
+
refCleanup.current();
|
|
4143
|
+
refCleanup.current = null;
|
|
4144
|
+
}
|
|
4154
4145
|
else {
|
|
4155
|
-
|
|
4156
|
-
if (externalRefCleanupRef.current) {
|
|
4157
|
-
externalRefCleanupRef.current();
|
|
4158
|
-
externalRefCleanupRef.current = null;
|
|
4159
|
-
}
|
|
4160
|
-
else {
|
|
4161
|
-
// Fallback to React <19 behavior for refs that don't return cleanup
|
|
4162
|
-
setRef(externalRef, instance);
|
|
4163
|
-
}
|
|
4146
|
+
ref(instance);
|
|
4164
4147
|
}
|
|
4165
4148
|
}
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
[visualElement, visualState, externalRef]);
|
|
4149
|
+
else if (ref) {
|
|
4150
|
+
ref.current = instance;
|
|
4151
|
+
}
|
|
4152
|
+
}, [visualElement]);
|
|
4171
4153
|
}
|
|
4172
4154
|
|
|
4173
4155
|
/**
|
|
@@ -4175,6 +4157,12 @@ function useMotionRef(visualState, visualElement, externalRef) {
|
|
|
4175
4157
|
*/
|
|
4176
4158
|
const SwitchLayoutGroupContext = React.createContext({});
|
|
4177
4159
|
|
|
4160
|
+
function isRefObject(ref) {
|
|
4161
|
+
return (ref &&
|
|
4162
|
+
typeof ref === "object" &&
|
|
4163
|
+
Object.prototype.hasOwnProperty.call(ref, "current"));
|
|
4164
|
+
}
|
|
4165
|
+
|
|
4178
4166
|
function useVisualElement(Component, visualState, props, createVisualElement, ProjectionNodeConstructor, isSVG) {
|
|
4179
4167
|
const { visualElement: parent } = React.useContext(MotionContext);
|
|
4180
4168
|
const lazyContext = React.useContext(LazyContext);
|
|
@@ -5172,8 +5160,11 @@ class PanSession {
|
|
|
5172
5160
|
this.handlePointerUp = (event, info) => {
|
|
5173
5161
|
this.end();
|
|
5174
5162
|
const { onEnd, onSessionEnd, resumeAnimation } = this.handlers;
|
|
5175
|
-
if (
|
|
5163
|
+
// Resume animation if dragSnapToOrigin is set OR if no drag started (user just clicked)
|
|
5164
|
+
// This ensures constraint animations continue when interrupted by a click
|
|
5165
|
+
if (this.dragSnapToOrigin || !this.startEvent) {
|
|
5176
5166
|
resumeAnimation && resumeAnimation();
|
|
5167
|
+
}
|
|
5177
5168
|
if (!(this.lastMoveEvent && this.lastMoveEventInfo))
|
|
5178
5169
|
return;
|
|
5179
5170
|
const panInfo = getPanInfo(event.type === "pointercancel"
|
|
@@ -5422,15 +5413,21 @@ class VisualElementDragControls {
|
|
|
5422
5413
|
if (presenceContext && presenceContext.isPresent === false)
|
|
5423
5414
|
return;
|
|
5424
5415
|
const onSessionStart = (event) => {
|
|
5425
|
-
|
|
5426
|
-
//
|
|
5427
|
-
//
|
|
5428
|
-
dragSnapToOrigin ? this.pauseAnimation() : this.stopAnimation();
|
|
5416
|
+
// Stop or pause animations based on context:
|
|
5417
|
+
// - snapToCursor: stop because we'll set new position values
|
|
5418
|
+
// - otherwise: pause to allow resume if no drag starts (for constraint animations)
|
|
5429
5419
|
if (snapToCursor) {
|
|
5420
|
+
this.stopAnimation();
|
|
5430
5421
|
this.snapToCursor(extractEventInfo(event).point);
|
|
5431
5422
|
}
|
|
5423
|
+
else {
|
|
5424
|
+
this.pauseAnimation();
|
|
5425
|
+
}
|
|
5432
5426
|
};
|
|
5433
5427
|
const onStart = (event, info) => {
|
|
5428
|
+
// Stop any paused animation so motion values reflect true current position
|
|
5429
|
+
// (pauseAnimation was called in onSessionStart to allow resume if no drag started)
|
|
5430
|
+
this.stopAnimation();
|
|
5434
5431
|
// Attempt to grab the global drag gesture lock - maybe make this part of PanSession
|
|
5435
5432
|
const { drag, dragPropagation, onDragStart } = this.getProps();
|
|
5436
5433
|
if (drag && !dragPropagation) {
|
|
@@ -5796,7 +5793,11 @@ class VisualElementDragControls {
|
|
|
5796
5793
|
*/
|
|
5797
5794
|
const stopPointerListener = addPointerEvent(element, "pointerdown", (event) => {
|
|
5798
5795
|
const { drag, dragListener = true } = this.getProps();
|
|
5799
|
-
drag &&
|
|
5796
|
+
if (drag &&
|
|
5797
|
+
dragListener &&
|
|
5798
|
+
!motionDom.isElementKeyboardAccessible(event.target)) {
|
|
5799
|
+
this.start(event);
|
|
5800
|
+
}
|
|
5800
5801
|
});
|
|
5801
5802
|
const measureDragConstraints = () => {
|
|
5802
5803
|
const { dragConstraints } = this.getProps();
|
|
@@ -6359,4 +6360,4 @@ exports.useIsPresent = useIsPresent;
|
|
|
6359
6360
|
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
|
|
6360
6361
|
exports.usePresence = usePresence;
|
|
6361
6362
|
exports.visualElementStore = visualElementStore;
|
|
6362
|
-
//# sourceMappingURL=feature-bundle-
|
|
6363
|
+
//# sourceMappingURL=feature-bundle-OJqyiRBo.js.map
|