diff --git a/src/hooks/roofcover/useMovementSetting.js b/src/hooks/roofcover/useMovementSetting.js index cb5c0f02..2525cdf6 100644 --- a/src/hooks/roofcover/useMovementSetting.js +++ b/src/hooks/roofcover/useMovementSetting.js @@ -180,18 +180,9 @@ export function useMovementSetting(id) { name: 'followLine', }) canvas.add(followLine) + followLine.bringToFront() FOLLOW_LINE_REF.current = followLine - canvas.on('mouse:move', (event) => { - const mousePos = getIntersectMousePoint(event) - if (followLine.x1 === followLine.x2) { - followLine.left = mousePos.x - 2 - } else { - followLine.top = mousePos.y - 2 - } - canvas.renderAll() - }) - canvas.renderAll() }, [currentObject]) @@ -247,7 +238,9 @@ export function useMovementSetting(id) { const mouseMoveEvent = (e) => { //console.log('mouseMoveEvent:::::',e) - const target = canvas.getActiveObject() + // 기존에는 activeObject를 사용했으나, 이 기능에서는 선택된 라인을 비선택(selectable:false) 상태로 두므로 + // 항상 selectedObject.current를 기준으로 계산한다. + const target = selectedObject.current if (!target) return // 디버깅 로그 추가 @@ -285,11 +278,23 @@ export function useMovementSetting(id) { } } + // followLine도 포인터를 따라가도록 동기화 (하나의 mouse:move 핸들러만 사용) + const followLine = FOLLOW_LINE_REF.current + if (followLine) { + if (followLine.x1 === followLine.x2) { + // 수직 라인: x만 이동 + followLine.left = currentX.toNumber() - 2 + } else { + // 수평 라인: y만 이동 + followLine.top = currentY.toNumber() - 2 + } + followLine.bringToFront() + followLine.setCoords && followLine.setCoords() + canvas.renderAll() + } + // 방향 정보를 사용하여 라디오 버튼 상태 업데이트 - //console.log(`방향: ${direction}, 값: ${value.toNumber()}`) - - currentCalculatedValue = value.toNumber() if (typeRef.current === TYPE.FLOW_LINE) { @@ -618,11 +623,13 @@ export function useMovementSetting(id) { value = value.neg() } } else { - //console.log("error::", UP_DOWN_REF) - value = - UP_DOWN_REF.FILLED_INPUT_REF.current.value !== '' - ? Big(UP_DOWN_REF.FILLED_INPUT_REF.current.value) - : Big(UP_DOWN_REF.POINTER_INPUT_REF.current.value) + console.log("error::", UP_DOWN_REF.POINTER_INPUT_REF.current.value) + value = Big( + (UP_DOWN_REF?.FILLED_INPUT_REF?.current?.value?.trim() || + UP_DOWN_REF?.POINTER_INPUT_REF?.current?.value?.trim() || + '0' + ) + ); const midX = Big(target.x1).plus(target.x2).div(2) const midY = Big(target.y1).plus(target.y2).div(2)