From f98e9af1ac5498a9bd1175151e58421ae891d914 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Wed, 4 Dec 2019 11:13:41 -0500 Subject: [PATCH] Fix the building tooltip flying off the screen --- gorge.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gorge.js b/gorge.js index 10e3969..9a2ec22 100644 --- a/gorge.js +++ b/gorge.js @@ -651,7 +651,15 @@ function buildingTooltip(id, event) { let yOffset = tooltip.parentElement.getBoundingClientRect().y; let xPos = tooltip.parentElement.getBoundingClientRect().x - 450; - let yPos = event.clientY; + + // wow browsers are bad + + var body = document.body, + html = document.documentElement; + + var height = Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight ); + + let yPos = Math.min(event.clientY, height - 200); tooltip.style.setProperty("transform", "translate(" + xPos + "px, " + yPos + "px)") }