summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-10-21 00:38:14 +0200
committerTor Andersson <tor@ccxvii.net>2023-10-21 00:38:14 +0200
commit3c444f575e95c25e977aa49675c2f7c127b5eb87 (patch)
tree515f264b0766955bade4fc13937390f9f46dc6a0
parent395aed07b08dfda92b599c14f9e7b39efa380725 (diff)
downloadjulius-caesar-3c444f575e95c25e977aa49675c2f7c127b5eb87.tar.gz
Only auto-scroll on mobile.
-rw-r--r--play.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/play.js b/play.js
index 1b8e3ab..0fedce8 100644
--- a/play.js
+++ b/play.js
@@ -1,5 +1,11 @@
"use strict"
+function scroll_into_view_if_mobile(e) {
+ // if ("ontouchstart" in window)
+ if (window.innerWidth <= 800)
+ e.scrollIntoView({ block: "center", inline: "center", behavior: "smooth" })
+}
+
function set_has(set, item) {
let a = 0
let b = set.length - 1
@@ -799,9 +805,7 @@ function on_update() {
document.getElementById("battle_message").textContent = view.battle.flash
if (!document.getElementById("battle").classList.contains("show")) {
document.getElementById("battle").classList.add("show")
- document.getElementById("battle").scrollIntoView({
- block:"center", inline:"center", behavior:"smooth"
- })
+ scroll_into_view_if_mobile(document.getElementById("battle"))
}
update_battle()
} else {