From 8be9d2ed7f10088c96813ba8da2d51e842467e7c Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Mon, 23 Sep 2024 13:15:40 +0900 Subject: [PATCH] =?UTF-8?q?points=20=EC=88=98=EC=A0=95=EB=90=98=EB=8A=94?= =?UTF-8?q?=20=EA=B2=BD=EC=9A=B0=20=EA=B8=B8=EC=9D=B4,=EA=B0=81=EB=8F=84,?= =?UTF-8?q?=EB=B0=A9=ED=96=A5=20=EA=B0=92=20=EC=B4=88=EA=B8=B0=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../floor-plan/modal/outerlinesetting/OuterLineWall.jsx | 7 +++++-- src/hooks/useCanvasEvent.js | 5 ++--- src/hooks/useLine.js | 4 +++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/floor-plan/modal/outerlinesetting/OuterLineWall.jsx b/src/components/floor-plan/modal/outerlinesetting/OuterLineWall.jsx index 52056e39..73e48ff2 100644 --- a/src/components/floor-plan/modal/outerlinesetting/OuterLineWall.jsx +++ b/src/components/floor-plan/modal/outerlinesetting/OuterLineWall.jsx @@ -48,6 +48,7 @@ export default function OuterLineWall(props) { useEffect(() => { removeMouseEvent('mouse:down', mouseDown) addCanvasMouseEventListener('mouse:down', mouseDown) + clear() return () => { removeAllMouseEventListeners() } @@ -73,6 +74,8 @@ export default function OuterLineWall(props) { setArrow1('') setArrow2('') + + setAngle1(0) } const mouseDown = (e) => { @@ -168,7 +171,7 @@ export default function OuterLineWall(props) { return } - if (lastPoint.x === firstPoint.x && lastPoint.y === firstPoint.y) { + /*if (lastPoint.x === firstPoint.x && lastPoint.y === firstPoint.y) { return } @@ -222,7 +225,7 @@ export default function OuterLineWall(props) { canvas?.add(guideLine2) addLineText(guideLine2) - } + }*/ } }, [points]) diff --git a/src/hooks/useCanvasEvent.js b/src/hooks/useCanvasEvent.js index e5582733..9a30ccde 100644 --- a/src/hooks/useCanvasEvent.js +++ b/src/hooks/useCanvasEvent.js @@ -1,7 +1,6 @@ -import { useEffect, useState } from 'react' -import { fabric } from 'fabric' +import { useState } from 'react' import { useRecoilState, useRecoilValue } from 'recoil' -import { canvasSizeState, currentObjectState, modeState } from '@/store/canvasAtom' +import { canvasSizeState, currentObjectState } from '@/store/canvasAtom' import { QPolygon } from '@/components/fabric/QPolygon' // 캔버스에 필요한 이벤트 diff --git a/src/hooks/useLine.js b/src/hooks/useLine.js index e5ebcb41..3fbb9051 100644 --- a/src/hooks/useLine.js +++ b/src/hooks/useLine.js @@ -19,7 +19,9 @@ export const useLine = () => { const addLineText = (line, length = getLengthByLine(line)) => { removeLineText(line) - const text = new fabric.Text(length.toFixed(0), { + const lengthTxt = isNaN(Number(length)) ? length : length.toFixed(0) + + const text = new fabric.Text(lengthTxt, { left: (line.x2 + line.x1) / 2, top: (line.y2 + line.y1) / 2, parent: line,