kopia lustrzana https://github.com/shoelace-style/shoelace
fix: scrollbar gutters and dialog scrolling on open
rodzic
d0b71adb81
commit
7c0006474e
|
@ -33,6 +33,13 @@ export function lockBodyScrolling(lockingEl: HTMLElement) {
|
||||||
if (!document.documentElement.classList.contains('sl-scroll-lock')) {
|
if (!document.documentElement.classList.contains('sl-scroll-lock')) {
|
||||||
/** Scrollbar width + body padding calculation can go away once Safari has scrollbar-gutter support. */
|
/** 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
|
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.classList.add('sl-scroll-lock');
|
||||||
document.documentElement.style.setProperty('--sl-scroll-lock-size', `${scrollbarWidth}px`);
|
document.documentElement.style.setProperty('--sl-scroll-lock-size', `${scrollbarWidth}px`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,10 @@
|
||||||
|
|
||||||
@supports (scrollbar-gutter: stable) {
|
@supports (scrollbar-gutter: stable) {
|
||||||
.sl-scroll-lock {
|
.sl-scroll-lock {
|
||||||
scrollbar-gutter: stable !important;
|
scrollbar-gutter: var(--sl-scroll-lock-gutter) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sl-scroll-lock body {
|
||||||
overflow: hidden !important;
|
overflow: hidden !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue