Modal, $Modal, Drawer, Spin add new prop lockScroll, close #667

This commit is contained in:
梁灏 2020-09-14 10:45:23 +08:00
parent af8c2e5e59
commit 3bdbdc063e
2 changed files with 14 additions and 4 deletions

View file

@ -1,6 +1,12 @@
// used for Modal & $Spin & Drawer
import { getScrollBarSize } from '../../utils/assist';
export default {
props: {
lockScroll: {
type: Boolean,
default: true
}
},
methods: {
checkScrollBar () {
let fullWindowWidth = window.innerWidth;
@ -26,11 +32,13 @@ export default {
document.body.style.paddingRight = '';
},
addScrollEffect () {
if (!this.lockScroll) return;
this.checkScrollBar();
this.setScrollBar();
document.body.style.overflow = 'hidden';
},
removeScrollEffect() {
if (!this.lockScroll) return;
if (this.checkMaskInVisible()) {
document.body.style.overflow = '';
this.resetScrollBar();