@particle-academy/react-fancy 4.4.5 → 4.4.6
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 +22 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3341,6 +3341,28 @@ function useFloatingPosition(anchorRef, floatingRef, options = {}) {
|
|
|
3341
3341
|
react.useEffect(() => {
|
|
3342
3342
|
if (enabled) update();
|
|
3343
3343
|
});
|
|
3344
|
+
react.useEffect(() => {
|
|
3345
|
+
if (!enabled) return;
|
|
3346
|
+
let raf = 0;
|
|
3347
|
+
let ro = null;
|
|
3348
|
+
const tick = () => {
|
|
3349
|
+
const el = floatingRef.current;
|
|
3350
|
+
if (el) {
|
|
3351
|
+
update();
|
|
3352
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
3353
|
+
ro = new ResizeObserver(() => update());
|
|
3354
|
+
ro.observe(el);
|
|
3355
|
+
}
|
|
3356
|
+
} else {
|
|
3357
|
+
raf = requestAnimationFrame(tick);
|
|
3358
|
+
}
|
|
3359
|
+
};
|
|
3360
|
+
raf = requestAnimationFrame(tick);
|
|
3361
|
+
return () => {
|
|
3362
|
+
cancelAnimationFrame(raf);
|
|
3363
|
+
ro?.disconnect();
|
|
3364
|
+
};
|
|
3365
|
+
}, [enabled, update, floatingRef]);
|
|
3344
3366
|
react.useEffect(() => {
|
|
3345
3367
|
if (!enabled) {
|
|
3346
3368
|
setPosition(
|