둘다 체크시도 추가
This commit is contained in:
parent
9fa384db0d
commit
3ab518e188
@ -140,6 +140,33 @@ export function useMode() {
|
|||||||
let newY = pointer.y
|
let newY = pointer.y
|
||||||
|
|
||||||
if (isGuideLineMode && isGuideDotMode && mode === Mode.EDIT) {
|
if (isGuideLineMode && isGuideDotMode && mode === Mode.EDIT) {
|
||||||
|
const closestHorizontalLine = getClosestHorizontalLine(pointer, horizontalLineArray)
|
||||||
|
const closetVerticalLine = getClosestVerticalLine(pointer, verticalLineArray)
|
||||||
|
const xDiff = Math.abs(pointer.x - closetVerticalLine.x1)
|
||||||
|
const yDiff = Math.abs(pointer.y - closestHorizontalLine.y1)
|
||||||
|
|
||||||
|
const x = pointer.x - guideLineLength * Math.floor(pointer.x / guideLineLength)
|
||||||
|
const y = pointer.y - guideLineLength * Math.floor(pointer.y / guideLineLength)
|
||||||
|
|
||||||
|
const xRate = x / guideLineLength
|
||||||
|
const yRate = y / guideLineLength
|
||||||
|
const isAttachX = xRate >= 0.4 && xRate <= 0.7
|
||||||
|
const isAttachY = yRate >= 0.4 && yRate <= 0.7
|
||||||
|
|
||||||
|
if (isAttachX && isAttachY) {
|
||||||
|
newX = Math.floor(pointer.x / guideLineLength) * guideLineLength + guideLineLength / 2
|
||||||
|
newY = Math.floor(pointer.y / guideLineLength) * guideLineLength + guideLineLength / 2
|
||||||
|
} else {
|
||||||
|
if (Math.min(xDiff, yDiff) <= 20) {
|
||||||
|
if (xDiff < yDiff) {
|
||||||
|
newX = closetVerticalLine.x1
|
||||||
|
newY = pointer.y
|
||||||
|
} else {
|
||||||
|
newX = pointer.x
|
||||||
|
newY = closestHorizontalLine.y1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (isGuideDotMode && mode === Mode.EDIT) {
|
} else if (isGuideDotMode && mode === Mode.EDIT) {
|
||||||
const x = pointer.x - guideDotLength * Math.floor(pointer.x / guideDotLength)
|
const x = pointer.x - guideDotLength * Math.floor(pointer.x / guideDotLength)
|
||||||
const y = pointer.y - guideDotLength * Math.floor(pointer.y / guideDotLength)
|
const y = pointer.y - guideDotLength * Math.floor(pointer.y / guideDotLength)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user