From 7dc02514ad1f7c7e781d66aebf3373391ba567eb Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Mon, 18 Nov 2024 10:03:15 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B3=B4=EC=A1=B0=EC=84=A0=20=EC=A4=91?= =?UTF-8?q?=EB=B3=B5=EC=83=9D=EC=84=B1=20line=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/roofcover/useAuxiliaryDrawing.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/hooks/roofcover/useAuxiliaryDrawing.js b/src/hooks/roofcover/useAuxiliaryDrawing.js index 6e95e79c..1a0d87bd 100644 --- a/src/hooks/roofcover/useAuxiliaryDrawing.js +++ b/src/hooks/roofcover/useAuxiliaryDrawing.js @@ -455,9 +455,24 @@ export function useAuxiliaryDrawing(id) { name: 'auxiliaryLine', }) - lineHistory.current.push(line) + const historyLines = [...lineHistory.current] + + const hasSameLine = historyLines.some((history) => { + return ( + (isSamePoint(history.startPoint, line.startPoint) && isSamePoint(history.endPoint, line.endPoint)) || + (isSamePoint(history.startPoint, line.endPoint) && isSamePoint(history.endPoint, line.startPoint)) + ) + }) + mousePointerArr.current = [] clear() + + if (hasSameLine) { + canvas.remove(line) + return + } + + lineHistory.current.push(line) } const mouseDown = (e) => {