@zag-js/remove-scroll 0.2.1 → 0.2.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.js +5 -8
- package/dist/index.mjs +5 -8
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -27,9 +27,8 @@ module.exports = __toCommonJS(src_exports);
|
|
|
27
27
|
// ../dom/src/platform.ts
|
|
28
28
|
var isDom = () => typeof window !== "undefined";
|
|
29
29
|
function getPlatform() {
|
|
30
|
-
var _a;
|
|
31
30
|
const agent = navigator.userAgentData;
|
|
32
|
-
return
|
|
31
|
+
return agent?.platform ?? navigator.platform;
|
|
33
32
|
}
|
|
34
33
|
var pt = (v) => isDom() && v.test(getPlatform());
|
|
35
34
|
var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
|
|
@@ -69,9 +68,8 @@ function getPaddingProperty(documentElement) {
|
|
|
69
68
|
return scrollbarX ? "paddingLeft" : "paddingRight";
|
|
70
69
|
}
|
|
71
70
|
function preventBodyScroll(_document) {
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
const win = (_a = doc.defaultView) != null ? _a : window;
|
|
71
|
+
const doc = _document ?? document;
|
|
72
|
+
const win = doc.defaultView ?? window;
|
|
75
73
|
const { documentElement, body } = doc;
|
|
76
74
|
const locked = body.hasAttribute(LOCK_CLASSNAME);
|
|
77
75
|
if (locked)
|
|
@@ -85,10 +83,9 @@ function preventBodyScroll(_document) {
|
|
|
85
83
|
[paddingProperty]: `${scrollbarWidth}px`
|
|
86
84
|
});
|
|
87
85
|
const setIOSStyle = () => {
|
|
88
|
-
var _a2, _b;
|
|
89
86
|
const { scrollX, scrollY, visualViewport } = win;
|
|
90
|
-
const offsetLeft =
|
|
91
|
-
const offsetTop =
|
|
87
|
+
const offsetLeft = visualViewport?.offsetLeft ?? 0;
|
|
88
|
+
const offsetTop = visualViewport?.offsetTop ?? 0;
|
|
92
89
|
const restoreStyle = assignStyle(body, {
|
|
93
90
|
position: "fixed",
|
|
94
91
|
overflow: "hidden",
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// ../dom/src/platform.ts
|
|
2
2
|
var isDom = () => typeof window !== "undefined";
|
|
3
3
|
function getPlatform() {
|
|
4
|
-
var _a;
|
|
5
4
|
const agent = navigator.userAgentData;
|
|
6
|
-
return
|
|
5
|
+
return agent?.platform ?? navigator.platform;
|
|
7
6
|
}
|
|
8
7
|
var pt = (v) => isDom() && v.test(getPlatform());
|
|
9
8
|
var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
|
|
@@ -43,9 +42,8 @@ function getPaddingProperty(documentElement) {
|
|
|
43
42
|
return scrollbarX ? "paddingLeft" : "paddingRight";
|
|
44
43
|
}
|
|
45
44
|
function preventBodyScroll(_document) {
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
const win = (_a = doc.defaultView) != null ? _a : window;
|
|
45
|
+
const doc = _document ?? document;
|
|
46
|
+
const win = doc.defaultView ?? window;
|
|
49
47
|
const { documentElement, body } = doc;
|
|
50
48
|
const locked = body.hasAttribute(LOCK_CLASSNAME);
|
|
51
49
|
if (locked)
|
|
@@ -59,10 +57,9 @@ function preventBodyScroll(_document) {
|
|
|
59
57
|
[paddingProperty]: `${scrollbarWidth}px`
|
|
60
58
|
});
|
|
61
59
|
const setIOSStyle = () => {
|
|
62
|
-
var _a2, _b;
|
|
63
60
|
const { scrollX, scrollY, visualViewport } = win;
|
|
64
|
-
const offsetLeft =
|
|
65
|
-
const offsetTop =
|
|
61
|
+
const offsetLeft = visualViewport?.offsetLeft ?? 0;
|
|
62
|
+
const offsetTop = visualViewport?.offsetTop ?? 0;
|
|
66
63
|
const restoreStyle = assignStyle(body, {
|
|
67
64
|
position: "fixed",
|
|
68
65
|
overflow: "hidden",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/remove-scroll",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "JavaScript utility to remove scroll on body",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"clean-package": "2.2.0",
|
|
23
|
-
"@zag-js/dom-utils": "0.2.
|
|
23
|
+
"@zag-js/dom-utils": "0.2.4"
|
|
24
24
|
},
|
|
25
25
|
"bugs": {
|
|
26
26
|
"url": "https://github.com/chakra-ui/zag/issues"
|