Fix drawing erase while on controls and brush type switch bug

This commit is contained in:
Mitchell McCaffrey 2020-04-29 09:25:56 +10:00
parent aac11790e2
commit 6e48d7d4e2
2 changed files with 12 additions and 8 deletions

View File

@ -155,19 +155,19 @@ function MapDrawing({
if (event.touches && event.touches.length !== 0) {
return;
}
setIsDrawing(false);
if (selectedTool === "brush") {
if (selectedTool === "brush" && drawingShape) {
if (drawingShape.data.points.length > 1) {
onShapeAdd(drawingShape);
}
} else if (selectedTool === "shape") {
} else if (selectedTool === "shape" && drawingShape) {
onShapeAdd(drawingShape);
}
setDrawingShape(null);
if (selectedTool === "erase" && hoveredShapeRef.current) {
if (selectedTool === "erase" && hoveredShapeRef.current && isDrawing) {
onShapeRemove(hoveredShapeRef.current.id);
}
setIsDrawing(false);
setDrawingShape(null);
}
// Add listeners for draw events on map to allow drawing past the bounds

View File

@ -122,7 +122,6 @@ function MapFog({
if (event.touches && event.touches.length !== 0) {
return;
}
setIsDrawing(false);
if (isEditing && toolSettings.type === "add" && drawingShape) {
if (drawingShape.data.points.length > 1) {
const shape = {
@ -134,10 +133,15 @@ function MapFog({
}
}
setDrawingShape(null);
if (toolSettings.type === "remove" && hoveredShapeRef.current) {
if (
toolSettings.type === "remove" &&
hoveredShapeRef.current &&
isDrawing
) {
onShapeRemove(hoveredShapeRef.current.id);
}
setDrawingShape(null);
setIsDrawing(false);
}
// Add listeners for draw events on map to allow drawing past the bounds