summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-10-21 00:38:39 +0200
committerTor Andersson <tor@ccxvii.net>2023-10-21 00:38:39 +0200
commit3a7fcae37064b743f4c223fae9e3fc5f4bbf3dad (patch)
tree696948674ffa4413b94ce6da8337001a3db6f214
parent2cf97bc3692443c6d4e92775ed902b348200147c (diff)
downloadcrusader-rex-3a7fcae37064b743f4c223fae9e3fc5f4bbf3dad.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 f5422ed..6f05391 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
@@ -922,9 +928,7 @@ function on_update() {
start_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 {