diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-12-09 17:05:00 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-12-10 18:06:33 +0100 |
commit | 277fdc3dc71de71d1996586b5f0b56bee1c60bf1 (patch) | |
tree | ab31f1ec40c0d991fc3905938ab2c59920b4cdc5 | |
parent | 9af6fc6e93d59e72da2d80eb63b3a9a9ce445fb8 (diff) | |
download | server-277fdc3dc71de71d1996586b5f0b56bee1c60bf1.tar.gz |
Update map size dynamically (if it changes during play).
-rw-r--r-- | public/common/client.js | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/public/common/client.js b/public/common/client.js index 33b9147..ae0f0b8 100644 --- a/public/common/client.js +++ b/public/common/client.js @@ -961,13 +961,20 @@ var update_zoom = function () {} } const map = document.getElementById("map") || e_inner.querySelector("div") - var map_w = mapwrap ? mapwrap.clientWidth : map.clientWidth - var map_h = mapwrap ? mapwrap.clientHeight : map.clientHeight + var map_w = 1920 + var map_h = 1080 + + function update_map_size() { + map_w = mapwrap ? mapwrap.clientWidth : map.clientWidth + map_h = mapwrap ? mapwrap.clientHeight : map.clientHeight + if (e_scroll.dataset.mapHeight) + map_h = Number(e_scroll.dataset.mapHeight) + if (e_scroll.dataset.mapWidth) + map_w = Number(e_scroll.dataset.mapWidth) + console.log("UPDATE MAP SIZE", map_w, map_h) + } - if (e_scroll.dataset.mapHeight) - map_h = Number(e_scroll.dataset.mapHeight) - if (e_scroll.dataset.mapWidth) - map_w = Number(e_scroll.dataset.mapWidth) + update_map_size() console.log("INIT MAP", map, map_w, map_h, window.devicePixelRatio) @@ -1031,6 +1038,8 @@ var update_zoom = function () {} // export function toggle_zoom = function () { + update_map_size() + if (transform1.scale === 1) { if (mapwrap && window.innerWidth > 800) { cycle_map_fit() @@ -1050,6 +1059,7 @@ var update_zoom = function () {} // export function update_zoom = function () { + update_map_size() update_map_fit() update_transform_on_resize() scroll_log_to_end() |