fix(module:modal): the width will be added when there is no scroll bar (#408)

This commit is contained in:
zxyao 2020-07-22 22:24:58 +08:00 committed by GitHub
parent 1e02c38d97
commit 20b5bb5e7d

View File

@ -350,6 +350,12 @@ export function removeCls(selector: Element | string, clsName: string | Array<st
const oldBodyCacheStack = [];
const hasScrollbar = () => {
let overflow = document.body.style.overflow;
if (overflow && overflow === "hidden") return false;
return document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight);
}
export function disableBodyScroll() {
let body = document.body;
const oldBodyCache = {};
@ -360,7 +366,7 @@ export function disableBodyScroll() {
css(body,
{
"position": "relative",
"width": "calc(100% - 17px)",
"width": hasScrollbar() ? "calc(100% - 17px)" : null,
"overflow": "hidden"
});
addCls(document.body, "ant-scrolling-effect");