Commit 273cc057e60cc4fe262a913f5f295e684daf395a

Authored by Aresn
Committed by GitHub
2 parents bae9f443 1635ec37

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 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 20 setScrollBar () {
17 21 if (this.bodyIsOverflowing && this.scrollBarWidth !== undefined) {
18 22 document.body.style.paddingRight = `${this.scrollBarWidth}px`;
... ... @@ -27,8 +31,10 @@ export default {
27 31 document.body.style.overflow = 'hidden';
28 32 },
29 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 40 \ No newline at end of file
  41 +};
... ...