diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-10-21 00:37:57 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-10-21 00:37:57 +0200 |
commit | 8cf3428c0f7378124cb0a7092e0b554608b5fed1 (patch) | |
tree | 3c60a6f5c5c132e618f73eecfc7605e15f8b660e /play.js | |
parent | caa2c274ba4a361cdc04fa9115cdbe140d3c362b (diff) | |
download | hammer-of-the-scots-8cf3428c0f7378124cb0a7092e0b554608b5fed1.tar.gz |
Only auto-scroll on mobile.
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -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 @@ -768,9 +774,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 { |