diff --git a/src/hooks/useMode.js b/src/hooks/useMode.js index 88d50d4a..9f20990f 100644 --- a/src/hooks/useMode.js +++ b/src/hooks/useMode.js @@ -456,12 +456,21 @@ export function useMode() { // 다름 라인이 오른쪽으로 이동 if (historyLines.current[i].direction === 'top') { if (prev.direction !== 'right') { - newOuterlines.push({ - x1: historyLines.current[i].x1 - 50, - y1: historyLines.current[i].y1 + 50, - x2: historyLines.current[i].x2 - 50, - y2: historyLines.current[i].y2 - 50, - }) + if(historyLines.current.length === 6) { + newOuterlines.push({ + x1: historyLines.current[i].x1 - 50, + y1: historyLines.current[i].y1 + 50, + x2: historyLines.current[i].x2 - 50, + y2: historyLines.current[i].y2 - 50, + }) + } else if(historyLines.current.length === 8) { + newOuterlines.push({ + x1: historyLines.current[i].x1 + 50, + y1: historyLines.current[i].y1 - 50, + x2: historyLines.current[i].x2 + 50, + y2: historyLines.current[i].y2 + 50, + } + } } else { newOuterlines.push({ x1: historyLines.current[i].x1 + 50, @@ -473,12 +482,21 @@ export function useMode() { } else { // bottom if (prev?.direction !== 'right') { - newOuterlines.push({ - x1: historyLines.current[i].x1 - 50, - y1: historyLines.current[i].y1 - 50, - x2: historyLines.current[i].x2 - 50, - y2: historyLines.current[i].y2 + 50, - }) + if(historyLines.current.length === 6) { + newOuterlines.push({ + x1: historyLines.current[i].x1 - 50, + y1: historyLines.current[i].y1 - 50, + x2: historyLines.current[i].x2 - 50, + y2: historyLines.current[i].y2 + 50, + }) + } else if(historyLines.current.length === 8) { + newOuterlines.push({ + x1: historyLines.current[i].x1 + 50, + y1: historyLines.current[i].y1 + 50, + x2: historyLines.current[i].x2 + 50, + y2: historyLines.current[i].y2 - 50, + }) + } } else { newOuterlines.push({ x1: historyLines.current[i].x1 - 50, @@ -491,12 +509,21 @@ export function useMode() { } else if (next.direction === 'left') { if (historyLines.current[i].direction === 'top') { if (prev?.direction !== 'left') { - newOuterlines.push({ - x1: historyLines.current[i].x1 + 50, - y1: historyLines.current[i].y1 + 50, - x2: historyLines.current[i].x2 + 50, - y2: historyLines.current[i].y2 - 50, - }) + if(historyLines.current.length === 6) { + newOuterlines.push({ + x1: historyLines.current[i].x1 + 50, + y1: historyLines.current[i].y1 + 50, + x2: historyLines.current[i].x2 + 50, + y2: historyLines.current[i].y2 - 50, + }) + } else if(historyLines.current.length === 8) { + newOuterlines.push({ + x1: historyLines.current[i].x1 - 50, + y1: historyLines.current[i].y1 - 50, + x2: historyLines.current[i].x2 - 50, + y2: historyLines.current[i].y2 + 50, + }) + } } else { newOuterlines.push({ x1: historyLines.current[i].x1 - 50, @@ -508,12 +535,21 @@ export function useMode() { } else { // bottom if (prev?.direction !== 'left') { - newOuterlines.push({ - x1: historyLines.current[i].x1 + 50, - y1: historyLines.current[i].y1 - 50, - x2: historyLines.current[i].x2 + 50, - y2: historyLines.current[i].y2 + 50, - }) + if(historyLines.current.length === 6) { + newOuterlines.push({ + x1: historyLines.current[i].x1 + 50, + y1: historyLines.current[i].y1 - 50, + x2: historyLines.current[i].x2 + 50, + y2: historyLines.current[i].y2 + 50, + }) + } else if(historyLines.current.length === 8) { + newOuterlines.push({ + x1: historyLines.current[i].x1 - 50, + y1: historyLines.current[i].y1 + 50, + x2: historyLines.current[i].x2 - 50, + y2: historyLines.current[i].y2 - 50, + }) + } } else { newOuterlines.push({ x1: historyLines.current[i].x1 - 50, @@ -526,12 +562,21 @@ export function useMode() { } else if (next.direction === 'top') { if (historyLines.current[i].direction === 'right') { if (prev?.direction !== 'top') { - newOuterlines.push({ - x1: historyLines.current[i].x1 - 50, - y1: historyLines.current[i].y1 + 50, - x2: historyLines.current[i].x2 + 50, - y2: historyLines.current[i].y2 + 50, - }) + if(historyLines.current.length === 6) { + newOuterlines.push({ + x1: historyLines.current[i].x1 - 50, + y1: historyLines.current[i].y1 + 50, + x2: historyLines.current[i].x2 + 50, + y2: historyLines.current[i].y2 + 50, + }) + } else if(historyLines.current.length === 8) { + newOuterlines.push({ + x1: historyLines.current[i].x1 + 50, + y1: historyLines.current[i].y1 - 50, + x2: historyLines.current[i].x2 - 50, + y2: historyLines.current[i].y2 - 50, + }) + } } else { newOuterlines.push({ x1: historyLines.current[i].x1 + 50, @@ -543,12 +588,21 @@ export function useMode() { } else { // left if (prev?.direction !== 'top') { - newOuterlines.push({ - x1: historyLines.current[i].x1 + 50, - y1: historyLines.current[i].y1 + 50, - x2: historyLines.current[i].x2 - 50, - y2: historyLines.current[i].y2 + 50, - }) + if(historyLines.current.length === 6) { + newOuterlines.push({ + x1: historyLines.current[i].x1 + 50, + y1: historyLines.current[i].y1 + 50, + x2: historyLines.current[i].x2 - 50, + y2: historyLines.current[i].y2 + 50, + }) + } else if(historyLines.current.length === 8) { + newOuterlines.push({ + x1: historyLines.current[i].x1 - 50, + y1: historyLines.current[i].y1 - 50, + x2: historyLines.current[i].x2 + 50, + y2: historyLines.current[i].y2 - 50, + }) + } } else { newOuterlines.push({ x1: historyLines.current[i].x1 - 50, @@ -561,12 +615,21 @@ export function useMode() { } else if (next.direction === 'bottom') { if (historyLines.current[i].direction === 'right') { if (prev?.direction !== 'bottom') { - newOuterlines.push({ - x1: historyLines.current[i].x1 - 50, - y1: historyLines.current[i].y1 - 50, - x2: historyLines.current[i].x2 + 50, - y2: historyLines.current[i].y2 - 50, - }) + if(historyLines.current.length === 6) { + newOuterlines.push({ + x1: historyLines.current[i].x1 - 50, + y1: historyLines.current[i].y1 - 50, + x2: historyLines.current[i].x2 + 50, + y2: historyLines.current[i].y2 - 50, + }) + } else if(historyLines.current.length === 8) { + newOuterlines.push({ + x1: historyLines.current[i].x1 + 50, + y1: historyLines.current[i].y1 + 50, + x2: historyLines.current[i].x2 - 50, + y2: historyLines.current[i].y2 + 50, + }) + } } else { newOuterlines.push({ x1: historyLines.current[i].x1 - 50, @@ -578,12 +641,21 @@ export function useMode() { } else { // left if (prev.direction !== 'bottom') { - newOuterlines.push({ - x1: historyLines.current[i].x1 + 50, - y1: historyLines.current[i].y1 - 50, - x2: historyLines.current[i].x2 - 50, - y2: historyLines.current[i].y2 - 50, - }) + if(historyLines.current.length === 6) { + newOuterlines.push({ + x1: historyLines.current[i].x1 + 50, + y1: historyLines.current[i].y1 - 50, + x2: historyLines.current[i].x2 - 50, + y2: historyLines.current[i].y2 - 50, + }) + } else if(historyLines.current.length === 8) { + newOuterlines.push({ + x1: historyLines.current[i].x1 - 50, + y1: historyLines.current[i].y1 + 50, + x2: historyLines.current[i].x2 + 50, + y2: historyLines.current[i].y2 + 50, + }) + } } else { newOuterlines.push({ x1: historyLines.current[i].x1 - 50,