@fe6/water-pro
Version:
An enterprise-class UI design language and Vue-based implementation
21 lines (19 loc) • 595 B
JavaScript
import getScrollBarSize from './getScrollBarSize';
export default (close) => {
const bodyIsOverflowing =
document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight) &&
window.innerWidth > document.body.offsetWidth;
if (!bodyIsOverflowing) {
return;
}
if (close) {
document.body.style.position = '';
document.body.style.width = '';
return;
}
const scrollBarSize = getScrollBarSize();
if (scrollBarSize) {
document.body.style.position = 'relative';
document.body.style.width = `calc(100% - ${scrollBarSize}px)`;
}
};