@particle-academy/react-fancy 3.4.1 → 3.4.2

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 CHANGED
@@ -3269,12 +3269,17 @@ function useFloatingPosition(anchorRef, floatingRef, options = {}) {
3269
3269
  }, [anchorRef, floatingRef, placement, offset]);
3270
3270
  react.useLayoutEffect(() => {
3271
3271
  if (!enabled) return;
3272
- update();
3273
- const raf = requestAnimationFrame(() => {
3272
+ let raf = 0;
3273
+ let frames = 0;
3274
+ const measure = () => {
3274
3275
  update();
3275
- });
3276
+ if (!floatingRef.current && frames++ < 20) {
3277
+ raf = requestAnimationFrame(measure);
3278
+ }
3279
+ };
3280
+ measure();
3276
3281
  return () => cancelAnimationFrame(raf);
3277
- }, [update, enabled]);
3282
+ }, [update, enabled, floatingRef]);
3278
3283
  react.useEffect(() => {
3279
3284
  if (!enabled) return;
3280
3285
  window.addEventListener("scroll", update, true);