From edc7a245530103e41d09ccc809bd7023a11a947c Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Thu, 21 Nov 2024 10:33:14 +0900 Subject: [PATCH] =?UTF-8?q?=EC=83=81=EB=A9=B4=20=EC=98=A4=EB=A5=98=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/module/useModuleBasicSetting.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/hooks/module/useModuleBasicSetting.js b/src/hooks/module/useModuleBasicSetting.js index 7d8ea54d..4f9e829d 100644 --- a/src/hooks/module/useModuleBasicSetting.js +++ b/src/hooks/module/useModuleBasicSetting.js @@ -640,7 +640,7 @@ export function useModuleBasicSetting() { module.tempIndex = index const { x, y } = module.getCenterPoint() const { width, height } = module - centerPoints.push({ x, y, width, height }) + centerPoints.push({ x, y, width, height, index }) const circle = new fabric.Circle({ radius: 5, fill: 'red', @@ -665,7 +665,6 @@ export function useModuleBasicSetting() { let touchDimension = 0 //반접면 let halfTouchDimension = 0 - // 노출하면 체크 centerPoints.forEach((centerPoint, index) => { const { x, y, width, height } = centerPoint @@ -676,12 +675,15 @@ export function useModuleBasicSetting() { return } + const bottomLeftPoint = { x: x - width / 2, y: y + height } + const bottomRightPoint = { x: x + width / 2, y: y + height } + // 바로 아래에 셀이 없는 경우 물떼세 배치가 왼쪽 되어있는 셀을 찾는다. const leftBottomCnt = centerPoints.filter( - (centerPoint) => Math.abs(centerPoint.x - (x - width / 2)) < 2 && Math.abs(centerPoint.y - (y + height)) < 2, + (centerPoint) => Math.abs(centerPoint.x - bottomLeftPoint.x) < 2 && Math.abs(centerPoint.y - bottomLeftPoint.y) < 2, ).length const rightBottomCnt = centerPoints.filter( - (centerPoint) => Math.abs(centerPoint.x - (x + width / 2)) < 2 && Math.abs(centerPoint.y - (y + height)) < 2, + (centerPoint) => Math.abs(centerPoint.x - bottomRightPoint.x) < 2 && Math.abs(centerPoint.y - bottomRightPoint.y) < 2, ).length if (leftBottomCnt + rightBottomCnt === 2) { touchDimension++ @@ -706,11 +708,14 @@ export function useModuleBasicSetting() { return } + const topLeftPoint = { x: x - width / 2, y: y - height } + const topRightPoint = { x: x + width / 2, y: y - height } + const leftTopCnt = centerPoints.filter( - (centerPoint) => Math.abs(centerPoint.x - (x - width) < 2) && Math.abs(centerPoint.y - (y - height)) < 2, + (centerPoint) => Math.abs(centerPoint.x - topLeftPoint.x) < 2 && Math.abs(centerPoint.y - topRightPoint.y) < 2, ).length const rightTopCnt = centerPoints.filter( - (centerPoint) => Math.abs(centerPoint.x - (x + width / 2) < 2) && Math.abs(centerPoint.y - (y - height)) < 2, + (centerPoint) => Math.abs(centerPoint.x - topRightPoint.x) < 2 && Math.abs(centerPoint.y - topRightPoint.y) < 2, ).length if (leftTopCnt + rightTopCnt === 1) {