Skip to content

Commit 1d48052

Browse files
committed
refactor: move gap adaptor tab
1 parent 4f8d544 commit 1d48052

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

frontend/src/views/dashboard/canvas/CanvasCore.vue

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -809,9 +809,15 @@ function checkStartMove() {
809809
if (cloneItem && nowItemNode) {
810810
const xGap = Math.abs(cloneItem.offsetLeft - nowItemNode.offsetLeft)
811811
const yGap = Math.abs(cloneItem.offsetTop - nowItemNode.offsetTop)
812-
return xGap > offsetX || yGap > offsetY
812+
return {
813+
xMove: xGap > offsetX,
814+
yMove: yGap > offsetY,
815+
}
816+
}
817+
return {
818+
xMove: false,
819+
yMove: false,
813820
}
814-
return false
815821
}
816822
817823
function startMove(e: MouseEvent, item: CanvasItem, index: number) {
@@ -933,13 +939,10 @@ function startMove(e: MouseEvent, item: CanvasItem, index: number) {
933939
934940
//If the current canvas is locked, no component movement will be performed
935941
if (canvasLocked.value) return
936-
if (!checkStartMove()) {
937-
return
938-
}
939-
942+
const { xMove, yMove } = checkStartMove()
940943
// Adjust the accuracy of moving coordinate changes
941-
let newX = Math.round(nowCloneItemX / cellWidth.value)
942-
let newY = Math.round(nowCloneItemY / cellHeight.value)
944+
let newX = xMove ? Math.round(nowCloneItemX / cellWidth.value) : infoBox.value.oldX
945+
let newY = yMove ? Math.round(nowCloneItemY / cellHeight.value) : infoBox.value.oldY
943946
newX = newX > 0 ? newX : 1
944947
newY = newY > 0 ? newY : 1
945948
debounce(() => {

0 commit comments

Comments
 (0)