fix bug #3792 Page scroll bar problem caused by Modal component

This commit is contained in:
郑敏 2018-06-04 16:07:58 +08:00
parent ed4bb14303
commit 1635ec373c

View file

@ -13,6 +13,10 @@ export default {
this.scrollBarWidth = getScrollBarSize(); this.scrollBarWidth = getScrollBarSize();
} }
}, },
checkMaskInVisible () {
let masks = document.getElementsByClassName('ivu-modal-mask') || [];
return Array.from(masks).every(m => m.style.display === 'none' || m.classList.contains('fade-leave-to'));
},
setScrollBar () { setScrollBar () {
if (this.bodyIsOverflowing && this.scrollBarWidth !== undefined) { if (this.bodyIsOverflowing && this.scrollBarWidth !== undefined) {
document.body.style.paddingRight = `${this.scrollBarWidth}px`; document.body.style.paddingRight = `${this.scrollBarWidth}px`;
@ -27,8 +31,10 @@ export default {
document.body.style.overflow = 'hidden'; document.body.style.overflow = 'hidden';
}, },
removeScrollEffect() { removeScrollEffect() {
if (this.checkMaskInVisible()) {
document.body.style.overflow = ''; document.body.style.overflow = '';
this.resetScrollBar(); this.resetScrollBar();
} }
} }
}
}; };