Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ryanburnette/scroll-direction
Gracefully detect scroll direction.
https://github.com/ryanburnette/scroll-direction
Last synced: 17 days ago
JSON representation
Gracefully detect scroll direction.
- Host: GitHub
- URL: https://github.com/ryanburnette/scroll-direction
- Owner: ryanburnette
- License: isc
- Created: 2018-09-27T15:12:16.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-14T19:30:52.000Z (over 6 years ago)
- Last Synced: 2025-01-16T13:20:41.939Z (21 days ago)
- Language: JavaScript
- Homepage:
- Size: 47.9 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# Scroll Direction
[![npm version](https://badge.fury.io/js/%40ryanburnette%2Fscroll-direction.svg)](https://badge.fury.io/js/%40ryanburnette%2Fscroll-direction)
This library is my approach to gracefully detecting vertical scroll direction
in a browser. It works by keeping track of a series of throttled detect events,
then invoking a callback with a direction argument once the series contains
only one event direction.## Usage
```javascript
var s = new ScrollDirection(function (dir) {
console.log(dir)
})
```### Options
There are two options, series and throttle. Tweak the options to get the
desired behavior.```javascript
var options = {
series: 5,
throttle: 100
}
new ScrollDirection(callback,options)
```### Destroy
```javascript
s.destroy()
```## Installation
As a library consumed and packaged by something like Webpack or Rollup.
```
npm install @ryanburnette/scroll-direction
``````javascript
var ScrollDirection = require('@ryanburnette/scroll-direction')
```From a CDN.
```
```