@arkyn/components 3.0.1-beta.34 → 3.0.1-beta.36

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.
@@ -1 +1 @@
1
- {"version":3,"file":"useScrollLock.d.ts","sourceRoot":"","sources":["../../src/hooks/useScrollLock.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,iBAAS,aAAa,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAU9C;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"useScrollLock.d.ts","sourceRoot":"","sources":["../../src/hooks/useScrollLock.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,iBAAS,aAAa,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAyB9C;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -1,4 +1,15 @@
1
1
  import { useEffect } from "react";
2
+ /**
3
+ * Calculates the width of the scrollbar
4
+ * @returns The scrollbar width in pixels
5
+ */
6
+ function getScrollbarWidth() {
7
+ // Check if we're in a browser environment
8
+ if (typeof window === "undefined")
9
+ return 0;
10
+ // Calculate the difference between window width and document width
11
+ return window.innerWidth - document.documentElement.clientWidth;
12
+ }
2
13
  /**
3
14
  * useScrollLock hook - manages body scroll blocking for overlays
4
15
  *
@@ -39,9 +50,17 @@ function useScrollLock(isLocked) {
39
50
  useEffect(() => {
40
51
  if (isLocked) {
41
52
  const originalOverflow = document.body.style.overflow;
53
+ const originalPaddingRight = document.body.style.paddingRight;
54
+ const scrollbarWidth = getScrollbarWidth();
55
+ if (scrollbarWidth > 0) {
56
+ const computedStyle = window.getComputedStyle(document.body);
57
+ const existingPaddingRight = parseInt(computedStyle.paddingRight) || 0;
58
+ document.body.style.paddingRight = `${existingPaddingRight + scrollbarWidth}px`;
59
+ }
42
60
  document.body.style.overflow = "hidden";
43
61
  return () => {
44
62
  document.body.style.overflow = originalOverflow;
63
+ document.body.style.paddingRight = originalPaddingRight;
45
64
  };
46
65
  }
47
66
  }, [isLocked]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/components",
3
- "version": "3.0.1-beta.34",
3
+ "version": "3.0.1-beta.36",
4
4
  "main": "./dist/bundle.js",
5
5
  "module": "./dist/bundle.js",
6
6
  "types": "./dist/index.d.ts",