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;
|
let modalInstance;
|
||||||
|
|
||||||
function getModalInstance (render = undefined) {
|
function getModalInstance (render = undefined, lockScroll = true) {
|
||||||
modalInstance = modalInstance || Modal.newInstance({
|
modalInstance = modalInstance || Modal.newInstance({
|
||||||
closable: false,
|
closable: false,
|
||||||
maskClosable: false,
|
maskClosable: false,
|
||||||
footerHide: true,
|
footerHide: true,
|
||||||
render: render
|
render: render,
|
||||||
|
lockScroll
|
||||||
});
|
});
|
||||||
|
|
||||||
return modalInstance;
|
return modalInstance;
|
||||||
|
@ -15,7 +16,8 @@ function getModalInstance (render = undefined) {
|
||||||
|
|
||||||
function confirm (options) {
|
function confirm (options) {
|
||||||
const render = ('render' in options) ? options.render : undefined;
|
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 () {
|
options.onRemove = function () {
|
||||||
modalInstance = null;
|
modalInstance = null;
|
||||||
|
@ -64,4 +66,4 @@ Modal.remove = function () {
|
||||||
instance.remove();
|
instance.remove();
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Modal;
|
export default Modal;
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
// used for Modal & $Spin & Drawer
|
// used for Modal & $Spin & Drawer
|
||||||
import { getScrollBarSize } from '../../utils/assist';
|
import { getScrollBarSize } from '../../utils/assist';
|
||||||
export default {
|
export default {
|
||||||
|
props: {
|
||||||
|
lockScroll: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
checkScrollBar () {
|
checkScrollBar () {
|
||||||
let fullWindowWidth = window.innerWidth;
|
let fullWindowWidth = window.innerWidth;
|
||||||
|
@ -26,11 +32,13 @@ export default {
|
||||||
document.body.style.paddingRight = '';
|
document.body.style.paddingRight = '';
|
||||||
},
|
},
|
||||||
addScrollEffect () {
|
addScrollEffect () {
|
||||||
|
if (!this.lockScroll) return;
|
||||||
this.checkScrollBar();
|
this.checkScrollBar();
|
||||||
this.setScrollBar();
|
this.setScrollBar();
|
||||||
document.body.style.overflow = 'hidden';
|
document.body.style.overflow = 'hidden';
|
||||||
},
|
},
|
||||||
removeScrollEffect() {
|
removeScrollEffect() {
|
||||||
|
if (!this.lockScroll) return;
|
||||||
if (this.checkMaskInVisible()) {
|
if (this.checkMaskInVisible()) {
|
||||||
document.body.style.overflow = '';
|
document.body.style.overflow = '';
|
||||||
this.resetScrollBar();
|
this.resetScrollBar();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue