fix: syntax bug fix

const 변수에 값 재할당 오류
This commit is contained in:
nalpari 2024-07-05 04:14:25 +09:00
parent 223def4473
commit 41b8dea43a

View File

@ -353,47 +353,46 @@ export function useMode() {
// 캔버스에서 모든 라인 객체를 찾습니다. // 캔버스에서 모든 라인 객체를 찾습니다.
const lines = otherLines || historyLines.current const lines = otherLines || historyLines.current
if (!otherLines) { if (!otherLines) {
const sortedIndex = getStartIndex(lines) const sortedIndex = getStartIndex(lines)
const tmpArraySorted = rearrangeArray(lines, sortedIndex) const tmpArraySorted = rearrangeArray(lines, sortedIndex)
function findTopTwoIndexesByDistance(objArr) { function findTopTwoIndexesByDistance(objArr) {
if (objArr.length < 2) { if (objArr.length < 2) {
return []; // 배열의 길이가 2보다 작으면 빈 배열 반환 return [] // 배열의 길이가 2보다 작으면 빈 배열 반환
} }
let firstIndex = -1; let firstIndex = -1
let secondIndex = -1; let secondIndex = -1
let firstDistance = -Infinity; let firstDistance = -Infinity
let secondDistance = -Infinity; let secondDistance = -Infinity
for (let i = 0; i < objArr.length; i++) { for (let i = 0; i < objArr.length; i++) {
const distance = objArr[i].length; const distance = objArr[i].length
if (distance > firstDistance) { if (distance > firstDistance) {
secondDistance = firstDistance; secondDistance = firstDistance
secondIndex = firstIndex; secondIndex = firstIndex
firstDistance = distance; firstDistance = distance
firstIndex = i; firstIndex = i
} else if (distance > secondDistance) { } else if (distance > secondDistance) {
secondDistance = distance; secondDistance = distance
secondIndex = i; secondIndex = i
} }
} }
return [firstIndex, secondIndex]; return [firstIndex, secondIndex]
} }
const topIndex = findTopTwoIndexesByDistance(tmpArraySorted); const topIndex = findTopTwoIndexesByDistance(tmpArraySorted)
const shape = 0; let shape = 0
if(topIndex[0] === 2) { if (topIndex[0] === 2) {
if(topIndex[1] === 3) shape = 1 if (topIndex[1] === 3) shape = 1
}else if(topIndex === 1){ } else if (topIndex === 1) {
if(topIndex[1] === 2) shape = 4 if (topIndex[1] === 2) shape = 4
} }
historyLines.current = [] historyLines.current = []
} }