DEV Community

Cover image for Peek.js: Auto-Hide Header Nav on Scroll Direction
jQueryScript
jQueryScript

Posted on

Peek.js: Auto-Hide Header Nav on Scroll Direction

Peek.js — a lightweight JavaScript library that hides your fixed header when users scroll down and reveals it when they scroll up.

Key highlights:

  • Zero dependencies, single JS file
  • requestAnimationFrame-based updates for smooth performance
  • Passive scroll listeners for better main-thread efficiency
  • Configurable offset, tolerance, and CSS class names
  • Includes a destroy() method for clean teardown (great for mobile-only patterns)
  • Works with any framework or vanilla JS setup

👉 Blog Post

👉 GitHub Repo

👉 Live Demo

Top comments (0)