framer-motion 12.24.2 → 12.24.4
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-DBjkFz2c.js → feature-bundle-BwaqZAbT.js} +34 -8
- package/dist/cjs/feature-bundle-BwaqZAbT.js.map +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/m.js +33 -7
- package/dist/cjs/m.js.map +1 -1
- package/dist/dom.js +1 -1
- package/dist/es/motion/utils/use-motion-ref.mjs +34 -8
- package/dist/es/motion/utils/use-motion-ref.mjs.map +1 -1
- package/dist/framer-motion.dev.js +43 -11
- package/dist/framer-motion.js +1 -1
- package/dist/size-rollup-dom-animation-m.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 +3 -3
- package/dist/cjs/feature-bundle-DBjkFz2c.js.map +0 -1
package/dist/cjs/client.js
CHANGED
|
@@ -4103,11 +4103,26 @@ function isRefObject(ref) {
|
|
|
4103
4103
|
Object.prototype.hasOwnProperty.call(ref, "current"));
|
|
4104
4104
|
}
|
|
4105
4105
|
|
|
4106
|
+
/**
|
|
4107
|
+
* Set a given ref to a given value
|
|
4108
|
+
* This utility takes care of different types of refs: callback refs and RefObject(s)
|
|
4109
|
+
* Returns a cleanup function if the ref callback returns one (React 19 feature)
|
|
4110
|
+
*/
|
|
4111
|
+
function setRef(ref, value) {
|
|
4112
|
+
if (typeof ref === "function") {
|
|
4113
|
+
return ref(value);
|
|
4114
|
+
}
|
|
4115
|
+
else if (isRefObject(ref)) {
|
|
4116
|
+
ref.current = value;
|
|
4117
|
+
}
|
|
4118
|
+
}
|
|
4106
4119
|
/**
|
|
4107
4120
|
* Creates a ref function that, when called, hydrates the provided
|
|
4108
4121
|
* external ref and VisualElement.
|
|
4109
4122
|
*/
|
|
4110
4123
|
function useMotionRef(visualState, visualElement, externalRef) {
|
|
4124
|
+
// Store the cleanup function from external ref if it returns one
|
|
4125
|
+
const externalRefCleanupRef = React.useRef(null);
|
|
4111
4126
|
return React.useCallback((instance) => {
|
|
4112
4127
|
if (instance) {
|
|
4113
4128
|
visualState.onMount && visualState.onMount(instance);
|
|
@@ -4121,19 +4136,30 @@ function useMotionRef(visualState, visualElement, externalRef) {
|
|
|
4121
4136
|
}
|
|
4122
4137
|
}
|
|
4123
4138
|
if (externalRef) {
|
|
4124
|
-
if (
|
|
4125
|
-
|
|
4139
|
+
if (instance) {
|
|
4140
|
+
// Mount: call the external ref and store any cleanup function
|
|
4141
|
+
const cleanup = setRef(externalRef, instance);
|
|
4142
|
+
if (typeof cleanup === "function") {
|
|
4143
|
+
externalRefCleanupRef.current = cleanup;
|
|
4144
|
+
}
|
|
4126
4145
|
}
|
|
4127
|
-
else
|
|
4128
|
-
|
|
4146
|
+
else {
|
|
4147
|
+
// Unmount: call stored cleanup function if available, otherwise call ref with null
|
|
4148
|
+
if (externalRefCleanupRef.current) {
|
|
4149
|
+
externalRefCleanupRef.current();
|
|
4150
|
+
externalRefCleanupRef.current = null;
|
|
4151
|
+
}
|
|
4152
|
+
else {
|
|
4153
|
+
// Fallback to React <19 behavior for refs that don't return cleanup
|
|
4154
|
+
setRef(externalRef, instance);
|
|
4155
|
+
}
|
|
4129
4156
|
}
|
|
4130
4157
|
}
|
|
4131
4158
|
},
|
|
4132
4159
|
/**
|
|
4133
|
-
* Include
|
|
4134
|
-
* when the ref changes, allowing proper ref forwarding.
|
|
4160
|
+
* Include all dependencies to ensure the callback updates correctly
|
|
4135
4161
|
*/
|
|
4136
|
-
[visualElement]);
|
|
4162
|
+
[visualElement, visualState, externalRef]);
|
|
4137
4163
|
}
|
|
4138
4164
|
|
|
4139
4165
|
/**
|
|
@@ -6325,4 +6351,4 @@ exports.useIsPresent = useIsPresent;
|
|
|
6325
6351
|
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
|
|
6326
6352
|
exports.usePresence = usePresence;
|
|
6327
6353
|
exports.visualElementStore = visualElementStore;
|
|
6328
|
-
//# sourceMappingURL=feature-bundle-
|
|
6354
|
+
//# sourceMappingURL=feature-bundle-BwaqZAbT.js.map
|