Modal add property resetDragPosition

This commit is contained in:
梁灏 2021-06-09 10:41:37 +08:00
parent 3db95d23f9
commit cd01561cde

View file

@ -38,12 +38,21 @@
import ScrollbarMixins from './mixins-scrollbar'; import ScrollbarMixins from './mixins-scrollbar';
import { on, off } from '../../utils/dom'; import { on, off } from '../../utils/dom';
import { findComponentsDownward } from '../../utils/assist'; import { findComponentsDownward, deepCopy } from '../../utils/assist';
import { transferIndex as modalIndex, transferIncrease as modalIncrease, lastVisibleIndex, lastVisibleIncrease } from '../../utils/transfer-queue'; import { transferIndex as modalIndex, transferIncrease as modalIncrease, lastVisibleIndex, lastVisibleIncrease } from '../../utils/transfer-queue';
const prefixCls = 'ivu-modal'; const prefixCls = 'ivu-modal';
const dragData = {
x: null,
y: null,
dragX: null,
dragY: null,
dragging: false,
rect: null
};
export default { export default {
name: 'Modal', name: 'Modal',
mixins: [ Locale, Emitter, ScrollbarMixins ], mixins: [ Locale, Emitter, ScrollbarMixins ],
@ -133,6 +142,11 @@
type: Number, type: Number,
default: 10 default: 10
}, },
// 4.6.0
resetDragPosition: {
type: Boolean,
default: false
},
zIndex: { zIndex: {
type: Number, type: Number,
default: 1000 default: 1000
@ -145,14 +159,7 @@
showHead: true, showHead: true,
buttonLoading: false, buttonLoading: false,
visible: this.value, visible: this.value,
dragData: { dragData: deepCopy(dragData),
x: null,
y: null,
dragX: null,
dragY: null,
dragging: false,
rect: null
},
modalIndex: this.handleGetModalIndex(), // for Esc close the top modal modalIndex: this.handleGetModalIndex(), // for Esc close the top modal
isMouseTriggerIn: false, // #5800 isMouseTriggerIn: false, // #5800
}; };
@ -433,6 +440,9 @@
this.$emit('on-visible-change', val); this.$emit('on-visible-change', val);
this.lastVisible = val; this.lastVisible = val;
this.lastVisibleIndex = lastVisibleIndex; this.lastVisibleIndex = lastVisibleIndex;
if (val && this.resetDragPosition) {
this.dragData = deepCopy(dragData);
}
}, },
loading (val) { loading (val) {
if (!val) { if (!val) {