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