From 971976bf2a02130586266f49d4e7e5ab41543085 Mon Sep 17 00:00:00 2001 From: Michael Peters Date: Sat, 20 Jul 2024 17:17:01 -0700 Subject: [PATCH] reuse in startPoint element --- src/components/grid/grid.tsx | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/components/grid/grid.tsx b/src/components/grid/grid.tsx index d1576ad..aa117d8 100644 --- a/src/components/grid/grid.tsx +++ b/src/components/grid/grid.tsx @@ -153,7 +153,6 @@ const Grid: FC = () => { ); setRedoActions([]); - // single-click tools if (drawModeInfo.pointsType === 'single') { const toolLines = drawModeInfo.getToolLines( point, @@ -165,7 +164,6 @@ const Grid: FC = () => { return; } - // click and drag tools ------------------------------------------- if (lodash.isEqual(startPoint, point)) { setStartPoint(null); return; @@ -330,17 +328,12 @@ const Grid: FC = () => { }, [startPoint, mousePoint, drawMode, drawModeInfo, lineColor]); const startPointElement = useMemo(() => { - let point = snapToGrid( + if (drawModeInfo.pointsType === 'single') return null; + const point = snapToGrid( mousePoint, drawModeInfo.gridGap, drawModeInfo.gridOffset ); - if ( - drawMode === 'square' || - drawMode === 'square-small' || - drawMode === 'star' - ) - return null; return ( { cy={point.y} r="4" fill={ - drawMode === 'line' || drawMode === 'grid' - ? lineColor - : '#ff0000' + drawModeInfo.pointsType === 'double' ? lineColor : '#ff0000' } /> );