@hashrytech/quick-components-kit 0.16.6 → 0.16.8

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @hashrytech/quick-components-kit
2
2
 
3
+ ## 0.16.8
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: Fix for scroll jump after disable-scroll ends
8
+
9
+ ## 0.16.7
10
+
11
+ ### Patch Changes
12
+
13
+ - fix: reverting last change and remove smooth scroll to get back to original position for disable scroll
14
+
3
15
  ## 0.16.6
4
16
 
5
17
  ### Patch Changes
@@ -13,18 +13,27 @@ export function disableScroll(node, enabled = true) {
13
13
  const originalBodyWidth = document.body.style.width;
14
14
  const originalTop = document.body.style.top;
15
15
  const originalOverflow = document.documentElement.style.overflowY;
16
+ const hasVerticalScrollbar = document.documentElement.scrollHeight > document.documentElement.clientHeight;
16
17
  function applyLock() {
17
18
  document.body.style.top = `-${scrollTop}px`;
18
- document.documentElement.style.overflowY = 'scroll';
19
+ if (hasVerticalScrollbar) {
20
+ document.documentElement.style.overflowY = 'scroll'; // ensure layout doesn't shift
21
+ }
19
22
  document.body.style.position = 'fixed';
20
23
  document.body.style.width = '100%';
21
24
  }
22
25
  function removeLock() {
26
+ const originalScrollBehavior = document.documentElement.style.scrollBehavior;
23
27
  document.body.style.position = originalBodyPosition;
24
28
  document.body.style.width = originalBodyWidth;
25
29
  document.body.style.top = originalTop;
26
30
  document.documentElement.style.overflowY = originalOverflow;
31
+ document.documentElement.style.scrollBehavior = 'auto';
27
32
  window.scrollTo(0, scrollTop);
33
+ // Restore scroll behavior without causing a jump
34
+ requestAnimationFrame(() => {
35
+ document.documentElement.style.scrollBehavior = originalScrollBehavior;
36
+ });
28
37
  }
29
38
  if (node && enabled)
30
39
  applyLock();
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/hashrytech/quick-components-kit.git"
7
7
  },
8
- "version": "0.16.6",
8
+ "version": "0.16.8",
9
9
  "license": "MIT",
10
10
  "author": "Hashry Tech",
11
11
  "files": [