diff options
author | Thedro Neely <thedroneely@gmail.com> | 2022-11-14 04:50:21 -0500 |
---|---|---|
committer | Thedro Neely <thedroneely@gmail.com> | 2022-11-14 04:50:21 -0500 |
commit | 2328e44d2e34c6c906be16f5421b152c49e0f266 (patch) | |
tree | 997dee3ca2a018e30fdf0dad2a6e50e31f2c5e7a /public | |
parent | 85ad961667853ee2729324a2013dd0b4400b7f3b (diff) | |
download | thedroneely.com-2328e44d2e34c6c906be16f5421b152c49e0f266.tar.gz thedroneely.com-2328e44d2e34c6c906be16f5421b152c49e0f266.tar.bz2 thedroneely.com-2328e44d2e34c6c906be16f5421b152c49e0f266.zip |
public/js/app: Scroll into view on fragment change
Diffstat (limited to 'public')
-rw-r--r-- | public/js/app.js | 7 |
1 files 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 |