From da162ac25941fe7a4c6ac745725e0dafed77a63c Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Fri, 18 Apr 2025 16:03:52 +0900 Subject: [PATCH] =?UTF-8?q?=EB=AA=A8=EB=93=88,=ED=9A=8C=EB=A1=9C=EA=B5=AC?= =?UTF-8?q?=EC=84=B1=20=20=3D>=20=EB=AA=A8=EB=93=88/=EA=B0=80=EB=8C=80=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20=EB=A9=94=EB=89=B4=EC=97=90=EC=84=9C=20roo?= =?UTF-8?q?f=20=EC=84=A0=ED=83=9D=20=EC=95=88=EB=90=98=EB=8F=84=EB=A1=9D?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useCanvasEvent.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/hooks/useCanvasEvent.js b/src/hooks/useCanvasEvent.js index 1f6466f5..4204dc71 100644 --- a/src/hooks/useCanvasEvent.js +++ b/src/hooks/useCanvasEvent.js @@ -1,9 +1,10 @@ import { useEffect, useState } from 'react' import { useRecoilState, useRecoilValue } from 'recoil' import { v4 as uuidv4 } from 'uuid' -import { canvasSizeState, canvasState, canvasZoomState, currentObjectState } from '@/store/canvasAtom' +import { canvasSizeState, canvasState, canvasZoomState, currentMenuState, currentObjectState } from '@/store/canvasAtom' import { QPolygon } from '@/components/fabric/QPolygon' import { fontSelector } from '@/store/fontAtom' +import { MENU } from '@/common/common' // 캔버스에 필요한 이벤트 export function useCanvasEvent() { @@ -13,11 +14,16 @@ export function useCanvasEvent() { const canvasSize = useRecoilValue(canvasSizeState) const [canvasZoom, setCanvasZoom] = useRecoilState(canvasZoomState) const lengthTextOption = useRecoilValue(fontSelector('lengthText')) + const currentMenu = useRecoilValue(currentMenuState) useEffect(() => { canvas?.setZoom(canvasZoom / 100) }, [canvasZoom]) + useEffect(() => { + attachDefaultEventOnCanvas() + }, [currentMenu]) + // 기본적인 이벤트 필요시 추가 const attachDefaultEventOnCanvas = () => { removeEventOnCanvas() @@ -198,7 +204,7 @@ export function useCanvasEvent() { if (selected?.length > 0) { selected.forEach((obj) => { - if (obj.type === 'QPolygon') { + if (obj.type === 'QPolygon' && currentMenu !== MENU.MODULE_CIRCUIT_SETTING.BASIC_SETTING) { obj.set({ stroke: 'red' }) } }) @@ -211,7 +217,7 @@ export function useCanvasEvent() { if (deselected?.length > 0) { deselected.forEach((obj) => { - if (obj.type === 'QPolygon') { + if (obj.type === 'QPolygon' && currentMenu !== MENU.MODULE_CIRCUIT_SETTING.BASIC_SETTING) { if (obj.name !== 'moduleSetupSurface') { obj.set({ stroke: 'black' }) } @@ -227,7 +233,7 @@ export function useCanvasEvent() { if (deselected?.length > 0) { deselected.forEach((obj) => { - if (obj.type === 'QPolygon') { + if (obj.type === 'QPolygon' && currentMenu !== MENU.MODULE_CIRCUIT_SETTING.BASIC_SETTING) { obj.set({ stroke: 'black' }) } }) @@ -235,7 +241,7 @@ export function useCanvasEvent() { if (selected?.length > 0) { selected.forEach((obj) => { - if (obj.type === 'QPolygon') { + if (obj.type === 'QPolygon' && currentMenu !== MENU.MODULE_CIRCUIT_SETTING.BASIC_SETTING) { obj.set({ stroke: 'red' }) } })