diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-10-23 02:31:10 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-10-27 01:42:01 +0200 |
commit | f15dbf51690caf5a9428fd106942695870906883 (patch) | |
tree | 2ce567f389b6fa41729cb76dac807181f3e97cc8 /public | |
parent | ee723adbff2ef0968e95817e2bbe352e42ad9e84 (diff) | |
download | server-f15dbf51690caf5a9428fd106942695870906883.tar.gz |
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.
Diffstat (limited to 'public')
-rw-r--r-- | public/common/client.js | 14 |
1 files 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 |