diff options
author | Tor Andersson <tor@ccxvii.net> | 2021-05-21 23:59:06 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2021-05-22 00:07:22 +0200 |
commit | 48a6712e480fe484157e753579a19d712a49f6ac (patch) | |
tree | e8b03b7224b1fadcb59f8776a8eb4f0ca04d2c5a /public | |
parent | 20d113567bfa0130c46010e9f2b0d001c2a53bbb (diff) | |
download | server-48a6712e480fe484157e753579a19d712a49f6ac.tar.gz |
Add map zoom-out button.
Diffstat (limited to 'public')
-rw-r--r-- | public/common/client.js | 25 | ||||
-rw-r--r-- | public/common/grid.css | 6 | ||||
-rw-r--r-- | public/images/magnifying-glass.svg | 1 |
3 files changed, 32 insertions, 0 deletions
diff --git a/public/common/client.js b/public/common/client.js index ea1c12b..cee9ea5 100644 --- a/public/common/client.js +++ b/public/common/client.js @@ -318,8 +318,33 @@ function toggle_chat() { show_chat(); } +function zoom_map() { + let grid = document.querySelector(".grid_center"); + let mapwrap = document.querySelector(".mapwrap"); + let map = document.querySelector(".map"); + map.style.transform = 'none'; + mapwrap.style.height = 'auto'; + if (mapwrap.classList.contains("fit")) { + let { width: ww, height: wh } = mapwrap.getBoundingClientRect(); + let { width: cw, height: ch } = map.getBoundingClientRect(); + let scale = ww / cw; + if (scale < 1) { + map.style.transform = "scale(" + scale + ")"; + mapwrap.style.height = (ch * scale) + "px"; + } + } +} + +window.addEventListener('resize', zoom_map); + +function toggle_zoom() { + document.querySelector(".mapwrap").classList.toggle('fit'); + zoom_map(); +} + function toggle_log() { document.querySelector(".grid_window").classList.toggle("hide_log"); + zoom_map(); } function show_action_button(sel, action, use_label = false) { diff --git a/public/common/grid.css b/public/common/grid.css index 95a2ee4..1ef92da 100644 --- a/public/common/grid.css +++ b/public/common/grid.css @@ -224,9 +224,15 @@ html, body, div { transform: scale(2.0) translate(0,-35px); } +.mapwrap.fit { + overflow: hidden; + max-width: 100%; +} + .map { margin: 0 auto; box-shadow: 0px 1px 10px rgba(0,0,0,0.5); + transform-origin: 0 0; } button { diff --git a/public/images/magnifying-glass.svg b/public/images/magnifying-glass.svg new file mode 100644 index 0000000..39cc33b --- /dev/null +++ b/public/images/magnifying-glass.svg @@ -0,0 +1 @@ +<svg style="height: 512px; width: 512px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><g class="" style="" transform="translate(0,0)"><path d="M333.78 20.188c-39.97 0-79.96 15.212-110.405 45.656-58.667 58.667-60.796 152.72-6.406 213.97l-15.782 15.748 13.25 13.25 15.75-15.78c61.248 54.39 155.3 52.26 213.968-6.407 60.887-60.886 60.888-159.894 0-220.78C413.713 35.4 373.753 20.187 333.78 20.187zm0 18.562c35.15 0 70.285 13.44 97.158 40.313 53.745 53.745 53.744 140.6 0 194.343-51.526 51.526-133.46 53.643-187.5 6.375l.218-.217c-2.35-2.05-4.668-4.17-6.906-6.407-2.207-2.206-4.288-4.496-6.313-6.812l-.218.22c-47.27-54.04-45.152-135.976 6.374-187.502C263.467 52.19 298.63 38.75 333.78 38.75zm0 18.813c-30.31 0-60.63 11.6-83.81 34.78-46.362 46.362-46.362 121.234 0 167.594 10.14 10.142 21.632 18.077 33.905 23.782-24.91-19.087-40.97-49.133-40.97-82.94 0-15.323 3.292-29.888 9.22-43-4.165 20.485.44 40.88 14.47 54.907 24.583 24.585 68.744 20.318 98.624-9.562 29.88-29.88 34.146-74.04 9.56-98.625-2.375-2.376-4.943-4.473-7.655-6.313 45.13 8.648 79.954 46.345 84.25 92.876 4.44-35.07-6.82-71.726-33.813-98.72-23.18-23.18-53.47-34.78-83.78-34.78zM176.907 297.688L42.094 432.5l34.562 34.563L211.47 332.25l-34.564-34.563zM40 456.813L24 472.78 37.22 486l15.968-16L40 456.812z" fill="#000" fill-opacity="1"></path></g></svg>
\ No newline at end of file |