diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-10-21 13:58:16 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-10-21 19:41:47 +0200 |
commit | b4f7bf127186660f3026aab9befba80686e781d8 (patch) | |
tree | 9317e0afba2cf13a3d9c99cf61e87d501c74ddd7 | |
parent | 3e64f888c60975f40cb7b2e2cd60e29da2d3fb19 (diff) | |
download | server-b4f7bf127186660f3026aab9befba80686e781d8.tar.gz |
Common scroll_into_view and scroll_into_view_if_mobile functions.
-rw-r--r-- | public/common/client.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/public/common/client.js b/public/common/client.js index 6dd38f2..13b0871 100644 --- a/public/common/client.js +++ b/public/common/client.js @@ -36,6 +36,17 @@ let snap_count = 0 let snap_this = 0 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" }) +} + +function scroll_into_view_if_mobile(e) { + if (window.innerWidth <= 800) + scroll_into_view(e) +} + function scroll_with_middle_mouse(panel_sel, multiplier) { let panel = document.querySelector(panel_sel) let down_x, down_y, scroll_x, scroll_y |