흡착점 작업
This commit is contained in:
parent
f915dab239
commit
c467fc7fa8
@ -549,6 +549,7 @@ export function useModuleBasicSetting(tabNum) {
|
||||
* 스냅기능
|
||||
*/
|
||||
let snapDistance = flowDirection === 'south' || flowDirection === 'north' ? 70 : 40
|
||||
let sideSnapDistance = 15
|
||||
let trestleSnapDistance = 15
|
||||
|
||||
let intvHor =
|
||||
@ -588,51 +589,102 @@ export function useModuleBasicSetting(tabNum) {
|
||||
const holdCellCenterX = holdCellLeft + toFixedWithoutRounding(cell.width / 2, 2)
|
||||
const holdCellCenterY = holdCellTop + toFixedWithoutRounding(cell.height / 2, 2)
|
||||
|
||||
//흐름방향따라 달라야 한다.
|
||||
if (flowDirection === 'south' || flowDirection === 'north') {
|
||||
if (Math.abs(smallCenterX - holdCellCenterX) < snapDistance) {
|
||||
//움직이는 모듈 가운데 -> 설치 모듈 가운데
|
||||
tempModule.left = holdCellCenterX - toFixedWithoutRounding(width / 2, 2)
|
||||
}
|
||||
|
||||
//움직이는 모듈왼쪽 -> 가운데
|
||||
if (Math.abs(smallLeft - holdCellCenterX) < snapDistance) {
|
||||
tempModule.left = holdCellCenterX + intvHor / 2
|
||||
}
|
||||
// 오른쪽 -> 가운데
|
||||
if (Math.abs(smallRight - holdCellCenterX) < snapDistance) {
|
||||
tempModule.left = holdCellCenterX - width - intvHor / 2
|
||||
}
|
||||
|
||||
//설치된 셀에 좌측에 스냅
|
||||
if (Math.abs(smallRight - holdCellLeft) < snapDistance) {
|
||||
// console.log('모듈 좌측 스냅')
|
||||
tempModule.left = holdCellLeft - width - intvHor
|
||||
}
|
||||
|
||||
//설치된 셀에 우측에 스냅
|
||||
if (Math.abs(smallLeft - holdCellRight) < snapDistance) {
|
||||
// console.log('모듈 우측 스냅')
|
||||
tempModule.left = holdCellRight + intvHor
|
||||
}
|
||||
//설치된 셀에 위쪽에 스냅
|
||||
if (Math.abs(smallBottom - holdCellTop) < sideSnapDistance) {
|
||||
tempModule.top = holdCellTop - height - intvVer
|
||||
}
|
||||
|
||||
//설치된 셀에 밑쪽에 스냅
|
||||
if (Math.abs(smallTop - holdCellBottom) < sideSnapDistance) {
|
||||
tempModule.top = holdCellBottom + intvVer
|
||||
}
|
||||
|
||||
//설치된 셀에 윗쪽에 스냅
|
||||
if (Math.abs(smallTop - holdCellTop) < sideSnapDistance) {
|
||||
tempModule.top = holdCellTop
|
||||
}
|
||||
} else {
|
||||
//흐름방향 west, east
|
||||
|
||||
//가운데 가운데
|
||||
if (Math.abs(smallCenterY - holdCellCenterY) < snapDistance) {
|
||||
tempModule.top = holdCellCenterY - toFixedWithoutRounding(width / 2, 2)
|
||||
}
|
||||
|
||||
//위쪽 -> 가운데
|
||||
if (Math.abs(smallTop - holdCellCenterY) < snapDistance) {
|
||||
// console.log('holdCellCenterX', holdCellCenterX)
|
||||
// console.log('smallLeft', smallLeft)
|
||||
|
||||
// console.log('모듈 센터에 스냅')
|
||||
tempModule.top = holdCellCenterY + intvHor / 2
|
||||
|
||||
// console.log('tempModule.left', tempModule.left)
|
||||
}
|
||||
// 밑 -> 가운데
|
||||
if (Math.abs(smallBottom - holdCellCenterY) < snapDistance) {
|
||||
tempModule.top = holdCellCenterY - height - intvHor / 2
|
||||
}
|
||||
|
||||
//설치된 셀에 좌측에 스냅
|
||||
if (Math.abs(smallRight - holdCellLeft) < snapDistance) {
|
||||
// console.log('모듈 좌측 스냅')
|
||||
tempModule.left = holdCellLeft - width - intvHor
|
||||
}
|
||||
|
||||
//설치된 셀에 우측에 스냅
|
||||
if (Math.abs(smallLeft - holdCellRight) < snapDistance) {
|
||||
// console.log('모듈 우측 스냅')
|
||||
tempModule.left = holdCellRight + intvHor
|
||||
}
|
||||
//설치된 셀에 위쪽에 스냅
|
||||
if (Math.abs(smallBottom - holdCellTop) < sideSnapDistance) {
|
||||
tempModule.top = holdCellTop - height - intvVer
|
||||
}
|
||||
|
||||
//설치된 셀에 밑쪽에 스냅
|
||||
if (Math.abs(smallTop - holdCellBottom) < sideSnapDistance) {
|
||||
tempModule.top = holdCellBottom + intvVer
|
||||
}
|
||||
|
||||
//설치된 셀에 윗쪽에 스냅
|
||||
if (Math.abs(smallTop - holdCellTop) < sideSnapDistance) {
|
||||
tempModule.top = holdCellTop
|
||||
}
|
||||
|
||||
if (Math.abs(smallLeft - holdCellLeft) < snapDistance) {
|
||||
tempModule.left = holdCellLeft
|
||||
}
|
||||
}
|
||||
|
||||
//가운데 -> 가운대
|
||||
if (Math.abs(smallCenterX - holdCellCenterX) < snapDistance) {
|
||||
tempModule.left = holdCellCenterX - toFixedWithoutRounding(width / 2, 2)
|
||||
}
|
||||
|
||||
//왼쪽 -> 가운데
|
||||
if (Math.abs(smallLeft - holdCellCenterX) < snapDistance) {
|
||||
// console.log('holdCellCenterX', holdCellCenterX)
|
||||
// console.log('smallLeft', smallLeft)
|
||||
|
||||
// console.log('모듈 센터에 스냅')
|
||||
tempModule.left = holdCellCenterX + intvHor / 2
|
||||
|
||||
// console.log('tempModule.left', tempModule.left)
|
||||
}
|
||||
// 오른쪽 -> 가운데
|
||||
if (Math.abs(smallRight - holdCellCenterX) < snapDistance) {
|
||||
tempModule.left = holdCellCenterX - width - intvHor / 2
|
||||
}
|
||||
|
||||
//설치된 셀에 좌측에 스냅
|
||||
if (Math.abs(smallRight - holdCellLeft) < snapDistance) {
|
||||
// console.log('모듈 좌측 스냅')
|
||||
tempModule.left = holdCellLeft - width - intvHor
|
||||
}
|
||||
|
||||
//설치된 셀에 우측에 스냅
|
||||
if (Math.abs(smallLeft - holdCellRight) < snapDistance) {
|
||||
// console.log('모듈 우측 스냅')
|
||||
tempModule.left = holdCellRight + intvHor
|
||||
}
|
||||
//설치된 셀에 위쪽에 스냅
|
||||
if (Math.abs(smallBottom - holdCellTop) < 10) {
|
||||
tempModule.top = holdCellTop - height - intvVer
|
||||
}
|
||||
|
||||
//설치된 셀에 밑쪽에 스냅
|
||||
if (Math.abs(smallTop - holdCellBottom) < 10) {
|
||||
tempModule.top = holdCellBottom + intvVer
|
||||
}
|
||||
|
||||
//설치된 셀에 윗쪽에 스냅
|
||||
if (Math.abs(smallTop - holdCellTop) < 10) {
|
||||
tempModule.top = holdCellTop
|
||||
}
|
||||
|
||||
//세로 가운데 -> 가운데
|
||||
// if (Math.abs(smallCenterY - holdCellCenterY) < snapDistance) {
|
||||
@ -641,11 +693,6 @@ export function useModuleBasicSetting(tabNum) {
|
||||
// //위쪽 -> 가운데
|
||||
// if (Math.abs(smallTop - holdCellCenterY) < cellSnapDistance) {
|
||||
// tempModule.top = holdCellCenterY
|
||||
// }
|
||||
// //아랫쪽 -> 가운데
|
||||
// if (Math.abs(smallBottom - holdCellCenterY) < cellSnapDistance) {
|
||||
// tempModule.top = holdCellCenterY - height
|
||||
// }
|
||||
})
|
||||
}
|
||||
|
||||
@ -673,22 +720,19 @@ export function useModuleBasicSetting(tabNum) {
|
||||
// if (Math.abs(smallLeft - (trestleLeft + moduleSetupSurfaces[i].width / 2)) < snapDistance) {
|
||||
// tempModule.left = trestleLeft + moduleSetupSurfaces[i].width / 2
|
||||
// }
|
||||
|
||||
// 모듈이 가운데가 세로중앙선에 붙게 스냅
|
||||
if (Math.abs(smallCenterX - (trestleLeft + moduleSetupSurfaces[i].width / 2)) < trestleSnapDistance) {
|
||||
tempModule.left = trestleLeft + moduleSetupSurfaces[i].width / 2 - tempModule.width / 2
|
||||
}
|
||||
|
||||
// if (Math.abs(smallCenterX - (trestleLeft + moduleSetupSurfaces[i].width / 2)) < trestleSnapDistance) {
|
||||
// tempModule.left = trestleLeft + moduleSetupSurfaces[i].width / 2 - tempModule.width / 2
|
||||
// }
|
||||
// 모듈오른쪽이 세로중앙선에 붙게 스냅
|
||||
// if (Math.abs(smallRight - (trestleLeft + moduleSetupSurfaces[i].width / 2)) < trestleSnapDistance) {
|
||||
// tempModule.left = trestleLeft + moduleSetupSurfaces[i].width / 2 - tempModule.width * tempModule.scaleX
|
||||
// }
|
||||
} else {
|
||||
// 모듈이 가로중앙선에 스냅
|
||||
if (Math.abs(smallTop + tempModule.height / 2 - bigCenterY) < trestleSnapDistance) {
|
||||
tempModule.top = bigCenterY - tempModule.height / 2
|
||||
}
|
||||
|
||||
// if (Math.abs(smallTop + tempModule.height / 2 - bigCenterY) < trestleSnapDistance) {
|
||||
// tempModule.top = bigCenterY - tempModule.height / 2
|
||||
// }
|
||||
// if (Math.abs(smallTop - (trestleTop + moduleSetupSurfaces[i].height / 2)) < trestleSnapDistance) {
|
||||
// tempModule.top = trestleTop + moduleSetupSurfaces[i].height / 2
|
||||
// }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user