diff --git a/src/hooks/common/useRoofFn.js b/src/hooks/common/useRoofFn.js index e7a06d38..4721d581 100644 --- a/src/hooks/common/useRoofFn.js +++ b/src/hooks/common/useRoofFn.js @@ -250,7 +250,7 @@ export function useRoofFn() { const allRoofObject = canvas .getObjects() - .filter((obj) => obj !== roof && (obj.attributes?.roofId === roof.id || obj.parentId === roof.id || obj.parentId === wall.id)) + .filter((obj) => obj !== roof && (obj.attributes?.roofId === roof.id || obj.parentId === roof.id || (wall && obj.parentId === wall.id))) /** 지붕이 움직인 만큼의 delta를 구한다. */ const originalRoofLeft = roof.left @@ -276,15 +276,33 @@ export function useRoofFn() { // Move all related objects by the delta allRoofObject.forEach((obj) => { if (obj.points !== undefined) { - obj.set({ - left: obj.left + deltaX, - top: obj.top + deltaY, - originX: 'center', - originY: 'center', - objectCaching: false, - }) - obj.fire('polygonMoved') - obj.fire('modified') + if (obj.name === 'arrow') { + // arrow 는 originX='left' 기본값이며 polygonMoved 가 left=pathOffset(중심) 으로 + // 리셋하면 origin 불일치로 위치가 밀리므로, 단순 점 이동만 수행. + obj.points = obj.points.map((p) => ({ x: p.x + deltaX, y: p.y + deltaY })) + const dim = obj._calcDimensions({}) + obj.set({ + left: dim.left + dim.width / 2, + top: dim.top + dim.height / 2, + width: dim.width, + height: dim.height, + pathOffset: { x: dim.left + dim.width / 2, y: dim.top + dim.height / 2 }, + originX: 'center', + originY: 'center', + objectCaching: false, + }) + obj.setCoords() + } else { + obj.set({ + left: obj.left + deltaX, + top: obj.top + deltaY, + originX: 'center', + originY: 'center', + objectCaching: false, + }) + obj.fire('polygonMoved') + obj.fire('modified') + } } else { obj.set({ left: obj.left + deltaX,