From 1e69486ae5e741303a1c3e14b3fe57b08e0d74c4 Mon Sep 17 00:00:00 2001 From: Andrew Simonson Date: Sun, 28 Jul 2024 15:12:55 -0500 Subject: [PATCH] separate hashchange, goto events --- src/static/js/responsive.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/static/js/responsive.js b/src/static/js/responsive.js index a4d5b1d..2202f76 100644 --- a/src/static/js/responsive.js +++ b/src/static/js/responsive.js @@ -19,8 +19,11 @@ async function goto(location, { push = true } = {}) { mode: "cors", }); const response = await a.json(); - if (!location.includes("#")) { + if (!window.location.href.includes("#")) { window.scrollTo({top: 0, left: 0, behavior:"instant"}); + } else { + eid = decodeURIComponent(window.location.hash.substring(1)) + document.getElementById(eid).scrollIntoView() } const metadata = response[0]; const content = response[1]; @@ -37,6 +40,6 @@ async function goto(location, { push = true } = {}) { } function backButton() { - const location = window.location.href; + const location = window.location.pathname; goto(location.substring(1), { push: false }); // remove slash, goto already does that }