fix: Prevent content scrolling behind main menu (part 1) (#35173)

This commit is contained in:
diondiondion 2025-06-25 14:12:49 +02:00 committed by GitHub
commit c6dddbb66e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 83 additions and 41 deletions

View file

@ -1,8 +1,9 @@
import { isMobile } from '../is_mobile';
let cachedScrollbarWidth: number | null = null;
const getActualScrollbarWidth = () => {
export const getScrollbarWidth = () => {
if (isMobile(window.innerWidth)) {
return 0;
}
const outer = document.createElement('div');
outer.style.visibility = 'hidden';
outer.style.overflow = 'scroll';
@ -16,16 +17,3 @@ const getActualScrollbarWidth = () => {
return scrollbarWidth;
};
export const getScrollbarWidth = () => {
if (cachedScrollbarWidth !== null) {
return cachedScrollbarWidth;
}
const scrollbarWidth = isMobile(window.innerWidth)
? 0
: getActualScrollbarWidth();
cachedScrollbarWidth = scrollbarWidth;
return scrollbarWidth;
};