From 07e85f46a30d7d868ea0354eefdd1669a5600d23 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Fri, 8 May 2020 14:22:02 +1000 Subject: [PATCH] Move dice to overlay and move map interaction to prevent map movement while interacting with dice --- src/components/map/MapControls.js | 31 +--------------------------- src/components/map/MapDice.js | 11 ++++++++-- src/components/map/MapInteraction.js | 4 ++-- 3 files changed, 12 insertions(+), 34 deletions(-) diff --git a/src/components/map/MapControls.js b/src/components/map/MapControls.js index 7399798..7f5bfdf 100644 --- a/src/components/map/MapControls.js +++ b/src/components/map/MapControls.js @@ -1,4 +1,4 @@ -import React, { useState, Fragment, useEffect, useRef } from "react"; +import React, { useState, Fragment, useRef } from "react"; import { IconButton, Flex, Box } from "theme-ui"; import RadioIconButton from "./controls/RadioIconButton"; @@ -178,35 +178,6 @@ function MapContols({ } } - // Stop map drawing from happening when selecting controls - // Not using react events as they seem to trigger after dom events - useEffect(() => { - function stopPropagation(e) { - e.stopPropagation(); - } - const controls = controlsRef.current; - if (controls) { - controls.addEventListener("mousedown", stopPropagation); - controls.addEventListener("touchstart", stopPropagation); - } - const settings = settingsRef.current; - if (settings) { - settings.addEventListener("mousedown", stopPropagation); - settings.addEventListener("touchstart", stopPropagation); - } - - return () => { - if (controls) { - controls.removeEventListener("mousedown", stopPropagation); - controls.removeEventListener("touchstart", stopPropagation); - } - if (settings) { - settings.removeEventListener("mousedown", stopPropagation); - settings.removeEventListener("touchstart", stopPropagation); - } - }; - }); - return ( <>