ScrollDir, short for Scroll Direction, is a 0 dependency, ~1kb micro Javascript plugin to easily leverage vertical scroll direction in CSS via a data attribute. 💪
ScrollDir is perfect for:
showing or hiding sticky elements based on scroll direction 🐥
only changing its direction attribute when scrolled a significant amount 🔥
ignoring small scroll movements that cause unwanted jitters 😎
Usage
ScrollDir will set the data-scrolldir attribute on the <html> element to up or down:
<html data-scrolldir="up"></html>
or
<html data-scrolldir="down"></html>
Now it’s easy to change styles based on the direction the user is scrolling!
This is a modular version of pwfisher's scroll-intent. If you'd like to use scrolldir with jQuery—use Scroll Intent. Scrolldir should work easily within any front-end framework so it ditches library dependencies. ~TY!