@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 +12 -0
- package/dist/actions/disable-scroll.js +10 -1
- package/package.json +1 -1
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
|
-
|
|
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();
|