@helpwave/hightide 0.5.3 → 0.5.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/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9053,8 +9053,11 @@ function useFloatingElement({
|
|
|
9053
9053
|
const [style, setStyle] = (0, import_react19.useState)();
|
|
9054
9054
|
const isMounted = useIsMounted();
|
|
9055
9055
|
const calculate = (0, import_react19.useCallback)(() => {
|
|
9056
|
-
const containerRect = containerRef.current
|
|
9057
|
-
|
|
9056
|
+
const containerRect = containerRef.current?.getBoundingClientRect();
|
|
9057
|
+
if (!containerRect) {
|
|
9058
|
+
return;
|
|
9059
|
+
}
|
|
9060
|
+
const windowRect = windowRef?.current?.getBoundingClientRect() ?? {
|
|
9058
9061
|
top: 0,
|
|
9059
9062
|
bottom: window.innerHeight,
|
|
9060
9063
|
left: 0,
|
|
@@ -9090,6 +9093,9 @@ function useFloatingElement({
|
|
|
9090
9093
|
}
|
|
9091
9094
|
}, [calculate, active, isMounted, height, width]);
|
|
9092
9095
|
(0, import_react19.useEffect)(() => {
|
|
9096
|
+
if (!containerRef.current && active) {
|
|
9097
|
+
return;
|
|
9098
|
+
}
|
|
9093
9099
|
window.addEventListener("resize", calculate);
|
|
9094
9100
|
let timeout;
|
|
9095
9101
|
if (isPolling) {
|
|
@@ -9101,7 +9107,7 @@ function useFloatingElement({
|
|
|
9101
9107
|
clearInterval(timeout);
|
|
9102
9108
|
}
|
|
9103
9109
|
};
|
|
9104
|
-
}, [calculate, isPolling, pollingInterval]);
|
|
9110
|
+
}, [active, calculate, containerRef, isPolling, pollingInterval]);
|
|
9105
9111
|
return style;
|
|
9106
9112
|
}
|
|
9107
9113
|
|