Commit 2a3a7dff670514aa89d0cc22f5e4d87fdea8d639
1 parent
67b129ae
fix: #189; !#zh: 修正点击左侧组件,在画布中组件会出现2次
Showing
3 changed files
with
11 additions
and
2 deletions
front-end/h5/src/components/core/editor/drag-mixin.js
| ... | ... | @@ -122,6 +122,9 @@ export default { |
| 122 | 122 | document.body.removeChild(dragDom) |
| 123 | 123 | dragDom = null |
| 124 | 124 | |
| 125 | + const canMousedown = this.checkCanMousedown(e, { minOffset: 10 }) | |
| 126 | + if (!canMousedown) return | |
| 127 | + | |
| 125 | 128 | const canvasWrapper = document.querySelector('.canvas-wrapper') |
| 126 | 129 | const position = canvasWrapper.getBoundingClientRect() |
| 127 | 130 | this.dragElement && this.clone({ |
| ... | ... | @@ -131,6 +134,12 @@ export default { |
| 131 | 134 | top: e.clientY - layerY - position.top |
| 132 | 135 | } |
| 133 | 136 | }) |
| 137 | + }, | |
| 138 | + checkCanMousedown (e, { minOffsetX, minOffsetY, minOffset }) { | |
| 139 | + const offsetX = e.clientX - dragConfig.origin.clientX | |
| 140 | + const offsetY = e.clientY - dragConfig.origin.clientY | |
| 141 | + | |
| 142 | + return offsetX >= (minOffsetX || minOffset) || offsetY >= (minOffsetY || minOffset) | |
| 134 | 143 | } |
| 135 | 144 | }, |
| 136 | 145 | updated () { | ... | ... |
front-end/h5/src/locales/lang/en-US.js