From 2328e44d2e34c6c906be16f5421b152c49e0f266 Mon Sep 17 00:00:00 2001 From: Thedro Neely Date: Mon, 14 Nov 2022 04:50:21 -0500 Subject: public/js/app: Scroll into view on fragment change --- public/js/app.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index 33b4866..898c416 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -87,20 +87,21 @@ window.addEventListener('scroll', function() { settings['pager'][url] = currentPosition; localStorage['settings'] = JSON.stringify(settings); - if (scrolls > 3) { - if (velocity > 75 || currentPosition < navbarHeight) { + if ((scrolls > 3 && velocity > 75) || currentPosition < navbarHeight) { remClass(navbar, 'hide'); } else if (velocity < -25) { addClass(navbar, 'hide'); } else if (currentPosition > navbarHeight) { runOnce(function () { addClass(navbar, 'hide'); }); } - } previousPosition = currentPosition; scrolls++; }); +window.addEventListener("hashchange", function () { + document.getElementById(location.hash.slice(1)).scrollIntoView(); +}); /** * Medium Zoom 1.0.4 -- cgit v1.2.3