From a86be7a48f8aaf4113724ed00035e8d248969cbb Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 21 Oct 2023 00:38:27 +0200 Subject: Only auto-scroll on mobile. --- play.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/play.js b/play.js index 2793dad..ca2e644 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" }) +} + 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 { -- cgit v1.2.3