Scroll direction
Simple library for detecting the scroll vertical direction.
- Provides a custom event
scrollDirectionChange
- Automatically adds classes to an element based on the direction
scroll-direction-up
orscroll-direction-down
.
// YOU CAN PROVIDE AN OPTIONS OBJECTconst options = target : document addClasses : false;options; // OR JUST NOTHING// INITIALIZE AN INSTANCE; // YOU CAN NOW ACCESS THE CUSTOM EVENT FOR THE PROVIDED ELEMENTwindow;
Options
target
Type : Element
Default : window
addClasses
Type : String
or Falsy value Boolean
Default : body
By default scroll-direction-up
and scroll-direction-down
will be added to the class list of the body. You can provide a different selector or a falsy value like ''
or just false
.