diff options
-rw-r--r-- | play.js | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -6,6 +6,12 @@ const svgNS = "http://www.w3.org/2000/svg" const round = Math.round const sqrt = Math.sqrt +function scroll_into_view_if_mobile(e) { + // if ("ontouchstart" in window) + if (window.innerWidth <= 800) + e.scrollIntoView({ block: "center", inline: "center", behavior: "smooth" }) +} + // refit and queue hexes const MALTA = 4 const hex_special = [ 47, 48, 49, 53, 102, 127, MALTA ] @@ -938,7 +944,7 @@ function update_battle_line(hex, line, test) { function update_battle() { if (ui.battle.classList.contains("hide")) { ui.battle.classList.remove("hide") - ui.battle.scrollIntoView({ block: "center", inline: "center", behavior: "smooth" }) + scroll_into_view_if_mobile(ui.battle) } ui.battle_header.textContent = hex_name[view.battle] @@ -967,8 +973,7 @@ function update_battle() { function update_pursuit() { if (ui.pursuit.classList.contains("hide")) { ui.pursuit.classList.remove("hide") - ui.pursuit.scrollIntoView({ block: "center", inline: "center", behavior: "smooth" }) - + scroll_into_view_if_mobile(ui.pursuit) } ui.pursuit_header.textContent = "Pursuit Fire at " + hex_name[view.pursuit] ui.pursuit_message.textContent = view.flash |