summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-10-21 13:58:16 +0200
committerTor Andersson <tor@ccxvii.net>2023-10-21 19:41:47 +0200
commitb4f7bf127186660f3026aab9befba80686e781d8 (patch)
tree9317e0afba2cf13a3d9c99cf61e87d501c74ddd7
parent3e64f888c60975f40cb7b2e2cd60e29da2d3fb19 (diff)
downloadserver-b4f7bf127186660f3026aab9befba80686e781d8.tar.gz
Common scroll_into_view and scroll_into_view_if_mobile functions.
-rw-r--r--public/common/client.js11
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