Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/onewaytech/jquery.fn.scrollx
Add scrollup / scrolldown / scrollleft / scrollright to jQuery.prototype (debounce integrated)
https://github.com/onewaytech/jquery.fn.scrollx
debounce jquery plugin scroll scrolldown scrollleft scrollright scrollup
Last synced: 25 days ago
JSON representation
Add scrollup / scrolldown / scrollleft / scrollright to jQuery.prototype (debounce integrated)
- Host: GitHub
- URL: https://github.com/onewaytech/jquery.fn.scrollx
- Owner: OneWayTech
- Created: 2017-11-27T10:34:25.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-04T06:18:35.000Z (almost 7 years ago)
- Last Synced: 2024-10-14T22:20:11.526Z (25 days ago)
- Topics: debounce, jquery, plugin, scroll, scrolldown, scrollleft, scrollright, scrollup
- Language: HTML
- Homepage:
- Size: 18.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Add `scrollup / scrolldown / scrollleft / scrollright` to `jQuery.prototype` (debounce integrated)
[![npm version][npm-v-img]][npm-url]
[![npm download][npm-dl-img]][npm-url]
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)## § Demo
[Demo](https://onewaytech.github.io/jquery.fn.scrollx/test.html) ([source code of demo](https://github.com/onewaytech/jquery.fn.scrollx/blob/master/test.html))## § Installation
### ⊙ npm
`npm i -S jquery.fn.scrollx`### ⊙ CDN
```html```
## § Usage
```js
import $ from 'jquery'
require('jquery.fn.scrollx')($)const period = 200 // for debounce
const listener = (delta, currentOffset, lastOffset) => { ... }
let unlistener
const unlistenerReceiver = f => { unlistener = f }$('#foo').scrollup(listener, period, unlistenerReceiver)
$('#bar').on('click', unlistener)
```
`listener` is required
`period` (defaults to `100` ms) and `unlistenerReceiver` are optionale.g.
```js
$('#foo').scrolldown(listener)
$('#foo').scrollleft(listener, 300)
$('#foo').scrollright(listener, unlistenerReceiver)
```## § Reference
* https://stackoverflow.com/a/7076832/5172890
* https://stackoverflow.com/a/4326907/5172890[npm-url]: https://www.npmjs.com/package/jquery.fn.scrollx
[npm-v-img]: http://img.shields.io/npm/v/jquery.fn.scrollx.svg
[npm-dl-img]: http://img.shields.io/npm/dm/jquery.fn.scrollx.svg