@zag-js/remove-scroll 0.1.6 → 0.2.0

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