summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-10-21 00:35:41 +0200
committerTor Andersson <tor@ccxvii.net>2023-10-21 00:35:41 +0200
commit36314e6391ca282712615e4a54a9fe31eae03236 (patch)
treecd4502044354361b8cf3580d2f83a02f0fadb556
parentd0761c05a44c293a4f91e8a53bd2023563f45f09 (diff)
downloadrommel-in-the-desert-36314e6391ca282712615e4a54a9fe31eae03236.tar.gz
Only scroll to battle dialog if screen is small.
-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