From 96eb4f25aef3d6ad866f3090b28e85bbc1e0437d Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Wed, 28 May 2025 11:30:40 +0900 Subject: [PATCH] =?UTF-8?q?[1046]=20:=20=E3=80=90HANASYS=20DESIGN=E3=80=91?= =?UTF-8?q?=E3=82=B0=E3=83=AA=E3=83=83=E3=83=89=E7=B7=9A=E3=81=AE=E6=A9=9F?= =?UTF-8?q?=E8=83=BD=E8=BF=BD=E5=8A=A0=E3=81=AB=E3=81=A4=E3=81=84=E3=81=A6?= =?UTF-8?q?=E3=81=AE=E8=A6=81=E6=9C=9B=20=EC=9E=84=EC=9D=98=20=EA=B7=B8?= =?UTF-8?q?=EB=A6=AC=EB=93=9C=20=EC=9E=91=EB=8F=99=20=EC=9D=B4=EC=83=81=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useEvent.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/hooks/useEvent.js b/src/hooks/useEvent.js index d701bcd9..9f9e4ea0 100644 --- a/src/hooks/useEvent.js +++ b/src/hooks/useEvent.js @@ -160,6 +160,7 @@ export function useEvent() { const verticalLines = canvas.getObjects().filter((obj) => ['lineGrid', 'tempGrid'].includes(obj.name) && obj.direction === 'vertical') if (!horizonLines || !verticalLines) { + drawMouseLine(pointer) return } @@ -183,6 +184,7 @@ export function useEvent() { } if (!closestVerticalLine || !closestHorizontalLine) { + drawMouseLine(pointer) return } @@ -271,7 +273,14 @@ export function useEvent() { console.error(e) } - const horizontalLine = new fabric.Line([-4 * canvas.width, arrivalPoint.y, 4 * canvas.width, arrivalPoint.y], { + drawMouseLine(arrivalPoint) + + // 캔버스를 다시 그립니다. + canvas?.renderAll() + } + + const drawMouseLine = (pointer) => { + const horizontalLine = new fabric.Line([-4 * canvas.width, pointer.y, 4 * canvas.width, pointer.y], { stroke: 'red', strokeWidth: 1, selectable: false, @@ -279,7 +288,7 @@ export function useEvent() { }) // 세로선 - const verticalLine = new fabric.Line([arrivalPoint.x, -4 * canvas.height, arrivalPoint.x, 4 * canvas.height], { + const verticalLine = new fabric.Line([pointer.x, -4 * canvas.height, pointer.x, 4 * canvas.height], { stroke: 'red', strokeWidth: 1, selectable: false, @@ -288,9 +297,6 @@ export function useEvent() { // 선들을 캔버스에 추가합니다. canvas?.add(horizontalLine, verticalLine) - - // 캔버스를 다시 그립니다. - canvas?.renderAll() } const removeMouseLine = () => {