Removed fog guidelines of touch end

This commit is contained in:
Mitchell McCaffrey 2021-02-22 17:04:35 +11:00
parent 95864dd933
commit d244471870

View File

@ -245,7 +245,7 @@ function MapFog({
setIsBrushDown(false); setIsBrushDown(false);
} }
function handlePolygonClick() { function handlePointerClick() {
if (toolSettings.type === "polygon") { if (toolSettings.type === "polygon") {
const brushPosition = getBrushPosition(); const brushPosition = getBrushPosition();
setDrawingShape((prevDrawingShape) => { setDrawingShape((prevDrawingShape) => {
@ -274,7 +274,7 @@ function MapFog({
} }
} }
function handlePolygonMove() { function handlePointerMove() {
if ( if (
active && active &&
(toolSettings.type === "polygon" || toolSettings.type === "rectangle") (toolSettings.type === "polygon" || toolSettings.type === "rectangle")
@ -329,21 +329,27 @@ function MapFog({
} }
} }
function handelTouchEnd() {
setGuides([]);
}
interactionEmitter.on("dragStart", handleBrushDown); interactionEmitter.on("dragStart", handleBrushDown);
interactionEmitter.on("drag", handleBrushMove); interactionEmitter.on("drag", handleBrushMove);
interactionEmitter.on("dragEnd", handleBrushUp); interactionEmitter.on("dragEnd", handleBrushUp);
// Use mouse events for polygon and erase to allow for single clicks // Use mouse events for polygon and erase to allow for single clicks
mapStage.on("mousedown touchstart", handlePolygonMove); mapStage.on("mousedown touchstart", handlePointerMove);
mapStage.on("mousemove touchmove", handlePolygonMove); mapStage.on("mousemove touchmove", handlePointerMove);
mapStage.on("click tap", handlePolygonClick); mapStage.on("click tap", handlePointerClick);
mapStage.on("touchend", handelTouchEnd);
return () => { return () => {
interactionEmitter.off("dragStart", handleBrushDown); interactionEmitter.off("dragStart", handleBrushDown);
interactionEmitter.off("drag", handleBrushMove); interactionEmitter.off("drag", handleBrushMove);
interactionEmitter.off("dragEnd", handleBrushUp); interactionEmitter.off("dragEnd", handleBrushUp);
mapStage.off("mousedown touchstart", handlePolygonMove); mapStage.off("mousedown touchstart", handlePointerMove);
mapStage.off("mousemove touchmove", handlePolygonMove); mapStage.off("mousemove touchmove", handlePointerMove);
mapStage.off("click tap", handlePolygonClick); mapStage.off("click tap", handlePointerClick);
mapStage.off("touchend", handelTouchEnd);
}; };
}); });