Commit 273cc057e60cc4fe262a913f5f295e684daf395a
Committed by
GitHub
Merge pull request #3808 from m430/bug-3792
fix bug #3792 Page scroll bar problem caused by Modal component
Showing
1 changed file
with
9 additions
and
3 deletions
Show diff stats
src/components/modal/mixins-scrollbar.js
| @@ -13,6 +13,10 @@ export default { | @@ -13,6 +13,10 @@ export default { | ||
| 13 | this.scrollBarWidth = getScrollBarSize(); | 13 | this.scrollBarWidth = getScrollBarSize(); |
| 14 | } | 14 | } |
| 15 | }, | 15 | }, |
| 16 | + checkMaskInVisible () { | ||
| 17 | + let masks = document.getElementsByClassName('ivu-modal-mask') || []; | ||
| 18 | + return Array.from(masks).every(m => m.style.display === 'none' || m.classList.contains('fade-leave-to')); | ||
| 19 | + }, | ||
| 16 | setScrollBar () { | 20 | setScrollBar () { |
| 17 | if (this.bodyIsOverflowing && this.scrollBarWidth !== undefined) { | 21 | if (this.bodyIsOverflowing && this.scrollBarWidth !== undefined) { |
| 18 | document.body.style.paddingRight = `${this.scrollBarWidth}px`; | 22 | document.body.style.paddingRight = `${this.scrollBarWidth}px`; |
| @@ -27,8 +31,10 @@ export default { | @@ -27,8 +31,10 @@ export default { | ||
| 27 | document.body.style.overflow = 'hidden'; | 31 | document.body.style.overflow = 'hidden'; |
| 28 | }, | 32 | }, |
| 29 | removeScrollEffect() { | 33 | removeScrollEffect() { |
| 30 | - document.body.style.overflow = ''; | ||
| 31 | - this.resetScrollBar(); | 34 | + if (this.checkMaskInVisible()) { |
| 35 | + document.body.style.overflow = ''; | ||
| 36 | + this.resetScrollBar(); | ||
| 37 | + } | ||
| 32 | } | 38 | } |
| 33 | } | 39 | } |
| 34 | -}; | ||
| 35 | \ No newline at end of file | 40 | \ No newline at end of file |
| 41 | +}; |