From 502339d90b2dcec59ac78bf86ab95de5794b0543 Mon Sep 17 00:00:00 2001 From: H4CK3R-01 Date: Thu, 10 Jun 2021 11:27:51 +0200 Subject: [PATCH] Fixed scale problem --- public/js/game.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/public/js/game.js b/public/js/game.js index 5c79357..d46caa8 100644 --- a/public/js/game.js +++ b/public/js/game.js @@ -197,10 +197,24 @@ function generate_circle(graphics, x, y) { } function calculate_size() { - if (game.offsetWidth > game.offsetHeight) { - return game.offsetHeight; + let width; + let height; + if (game.offsetWidth > window.innerWidth) { + width = window.innerWidth - document.getElementById('chat').offsetWidth; } else { - return game.offsetWidth; + width = game.offsetWidth; + } + + if (game.offsetHeight > window.innerHeight) { + height = window.innerHeight - document.getElementsByTagName('header')[0].offsetHeight; + } else { + height = game.offsetHeight; + } + + if (width > height) { + return height; + } else { + return width; } }