From 1635ec373c4f9f8f7c4f25dc2c548a4a1a072f79 Mon Sep 17 00:00:00 2001 From: 郑敏 Date: Mon, 4 Jun 2018 16:07:58 +0800 Subject: [PATCH] fix bug #3792 Page scroll bar problem caused by Modal component --- src/components/modal/mixins-scrollbar.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/modal/mixins-scrollbar.js b/src/components/modal/mixins-scrollbar.js index 1570fb7..87f305d 100644 --- a/src/components/modal/mixins-scrollbar.js +++ b/src/components/modal/mixins-scrollbar.js @@ -13,6 +13,10 @@ export default { 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 () { if (this.bodyIsOverflowing && this.scrollBarWidth !== undefined) { document.body.style.paddingRight = `${this.scrollBarWidth}px`; @@ -27,8 +31,10 @@ export default { document.body.style.overflow = 'hidden'; }, removeScrollEffect() { - document.body.style.overflow = ''; - this.resetScrollBar(); + if (this.checkMaskInVisible()) { + document.body.style.overflow = ''; + this.resetScrollBar(); + } } } -}; \ No newline at end of file +}; -- libgit2 0.21.4