fix: canvas 체크 로직 수정

This commit is contained in:
yoosangwook 2024-08-01 11:28:27 +09:00
parent e26c751e73
commit 495b95e991

View File

@ -42,18 +42,18 @@ export function useCanvas(id) {
useEffect(() => { useEffect(() => {
canvas canvas
?.getObjects() ?.getObjects()
.filter((obj) => obj.type === 'textbox' || obj.type === 'text' || obj.type === 'i-text') ?.filter((obj) => obj.type === 'textbox' || obj.type === 'text' || obj.type === 'i-text')
.forEach((obj) => { .forEach((obj) => {
obj.set({ fontSize: fontSize }) obj.set({ fontSize: fontSize })
}) })
canvas canvas
?.getObjects() ?.getObjects()
.filter((obj) => obj.type === 'QLine' || obj.type === 'QPolygon' || obj.type === 'QRect') ?.filter((obj) => obj.type === 'QLine' || obj.type === 'QPolygon' || obj.type === 'QRect')
.forEach((obj) => { .forEach((obj) => {
obj.setFontSize(fontSize) obj.setFontSize(fontSize)
}) })
canvas?.renderAll() canvas?.getObjects().length > 0 && canvas?.renderAll()
}, [fontSize]) }, [fontSize])
/** /**
@ -103,7 +103,7 @@ export function useCanvas(id) {
} }
const initialize = () => { const initialize = () => {
canvas?.clear() canvas.getObjects().length > 0 && canvas?.clear()
// settings for all canvas in the app // settings for all canvas in the app
fabric.Object.prototype.transparentCorners = false fabric.Object.prototype.transparentCorners = false
fabric.Object.prototype.cornerColor = '#2BEBC8' fabric.Object.prototype.cornerColor = '#2BEBC8'