From f15dbf51690caf5a9428fd106942695870906883 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 23 Oct 2023 02:31:10 +0200 Subject: Delay scrollIntoView by using timer, to prevent event handler from interfering. This is needed on Chrome when the scrollIntoView is triggered from certain events, otherwise the event processing will interrupt and stop the scrolling. --- public/common/client.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/public/common/client.js b/public/common/client.js index 417efb2..ef6e6df 100644 --- a/public/common/client.js +++ b/public/common/client.js @@ -39,15 +39,20 @@ let snap_view = null function scroll_into_view(e) { if (window.innerWidth <= 800) document.querySelector("aside").classList.add("hide") - e.scrollIntoView({ block: "center", inline: "center", behavior: "smooth" }) + setTimeout(function () { + e.scrollIntoView({ block: "center", inline: "center", behavior: "smooth" }) + }, 0) } function scroll_into_view_if_needed(e) { if (window.innerWidth <= 800) { - // TODO: close log on mobile? - e.scrollIntoView({ block: "start", inline: "center", behavior: "smooth" }) + setTimeout(function () { + e.scrollIntoView({ block: "start", inline: "center", behavior: "smooth" }) + }, 0) } else { - e.scrollIntoView({ block: "nearest", inline: "nearest", behavior: "smooth" }) + setTimeout(function () { + e.scrollIntoView({ block: "nearest", inline: "nearest", behavior: "smooth" }) + }, 0) } } @@ -1302,6 +1307,7 @@ var update_layout = function () {} function (evt) { if (evt.ctrlKey) { disable_map_fit() + anchor_transform(evt.touches) let win_w = e_scroll.clientWidth let win_h = e_scroll.clientHeight -- cgit v1.2.3