@particle-academy/react-fancy 3.4.1 → 3.4.3
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/index.cjs +14 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3265,16 +3265,21 @@ function useFloatingPosition(anchorRef, floatingRef, options = {}) {
|
|
|
3265
3265
|
if (!anchor || !floating) return;
|
|
3266
3266
|
const anchorRect = anchor.getBoundingClientRect();
|
|
3267
3267
|
const floatingRect = floating.getBoundingClientRect();
|
|
3268
|
-
|
|
3268
|
+
const next = getPosition(anchorRect, floatingRect, placement, offset);
|
|
3269
|
+
setPosition(
|
|
3270
|
+
(prev) => prev.x === next.x && prev.y === next.y && prev.placement === next.placement ? prev : next
|
|
3271
|
+
);
|
|
3269
3272
|
}, [anchorRef, floatingRef, placement, offset]);
|
|
3270
|
-
react.
|
|
3271
|
-
if (
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3273
|
+
react.useEffect(() => {
|
|
3274
|
+
if (enabled) update();
|
|
3275
|
+
});
|
|
3276
|
+
react.useEffect(() => {
|
|
3277
|
+
if (!enabled) {
|
|
3278
|
+
setPosition(
|
|
3279
|
+
(prev) => prev.x === -9999 ? prev : { x: -9999, y: -9999, placement }
|
|
3280
|
+
);
|
|
3281
|
+
}
|
|
3282
|
+
}, [enabled, placement]);
|
|
3278
3283
|
react.useEffect(() => {
|
|
3279
3284
|
if (!enabled) return;
|
|
3280
3285
|
window.addEventListener("scroll", update, true);
|