fix: 修改moadl定义拖拽,和 绑定style left 与top 值后,点击拖拽飘移的问题

This commit is contained in:
王佳 2019-08-20 19:01:14 +08:00
parent a2c5781120
commit 40bf70dd08
No known key found for this signature in database
GPG key ID: 2261D11EE24182F9
2 changed files with 14 additions and 3 deletions

View file

@ -80,7 +80,10 @@
default: false
},
styles: {
type: Object
type: Object,
default() {
return {};
}
},
className: {
type: String
@ -199,8 +202,9 @@
let style = {};
if (this.draggable) {
let customTop = this.styles.top ? parseFloat(this.styles.top) : 0
if (this.dragData.x !== null) style.left = `${this.dragData.x}px`;
let customTop = this.styles.top || 0 ? parseFloat(this.styles.top) : 0
let customLeft = this.styles.left || 0 ? parseFloat(this.styles.left) : 0
if (this.dragData.x !== null) style.left = `${this.dragData.x - customLeft}px`;
if (this.dragData.y !== null) style.top = `${this.dragData.y - customTop}px`;
const width = parseInt(this.width);
const styleWidth = {