浏览代码

Popup: fix missing padding-right when overflow-y is scroll

Leopoldthecoder 8 年之前
父节点
当前提交
7753bd8931
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      src/utils/popup/index.js

+ 3 - 1
src/utils/popup/index.js

@@ -2,6 +2,7 @@ import Vue from 'vue';
 import merge from 'element-ui/src/utils/merge';
 import PopupManager from 'element-ui/src/utils/popup/popup-manager';
 import getScrollBarWidth from '../scrollbar-width';
+import { getStyle } from '../dom';
 
 let idSeed = 1;
 const transitions = [];
@@ -198,7 +199,8 @@ export default {
           }
           scrollBarWidth = getScrollBarWidth();
           let bodyHasOverflow = document.documentElement.clientHeight < document.body.scrollHeight;
-          if (scrollBarWidth > 0 && bodyHasOverflow) {
+          let bodyOverflowY = getStyle(document.body, 'overflowY');
+          if (scrollBarWidth > 0 && (bodyHasOverflow || bodyOverflowY === 'scroll')) {
             document.body.style.paddingRight = scrollBarWidth + 'px';
           }
           document.body.style.overflow = 'hidden';