From f48a39c3ad105113434fe87256839a589070b5fe Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Fri, 20 Nov 2020 09:24:28 +1100 Subject: [PATCH 1/3] Fix erase of drawing and fog with a short click --- src/components/map/MapDrawing.js | 14 +++++++++---- src/components/map/MapFog.js | 34 +++++++++++++++++++------------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/components/map/MapDrawing.js b/src/components/map/MapDrawing.js index 11c54df..8bf33c9 100644 --- a/src/components/map/MapDrawing.js +++ b/src/components/map/MapDrawing.js @@ -137,10 +137,7 @@ function MapDrawing({ onShapeAdd(drawingShape); } - if (erasingShapes.length > 0) { - onShapesRemove(erasingShapes.map((shape) => shape.id)); - setErasingShapes([]); - } + eraseHoveredShapes(); setDrawingShape(null); setIsBrushDown(false); @@ -165,6 +162,13 @@ function MapDrawing({ } } + function eraseHoveredShapes() { + if (erasingShapes.length > 0) { + onShapesRemove(erasingShapes.map((shape) => shape.id)); + setErasingShapes([]); + } + } + function renderShape(shape) { const defaultProps = { key: shape.id, @@ -172,6 +176,8 @@ function MapDrawing({ onTouchOver: () => handleShapeOver(shape, isBrushDown), onMouseDown: () => handleShapeOver(shape, true), onTouchStart: () => handleShapeOver(shape, true), + onMouseUp: eraseHoveredShapes, + onTouchEnd: eraseHoveredShapes, fill: colors[shape.color] || shape.color, opacity: shape.blend ? 0.5 : 1, id: shape.id, diff --git a/src/components/map/MapFog.js b/src/components/map/MapFog.js index be9e043..d58c530 100644 --- a/src/components/map/MapFog.js +++ b/src/components/map/MapFog.js @@ -144,20 +144,7 @@ function MapFog({ setDrawingShape(null); } - // Erase - if (editingShapes.length > 0) { - if (toolSettings.type === "remove") { - onShapesRemove(editingShapes.map((shape) => shape.id)); - } else if (toolSettings.type === "toggle") { - onShapesEdit( - editingShapes.map((shape) => ({ - ...shape, - visible: !shape.visible, - })) - ); - } - setEditingShapes([]); - } + eraseHoveredShapes(); setIsBrushDown(false); } @@ -281,6 +268,23 @@ function MapFog({ useKeyboard(handleKeyDown, handleKeyUp); + function eraseHoveredShapes() { + // Erase + if (editingShapes.length > 0) { + if (toolSettings.type === "remove") { + onShapesRemove(editingShapes.map((shape) => shape.id)); + } else if (toolSettings.type === "toggle") { + onShapesEdit( + editingShapes.map((shape) => ({ + ...shape, + visible: !shape.visible, + })) + ); + } + setEditingShapes([]); + } + } + function handleShapeOver(shape, isDown) { if (shouldHover && isDown) { if (editingShapes.findIndex((s) => s.id === shape.id) === -1) { @@ -305,6 +309,8 @@ function MapFog({ onTouchOver={() => handleShapeOver(shape, isBrushDown)} onMouseDown={() => handleShapeOver(shape, true)} onTouchStart={() => handleShapeOver(shape, true)} + onMouseUp={eraseHoveredShapes} + onTouchEnd={eraseHoveredShapes} points={points} stroke={colors[shape.color] || shape.color} fill={colors[shape.color] || shape.color} From 0883c1d79c987e3c0f1757da10ac5590e6cb2ede Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Fri, 20 Nov 2020 09:24:49 +1100 Subject: [PATCH 2/3] Fix unnamed default export warning --- src/docs/assets/index.js | 4 +++- src/theme.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/docs/assets/index.js b/src/docs/assets/index.js index 7c2bb32..6c7f584 100644 --- a/src/docs/assets/index.js +++ b/src/docs/assets/index.js @@ -26,7 +26,7 @@ import filteringMaps from "./FilteringMaps.mp4"; import groupAndRemovingTokens from "./GroupAndRemovingTokens.mp4"; import filteringTokens from "./FilteringTokens.mp4"; -export default { +const assets = { defaultMaps, customMaps, editingMapsAdvanced, @@ -55,3 +55,5 @@ export default { groupAndRemovingTokens, filteringTokens, }; + +export default assets; diff --git a/src/theme.js b/src/theme.js index 5be2da1..6a1d4c8 100644 --- a/src/theme.js +++ b/src/theme.js @@ -1,4 +1,4 @@ -export default { +const theme = { colors: { text: "hsl(210, 50%, 96%)", background: "hsl(230, 25%, 18%)", @@ -281,3 +281,5 @@ export default { }, }, }; + +export default theme; From c54b8633307febdfb25b3ab1fd52c755514ee162 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Fri, 20 Nov 2020 09:24:58 +1100 Subject: [PATCH 3/3] Fixed unused import warning --- src/network/Connection.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/network/Connection.js b/src/network/Connection.js index daf312c..40c490d 100644 --- a/src/network/Connection.js +++ b/src/network/Connection.js @@ -3,7 +3,6 @@ import { encode, decode } from "@msgpack/msgpack"; import shortid from "shortid"; import blobToBuffer from "../helpers/blobToBuffer"; -import { logError } from "../helpers/logging"; // Limit buffer size to 16kb to avoid issues with chrome packet size // http://viblast.com/blog/2015/2/5/webrtc-data-channel-message-size/