From 6b051499a15b71b19634bf6fcaf3686e980de953 Mon Sep 17 00:00:00 2001 From: Theo Sanderson Date: Wed, 15 Feb 2023 17:38:34 +0000 Subject: [PATCH] fix --- src/App.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/App.js b/src/App.js index c10d594..9afd775 100644 --- a/src/App.js +++ b/src/App.js @@ -44,10 +44,17 @@ const useQueryState = query => { const Tooltip = ({ hoveredInfo }) => { const [tooltipPosition, setTooltipPosition] = useState({ x: 0, y: 0 }); + // position to right of mouse unless x is too close to right edge + const left_or_right = tooltipPosition.x > window.innerWidth - 200 ? { + right: `${window.innerWidth - tooltipPosition.x + 10}px`, + } : { + left: `${tooltipPosition.x + 10}px`, + }; + const tooltipStyles = { position: "absolute", - top: `${tooltipPosition.y + 20}px`, - left: `${tooltipPosition.x + 0}px`, + top: `${tooltipPosition.y + 10}px`, + ...left_or_right, visibility: hoveredInfo ? "visible" : "hidden", zIndex: 1000,