@zag-js/remove-scroll 0.0.0-dev-20230529122041 → 0.0.0-dev-20230531091619

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,7 @@ var import_dom_query = require("@zag-js/dom-query");
27
27
  var LOCK_CLASSNAME = "data-zag-scroll-lock";
28
28
  function assignStyle(el, style) {
29
29
  if (!el)
30
- return () => {
31
- };
30
+ return;
32
31
  const previousStyle = el.style.cssText;
33
32
  Object.assign(el.style, style);
34
33
  return () => {
@@ -37,8 +36,7 @@ function assignStyle(el, style) {
37
36
  }
38
37
  function setCSSProperty(el, property, value) {
39
38
  if (!el)
40
- return () => {
41
- };
39
+ return;
42
40
  const previousValue = el.style.getPropertyValue(property);
43
41
  el.style.setProperty(property, value);
44
42
  return () => {
@@ -82,13 +80,13 @@ function preventBodyScroll(_document) {
82
80
  [paddingProperty]: `${scrollbarWidth}px`
83
81
  });
84
82
  return () => {
85
- restoreStyle();
83
+ restoreStyle?.();
86
84
  win.scrollTo(scrollX, scrollY);
87
85
  };
88
86
  };
89
87
  const cleanups = [setScrollbarWidthProperty(), (0, import_dom_query.isIos)() ? setIOSStyle() : setStyle()];
90
88
  return () => {
91
- cleanups.forEach((cleanup) => cleanup());
89
+ cleanups.forEach((fn) => fn?.());
92
90
  body.removeAttribute(LOCK_CLASSNAME);
93
91
  };
94
92
  }
package/dist/index.mjs CHANGED
@@ -3,8 +3,7 @@ import { isIos } from "@zag-js/dom-query";
3
3
  var LOCK_CLASSNAME = "data-zag-scroll-lock";
4
4
  function assignStyle(el, style) {
5
5
  if (!el)
6
- return () => {
7
- };
6
+ return;
8
7
  const previousStyle = el.style.cssText;
9
8
  Object.assign(el.style, style);
10
9
  return () => {
@@ -13,8 +12,7 @@ function assignStyle(el, style) {
13
12
  }
14
13
  function setCSSProperty(el, property, value) {
15
14
  if (!el)
16
- return () => {
17
- };
15
+ return;
18
16
  const previousValue = el.style.getPropertyValue(property);
19
17
  el.style.setProperty(property, value);
20
18
  return () => {
@@ -58,13 +56,13 @@ function preventBodyScroll(_document) {
58
56
  [paddingProperty]: `${scrollbarWidth}px`
59
57
  });
60
58
  return () => {
61
- restoreStyle();
59
+ restoreStyle?.();
62
60
  win.scrollTo(scrollX, scrollY);
63
61
  };
64
62
  };
65
63
  const cleanups = [setScrollbarWidthProperty(), isIos() ? setIOSStyle() : setStyle()];
66
64
  return () => {
67
- cleanups.forEach((cleanup) => cleanup());
65
+ cleanups.forEach((fn) => fn?.());
68
66
  body.removeAttribute(LOCK_CLASSNAME);
69
67
  };
70
68
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/remove-scroll",
3
- "version": "0.0.0-dev-20230529122041",
3
+ "version": "0.0.0-dev-20230531091619",
4
4
  "description": "JavaScript utility to remove scroll on body",
5
5
  "keywords": [
6
6
  "js",
@@ -20,7 +20,7 @@
20
20
  "access": "public"
21
21
  },
22
22
  "dependencies": {
23
- "@zag-js/dom-query": "0.0.0-dev-20230529122041"
23
+ "@zag-js/dom-query": "0.0.0-dev-20230531091619"
24
24
  },
25
25
  "devDependencies": {
26
26
  "clean-package": "2.2.0"
package/src/index.ts CHANGED
@@ -3,7 +3,7 @@ import { isIos } from "@zag-js/dom-query"
3
3
  const LOCK_CLASSNAME = "data-zag-scroll-lock"
4
4
 
5
5
  function assignStyle(el: HTMLElement | null | undefined, style: Partial<CSSStyleDeclaration>) {
6
- if (!el) return () => {}
6
+ if (!el) return
7
7
  const previousStyle = el.style.cssText
8
8
  Object.assign(el.style, style)
9
9
  return () => {
@@ -12,7 +12,7 @@ function assignStyle(el: HTMLElement | null | undefined, style: Partial<CSSStyle
12
12
  }
13
13
 
14
14
  function setCSSProperty(el: HTMLElement | null | undefined, property: string, value: string) {
15
- if (!el) return () => {}
15
+ if (!el) return
16
16
  const previousValue = el.style.getPropertyValue(property)
17
17
  el.style.setProperty(property, value)
18
18
  return () => {
@@ -70,7 +70,7 @@ export function preventBodyScroll(_document?: Document) {
70
70
  })
71
71
 
72
72
  return () => {
73
- restoreStyle()
73
+ restoreStyle?.()
74
74
  win.scrollTo(scrollX, scrollY)
75
75
  }
76
76
  }
@@ -78,7 +78,7 @@ export function preventBodyScroll(_document?: Document) {
78
78
  const cleanups = [setScrollbarWidthProperty(), isIos() ? setIOSStyle() : setStyle()]
79
79
 
80
80
  return () => {
81
- cleanups.forEach((cleanup) => cleanup())
81
+ cleanups.forEach((fn) => fn?.())
82
82
  body.removeAttribute(LOCK_CLASSNAME)
83
83
  }
84
84
  }