fix: scrollbar gutters and dialog scrolling on open

pull/1967/head
konnorrogers 2024-04-08 12:45:55 -04:00
rodzic d0b71adb81
commit 7c0006474e
2 zmienionych plików z 11 dodań i 1 usunięć

Wyświetl plik

@ -33,6 +33,13 @@ export function lockBodyScrolling(lockingEl: HTMLElement) {
if (!document.documentElement.classList.contains('sl-scroll-lock')) {
/** Scrollbar width + body padding calculation can go away once Safari has scrollbar-gutter support. */
const scrollbarWidth = getScrollbarWidth() + getExistingBodyPadding(); // must be measured before the `sl-scroll-lock` class is applied
let scrollbarGutterProperty = "stable"
if (scrollbarWidth <= 0) {
// if there's no scrollbar, just set it to "revert" so whatever the user has set gets used.
scrollbarGutterProperty = "revert";
}
document.documentElement.style.setProperty("--sl-scroll-lock-gutter", scrollbarGutterProperty)
document.documentElement.classList.add('sl-scroll-lock');
document.documentElement.style.setProperty('--sl-scroll-lock-size', `${scrollbarWidth}px`);
}

Wyświetl plik

@ -6,7 +6,10 @@
@supports (scrollbar-gutter: stable) {
.sl-scroll-lock {
scrollbar-gutter: stable !important;
scrollbar-gutter: var(--sl-scroll-lock-gutter) !important;
}
.sl-scroll-lock body {
overflow: hidden !important;
}
}