Skip to content

Commit f2d24ba

Browse files
committed
refactor: item move deraction
1 parent 80cae12 commit f2d24ba

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

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

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ const maxCell = ref(0)
129129
const positionBox = ref<Array<Array<{ el: boolean }>>>([])
130130
const coordinates = ref<CanvasCoord[]>([])
131131
const infoBox = ref()
132+
const historyPageX = ref<number | null>(null)
132133
133134
// Position data (non-reactive)
134135
let lastTask: (() => void) | undefined = undefined
@@ -921,25 +922,10 @@ function startMove(e: MouseEvent, item: CanvasItem, index: number) {
921922
//If the current canvas is locked, no component movement will be performed
922923
if (canvasLocked.value) return
923924
// Adjust the accuracy of moving coordinate changes
924-
const newX = Math.max(
925-
Math.floor(
926-
(nowCloneItemX - 20 + infoBox.value.cloneItem.offsetWidth / 96 - baseMarginLeft.value) /
927-
cellWidth.value +
928-
1
929-
),
930-
1
931-
)
932-
// temp adjust board
933-
934-
// Adjust the accuracy of moving coordinate changes
935-
const newY = Math.max(
936-
Math.floor(
937-
(nowCloneItemY + infoBox.value.cloneItem.offsetHeight / 96 - baseMarginTop.value) /
938-
cellHeight.value +
939-
1
940-
),
941-
1
942-
)
925+
let newX = Math.floor(nowCloneItemX / cellWidth.value)
926+
let newY = Math.floor(nowCloneItemY / cellHeight.value)
927+
newX = newX > 0 ? newX : 1
928+
newY = newY > 0 ? newY : 1
943929
debounce(() => {
944930
if (newX !== infoBox.value.oldX || newY !== infoBox.value.oldY) {
945931
movePlayer(moveItem, { x: newX, y: newY })

0 commit comments

Comments
 (0)