Skip to content

Commit

Permalink
Make sure page nav shows when scrolling past bottom of page
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsherman committed Dec 5, 2024
1 parent 31faf9b commit 6110274
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ function hookupPageNavAutoHide() {
let lastScrollY = globalThis.scrollY;

globalThis.addEventListener('scroll', () => {
const currentScrollY = globalThis.scrollY;
const maxScrollY =
document.documentElement.scrollHeight - globalThis.innerHeight;
const currentScrollY = Math.min(globalThis.scrollY, maxScrollY);

const isScrollingDown =
currentScrollY > scrollThreshold && currentScrollY > lastScrollY;
currentScrollY > scrollThreshold && currentScrollY >= lastScrollY;

if (isScrollingDown) {
header?.classList.add('hidden');
Expand Down

0 comments on commit 6110274

Please sign in to comment.