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

@ -2,12 +2,13 @@ import Modal from './confirm';
let modalInstance;
function getModalInstance (render = undefined) {
function getModalInstance (render = undefined, lockScroll = true) {
modalInstance = modalInstance || Modal.newInstance({
closable: false,
maskClosable: false,
footerHide: true,
render: render
render: render,
lockScroll
});
return modalInstance;
@ -15,7 +16,8 @@ function getModalInstance (render = undefined) {
function confirm (options) {
const render = ('render' in options) ? options.render : undefined;
let instance = getModalInstance(render);
const lockScroll = ('lockScroll' in options) ? options.lockScroll : true;
let instance = getModalInstance(render, lockScroll);
options.onRemove = function () {
modalInstance = null;
@ -64,4 +66,4 @@ Modal.remove = function () {
instance.remove();
};
export default Modal;
export default Modal;

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();