ant-design-vue/components/_util/switchScrollingEffect.js

21 lines
593 B
JavaScript
Raw Normal View History

2019-08-28 14:56:51 +00:00
import getScrollBarSize from './getScrollBarSize';
2020-10-02 07:44:10 +00:00
export default close => {
2019-08-29 14:50:53 +00:00
const bodyIsOverflowing =
document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight) &&
2019-08-28 14:56:51 +00:00
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)`;
}
};