Skip to content

Commit

Permalink
fix: #189; !#zh: 修正点击左侧组件,在画布中组件会出现2次
Browse files Browse the repository at this point in the history
  • Loading branch information
ly525 committed Jul 4, 2020
1 parent 67b129a commit 2a3a7df
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions front-end/h5/src/components/core/editor/drag-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ export default {
document.body.removeChild(dragDom)
dragDom = null

const canMousedown = this.checkCanMousedown(e, { minOffset: 10 })
if (!canMousedown) return

const canvasWrapper = document.querySelector('.canvas-wrapper')
const position = canvasWrapper.getBoundingClientRect()
this.dragElement && this.clone({
Expand All @@ -131,6 +134,12 @@ export default {
top: e.clientY - layerY - position.top
}
})
},
checkCanMousedown (e, { minOffsetX, minOffsetY, minOffset }) {
const offsetX = e.clientX - dragConfig.origin.clientX
const offsetY = e.clientY - dragConfig.origin.clientY

return offsetX >= (minOffsetX || minOffset) || offsetY >= (minOffsetY || minOffset)
}
},
updated () {
Expand Down
2 changes: 1 addition & 1 deletion front-end/h5/src/locales/lang/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default {
},
tip: {
componentUsage: 'Tip: just {0} on component',
click: 'click'
click: 'click/drag'
}
}
}
2 changes: 1 addition & 1 deletion front-end/h5/src/locales/lang/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default {
},
tip: {
componentUsage: '使用提示: {0} 组件即可',
click: '点击'
click: '点击或拖拽'
}
}
}

0 comments on commit 2a3a7df

Please sign in to comment.