From b4f7bf127186660f3026aab9befba80686e781d8 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 21 Oct 2023 13:58:16 +0200 Subject: Common scroll_into_view and scroll_into_view_if_mobile functions. --- public/common/client.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'public') 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 -- cgit v1.2.3