Changed map interaction to ignore events not on the canvas
This removes the need for calling prevent interaction all over the code also allowed pointer events to go through the empty parts of the dice tray
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
import React, { useEffect, useState, useContext } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import Modal from "react-modal";
|
||||
import { useThemeUI } from "theme-ui";
|
||||
|
||||
import MapInteractionContext from "../../contexts/MapInteractionContext";
|
||||
|
||||
import usePrevious from "../../helpers/usePrevious";
|
||||
|
||||
function MapMenu({
|
||||
isOpen,
|
||||
onRequestClose,
|
||||
@@ -24,17 +20,6 @@ function MapMenu({
|
||||
// callback
|
||||
const [modalContentNode, setModalContentNode] = useState(null);
|
||||
|
||||
// Toggle map interaction when menu is opened
|
||||
const wasOpen = usePrevious(isOpen);
|
||||
const { setPreventMapInteraction } = useContext(MapInteractionContext);
|
||||
useEffect(() => {
|
||||
if (isOpen && !wasOpen) {
|
||||
setPreventMapInteraction(true);
|
||||
} else if (wasOpen && !isOpen) {
|
||||
setPreventMapInteraction(false);
|
||||
}
|
||||
}, [isOpen, setPreventMapInteraction, wasOpen]);
|
||||
|
||||
useEffect(() => {
|
||||
// Close modal if interacting with any other element
|
||||
function handlePointerDown(event) {
|
||||
|
||||
Reference in New Issue
Block a user