diff --git a/src/components/map/MapDrawing.js b/src/components/map/MapDrawing.js index 11c54df..67362aa 100644 --- a/src/components/map/MapDrawing.js +++ b/src/components/map/MapDrawing.js @@ -55,8 +55,8 @@ function MapDrawing({ return getBrushPositionForTool( map, getRelativePointerPositionNormalized(mapImage), - toolId, - toolSettings, + map.snapToGrid && isShape, + false, gridSize, shapes ); diff --git a/src/components/map/MapFog.js b/src/components/map/MapFog.js index be9e043..e183071 100644 --- a/src/components/map/MapFog.js +++ b/src/components/map/MapFog.js @@ -61,8 +61,8 @@ function MapFog({ return getBrushPositionForTool( map, getRelativePointerPositionNormalized(mapImage), - toolId, - toolSettings, + map.snapToGrid && toolSettings.type === "polygon", + toolSettings.useEdgeSnapping, gridSize, shapes ); diff --git a/src/components/map/MapMeasure.js b/src/components/map/MapMeasure.js index c3544a7..bd96019 100644 --- a/src/components/map/MapMeasure.js +++ b/src/components/map/MapMeasure.js @@ -38,8 +38,8 @@ function MapMeasure({ map, selectedToolSettings, active, gridSize }) { return getBrushPositionForTool( map, getRelativePointerPositionNormalized(mapImage), - "drawing", - { type: "line" }, + map.snapToGrid, + false, gridSize, [] ); diff --git a/src/helpers/drawing.js b/src/helpers/drawing.js index 50c7e57..8ab54bf 100644 --- a/src/helpers/drawing.js +++ b/src/helpers/drawing.js @@ -8,22 +8,13 @@ const snappingThreshold = 1 / 5; export function getBrushPositionForTool( map, brushPosition, - tool, - toolSettings, + useGridSnappning, + useEdgeSnapping, gridSize, shapes ) { let position = brushPosition; - const useGridSnappning = - map.snapToGrid && - ((tool === "drawing" && - (toolSettings.type === "line" || - toolSettings.type === "rectangle" || - toolSettings.type === "circle" || - toolSettings.type === "triangle")) || - (tool === "fog" && toolSettings.type === "polygon")); - if (useGridSnappning) { // Snap to corners of grid // Subtract offset to transform into offset space then add it back transform back @@ -58,8 +49,6 @@ export function getBrushPositionForTool( } } - const useEdgeSnapping = tool === "fog" && toolSettings.useEdgeSnapping; - if (useEdgeSnapping) { const minGrid = Vector2.min(gridSize); let closestDistance = Number.MAX_VALUE;