summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--play.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/play.js b/play.js
index db11411..2a8ae7f 100644
--- a/play.js
+++ b/play.js
@@ -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