From a7c21830f89e430b05f2b90b0ca5d5994692b864 Mon Sep 17 00:00:00 2001 From: minsik Date: Thu, 31 Oct 2024 18:07:51 +0900 Subject: [PATCH] =?UTF-8?q?modal=20class=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/context-menu/QContextMenu.jsx | 16 ++++++++++++++-- src/components/floor-plan/MenuDepth01.jsx | 6 +++++- .../floor-plan/modal/auxiliary/AuxiliaryCopy.jsx | 2 +- .../floor-plan/modal/auxiliary/AuxiliaryMove.jsx | 2 +- .../floor-plan/modal/auxiliary/AuxiliarySize.jsx | 2 +- .../modal/dimensionLine/DimensionLineSetting.jsx | 13 +++++++------ .../modal/flowDirection/FlowDirectionSetting.jsx | 2 +- .../floor-plan/modal/image/ImageSizeSetting.jsx | 2 +- .../modal/module/CircuitNumberEdit.jsx | 2 +- .../modal/module/column/ColumnInsert.jsx | 2 +- .../modal/module/column/ColumnRemove.jsx | 2 +- .../floor-plan/modal/module/row/RowInsert.jsx | 2 +- .../floor-plan/modal/module/row/RowRemove.jsx | 2 +- .../floor-plan/modal/object/DormerOffset.jsx | 2 +- .../floor-plan/modal/object/ObjectSetting.jsx | 4 ++-- .../modal/object/RoofMaterialSetting.jsx | 6 +++--- .../roofAllocation/RoofAllocationSetting.jsx | 2 +- 17 files changed, 43 insertions(+), 26 deletions(-) diff --git a/src/components/common/context-menu/QContextMenu.jsx b/src/components/common/context-menu/QContextMenu.jsx index d1d73df3..f710485f 100644 --- a/src/components/common/context-menu/QContextMenu.jsx +++ b/src/components/common/context-menu/QContextMenu.jsx @@ -2,12 +2,14 @@ import { useEffect } from 'react' import '@/styles/contents.scss' import { useRecoilState } from 'recoil' -import { contextMenuState } from '@/store/contextMenu' +import { contextMenuListState, contextMenuState } from '@/store/contextMenu' export default function QContextMenu(props) { const { contextRef, canvasProps, handleKeyup } = props const [contextMenu, setContextMenu] = useRecoilState(contextMenuState) + const [contextMenuList, setContextMenuList] = useRecoilState(contextMenuListState) const activeObject = canvasProps?.getActiveObject() //액티브된 객체를 가져옴 + let contextType = '' if (activeObject) { @@ -19,12 +21,22 @@ export default function QContextMenu(props) { } } + const getYPosition = (e) => { + const contextLength = contextMenuList.reduce((acc, cur, index) => { + return acc + cur.length + }, 0) + return e?.clientY - (contextLength * 25 + contextMenuList.length * 2 * 17) + } useEffect(() => { if (!contextRef.current) return const handleContextMenu = (e) => { // e.preventDefault() //기존 contextmenu 막고 - setContextMenu({ visible: true, x: e.pageX, y: e.pageY }) + const position = { + x: window.innerWidth / 2 < e.pageX ? e.pageX - 240 : e.pageX, + y: window.innerHeight / 2 < e.pageY ? getYPosition(e) : e.pageY, + } + setContextMenu({ visible: true, ...position }) document.addEventListener('keyup', (e) => handleKeyup(e)) canvasProps?.upperCanvasEl.removeEventListener('contextmenu', handleContextMenu) //한번 노출 후 이벤트 삭제 } diff --git a/src/components/floor-plan/MenuDepth01.jsx b/src/components/floor-plan/MenuDepth01.jsx index 63e5e67a..351fdc97 100644 --- a/src/components/floor-plan/MenuDepth01.jsx +++ b/src/components/floor-plan/MenuDepth01.jsx @@ -15,7 +15,11 @@ export default function MenuDepth01() { const subMenus = useRecoilValue(subMenusState) const onClickMenu = ({ id, menu }) => { - setCurrentMenu(menu) + if (menu === currentMenu) { + handleMenu(type) + } else { + setCurrentMenu(menu) + } } useEffect(() => { diff --git a/src/components/floor-plan/modal/auxiliary/AuxiliaryCopy.jsx b/src/components/floor-plan/modal/auxiliary/AuxiliaryCopy.jsx index e4654e4a..32ffc78d 100644 --- a/src/components/floor-plan/modal/auxiliary/AuxiliaryCopy.jsx +++ b/src/components/floor-plan/modal/auxiliary/AuxiliaryCopy.jsx @@ -14,7 +14,7 @@ export default function AuxiliaryCopy(props) { const [arrow2, setArrow2] = useState(null) return ( -
+

{getMessage('modal.auxiliary.copy')}

- +
diff --git a/src/components/floor-plan/modal/flowDirection/FlowDirectionSetting.jsx b/src/components/floor-plan/modal/flowDirection/FlowDirectionSetting.jsx index 9fa412f9..8d0ce8c2 100644 --- a/src/components/floor-plan/modal/flowDirection/FlowDirectionSetting.jsx +++ b/src/components/floor-plan/modal/flowDirection/FlowDirectionSetting.jsx @@ -60,7 +60,7 @@ export default function FlowDirectionSetting(props) { }, [compasDeg]) return ( -
+

{getMessage('modal.shape.flow.direction.setting')}

@@ -36,7 +36,7 @@ export default function RoofMaterialSetting(props) {
- +
diff --git a/src/components/floor-plan/modal/roofAllocation/RoofAllocationSetting.jsx b/src/components/floor-plan/modal/roofAllocation/RoofAllocationSetting.jsx index c6afa44d..f6f1e6f1 100644 --- a/src/components/floor-plan/modal/roofAllocation/RoofAllocationSetting.jsx +++ b/src/components/floor-plan/modal/roofAllocation/RoofAllocationSetting.jsx @@ -16,7 +16,7 @@ export default function RoofAllocationSetting(props) { return ( -
+

{getMessage('plan.menu.estimate.roof.alloc')}