bits-ui 1.0.0-next.96 → 1.0.0-next.97
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.
|
@@ -15,16 +15,13 @@ const useBodyLockStackCount = createSharedHook(() => {
|
|
|
15
15
|
}
|
|
16
16
|
return false;
|
|
17
17
|
});
|
|
18
|
-
let initialBodyStyle = $state(
|
|
18
|
+
let initialBodyStyle = $state(null);
|
|
19
19
|
let stopTouchMoveListener = null;
|
|
20
20
|
function resetBodyStyle() {
|
|
21
21
|
if (!isBrowser)
|
|
22
22
|
return;
|
|
23
|
-
document.body.style
|
|
24
|
-
document.body.style.marginRight = initialBodyStyle.marginRight ?? "";
|
|
25
|
-
document.body.style.pointerEvents = initialBodyStyle.pointerEvents ?? "";
|
|
23
|
+
document.body.setAttribute("style", initialBodyStyle ?? "");
|
|
26
24
|
document.body.style.removeProperty("--scrollbar-width");
|
|
27
|
-
document.body.style.overflow = initialBodyStyle.overflow ?? "";
|
|
28
25
|
isIOS && stopTouchMoveListener?.();
|
|
29
26
|
}
|
|
30
27
|
$effect(() => {
|
|
@@ -33,17 +30,14 @@ const useBodyLockStackCount = createSharedHook(() => {
|
|
|
33
30
|
if (!curr) {
|
|
34
31
|
return;
|
|
35
32
|
}
|
|
33
|
+
initialBodyStyle = document.body.getAttribute("style");
|
|
36
34
|
const bodyStyle = getComputedStyle(document.body);
|
|
37
|
-
initialBodyStyle.overflow = bodyStyle.overflow;
|
|
38
|
-
initialBodyStyle.paddingRight = bodyStyle.paddingRight;
|
|
39
|
-
initialBodyStyle.marginRight = bodyStyle.marginRight;
|
|
40
|
-
initialBodyStyle.pointerEvents = bodyStyle.pointerEvents;
|
|
41
35
|
// TODO: account for RTL direction, etc.
|
|
42
36
|
const verticalScrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
|
|
43
|
-
const paddingRight = Number.parseInt(
|
|
37
|
+
const paddingRight = Number.parseInt(bodyStyle.paddingRight ?? "0", 10);
|
|
44
38
|
const config = {
|
|
45
39
|
padding: paddingRight + verticalScrollbarWidth,
|
|
46
|
-
margin: Number.parseInt(
|
|
40
|
+
margin: Number.parseInt(bodyStyle.marginRight ?? "0", 10),
|
|
47
41
|
};
|
|
48
42
|
if (verticalScrollbarWidth > 0) {
|
|
49
43
|
document.body.style.paddingRight = `${config.padding}px`;
|