From e1733bb504281424397cedc6ba88f6ad9cb021f8 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Fri, 31 Jul 2020 14:50:01 +1000 Subject: [PATCH] Change token fade hover to only be on drawing --- src/components/map/Map.js | 1 + src/components/map/MapToken.js | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/map/Map.js b/src/components/map/Map.js index 553bfdf..f6cba4f 100644 --- a/src/components/map/Map.js +++ b/src/components/map/Map.js @@ -241,6 +241,7 @@ function Map({ selectedToolId === "pan" && !(tokenState.id in disabledTokens) } mapState={mapState} + fadeOnHover={selectedToolId === "drawing"} /> ))} diff --git a/src/components/map/MapToken.js b/src/components/map/MapToken.js index d47f90b..54bd867 100644 --- a/src/components/map/MapToken.js +++ b/src/components/map/MapToken.js @@ -25,6 +25,7 @@ function MapToken({ onTokenDragEnd, draggable, mapState, + fadeOnHover, }) { const { userId } = useContext(AuthContext); const { @@ -127,13 +128,13 @@ function MapToken({ } } - function handlePointerOver() { - if (!draggable) { + function handlePointerEnter() { + if (fadeOnHover) { setTokenOpacity(0.5); } } - function handlePointerOut() { + function handlePointerLeave() { if (tokenOpacity !== 1.0) { setTokenOpacity(1.0); } @@ -183,8 +184,8 @@ function MapToken({ draggable={draggable} onMouseDown={handlePointerDown} onMouseUp={handlePointerUp} - onMouseOver={handlePointerOver} - onMouseOut={handlePointerOut} + onMouseEnter={handlePointerEnter} + onMouseLeave={handlePointerLeave} onTouchStart={handlePointerDown} onTouchEnd={handlePointerUp} onClick={handleClick}