Modal, $Modal, Drawer, Spin add new prop lockScroll, close #667
This commit is contained in:
parent
af8c2e5e59
commit
3bdbdc063e
2 changed files with 14 additions and 4 deletions
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue