fix: Prevent content scrolling behind main menu (part 1) (#35173)
This commit is contained in:
parent
c52848b444
commit
c6dddbb66e
7 changed files with 83 additions and 41 deletions
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue