[1046] - 댓글
1. 임의그리드 우클릭 흡착점에 생성 2. 임의그리드 생성 후 mouseLine 안그려지는 현상 수정
This commit is contained in:
parent
058a3eabc6
commit
d8a7986120
@ -2,7 +2,14 @@ import { useRef } from 'react'
|
||||
import { useRecoilValue, useSetRecoilState } from 'recoil'
|
||||
import { canvasState, canvasZoomState, currentMenuState, textModeState } from '@/store/canvasAtom'
|
||||
import { fabric } from 'fabric'
|
||||
import { calculateDistance, calculateDistancePoint, calculateIntersection, distanceBetweenPoints, findClosestPoint } from '@/util/canvas-util'
|
||||
import {
|
||||
calculateDistance,
|
||||
calculateDistancePoint,
|
||||
calculateIntersection,
|
||||
distanceBetweenPoints,
|
||||
findClosestPoint,
|
||||
getInterSectionLineNotOverCoordinate,
|
||||
} from '@/util/canvas-util'
|
||||
import { useAdsorptionPoint } from '@/hooks/useAdsorptionPoint'
|
||||
import { useDotLineGrid } from '@/hooks/useDotLineGrid'
|
||||
import { useTempGrid } from '@/hooks/useTempGrid'
|
||||
@ -146,7 +153,7 @@ export function useEvent() {
|
||||
...innerLinePoints,
|
||||
]
|
||||
|
||||
if (dotLineGridSetting.LINE || canvas.getObjects().filter((obj) => ['lineGrid', 'tempGrid'].includes(obj.name)).length > 0) {
|
||||
if (dotLineGridSetting.LINE || canvas.getObjects().filter((obj) => ['lineGrid', 'tempGrid'].includes(obj.name)).length > 1) {
|
||||
const closestLine = getClosestLineGrid(pointer)
|
||||
|
||||
const horizonLines = canvas.getObjects().filter((obj) => ['lineGrid', 'tempGrid'].includes(obj.name) && obj.direction === 'horizontal')
|
||||
@ -260,7 +267,9 @@ export function useEvent() {
|
||||
arrivalPoint = guideIntersectionPoint
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
|
||||
const horizontalLine = new fabric.Line([-4 * canvas.width, arrivalPoint.y, 4 * canvas.width, arrivalPoint.y], {
|
||||
stroke: 'red',
|
||||
@ -298,7 +307,12 @@ export function useEvent() {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
//임의 그리드 모드일 경우
|
||||
let pointer = { x: e.offsetX, y: e.offsetY }
|
||||
let originPointer = { x: e.offsetX, y: e.offsetY }
|
||||
const mouseLines = canvas.getObjects().filter((obj) => obj.name === 'mouseLine')
|
||||
let pointer = getInterSectionLineNotOverCoordinate(mouseLines[0], mouseLines[1]) || {
|
||||
x: Math.round(originPointer.x),
|
||||
y: Math.round(originPointer.y),
|
||||
}
|
||||
|
||||
const tempGrid = new fabric.Line([-1500, pointer.y, 2500, pointer.y], {
|
||||
stroke: gridColor,
|
||||
|
||||
@ -2,6 +2,7 @@ import { canvasState, tempGridModeState } from '@/store/canvasAtom'
|
||||
import { useRecoilState, useRecoilValue } from 'recoil'
|
||||
import { gridColorState } from '@/store/gridAtom'
|
||||
import { gridDisplaySelector } from '@/store/settingAtom'
|
||||
import { useMouse } from '@/hooks/useMouse'
|
||||
|
||||
const GRID_PADDING = 5
|
||||
export function useTempGrid() {
|
||||
@ -9,10 +10,10 @@ export function useTempGrid() {
|
||||
const gridColor = useRecoilValue(gridColorState)
|
||||
const isGridDisplay = useRecoilValue(gridDisplaySelector)
|
||||
const [tempGridMode, setTempGridMode] = useRecoilState(tempGridModeState)
|
||||
|
||||
const { getIntersectMousePoint } = useMouse()
|
||||
const tempGridModeStateLeftClickEvent = (e) => {
|
||||
//임의 그리드 모드일 경우
|
||||
let pointer = canvas.getPointer(e.e)
|
||||
let pointer = getIntersectMousePoint(e)
|
||||
|
||||
const tempGrid = new fabric.Line([pointer.x, -1500, pointer.x, 2500], {
|
||||
stroke: gridColor,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user