diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-10-21 00:38:27 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-10-21 00:38:27 +0200 |
commit | a86be7a48f8aaf4113724ed00035e8d248969cbb (patch) | |
tree | 9866749be216f5c278c82ce49100a15e81baefdf | |
parent | da620aa17fa8b0c50d6a64b7fe6ba76863d5cef1 (diff) | |
download | richard-iii-a86be7a48f8aaf4113724ed00035e8d248969cbb.tar.gz |
Only auto-scroll on mobile.
-rw-r--r-- | play.js | 11 |
1 files changed, 7 insertions, 4 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" }) +} + const LANCASTER = "Lancaster" const YORK = "York" const ENEMY = { York: "Lancaster", Lancaster: "York" } @@ -817,10 +823,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 { |