points 수정되는 경우 길이,각도,방향 값 초기화

This commit is contained in:
hyojun.choi 2024-09-23 13:15:40 +09:00
parent 1a98f1448a
commit 8be9d2ed7f
3 changed files with 10 additions and 6 deletions

View File

@ -48,6 +48,7 @@ export default function OuterLineWall(props) {
useEffect(() => { useEffect(() => {
removeMouseEvent('mouse:down', mouseDown) removeMouseEvent('mouse:down', mouseDown)
addCanvasMouseEventListener('mouse:down', mouseDown) addCanvasMouseEventListener('mouse:down', mouseDown)
clear()
return () => { return () => {
removeAllMouseEventListeners() removeAllMouseEventListeners()
} }
@ -73,6 +74,8 @@ export default function OuterLineWall(props) {
setArrow1('') setArrow1('')
setArrow2('') setArrow2('')
setAngle1(0)
} }
const mouseDown = (e) => { const mouseDown = (e) => {
@ -168,7 +171,7 @@ export default function OuterLineWall(props) {
return return
} }
if (lastPoint.x === firstPoint.x && lastPoint.y === firstPoint.y) { /*if (lastPoint.x === firstPoint.x && lastPoint.y === firstPoint.y) {
return return
} }
@ -222,7 +225,7 @@ export default function OuterLineWall(props) {
canvas?.add(guideLine2) canvas?.add(guideLine2)
addLineText(guideLine2) addLineText(guideLine2)
} }*/
} }
}, [points]) }, [points])

View File

@ -1,7 +1,6 @@
import { useEffect, useState } from 'react' import { useState } from 'react'
import { fabric } from 'fabric'
import { useRecoilState, useRecoilValue } from 'recoil' import { useRecoilState, useRecoilValue } from 'recoil'
import { canvasSizeState, currentObjectState, modeState } from '@/store/canvasAtom' import { canvasSizeState, currentObjectState } from '@/store/canvasAtom'
import { QPolygon } from '@/components/fabric/QPolygon' import { QPolygon } from '@/components/fabric/QPolygon'
// 캔버스에 필요한 이벤트 // 캔버스에 필요한 이벤트

View File

@ -19,7 +19,9 @@ export const useLine = () => {
const addLineText = (line, length = getLengthByLine(line)) => { const addLineText = (line, length = getLengthByLine(line)) => {
removeLineText(line) removeLineText(line)
const text = new fabric.Text(length.toFixed(0), { const lengthTxt = isNaN(Number(length)) ? length : length.toFixed(0)
const text = new fabric.Text(lengthTxt, {
left: (line.x2 + line.x1) / 2, left: (line.x2 + line.x1) / 2,
top: (line.y2 + line.y1) / 2, top: (line.y2 + line.y1) / 2,
parent: line, parent: line,