jquery.fn.scrollx
v1.0.13
Published
add scroll[up|down|left|right] to jQuery.prototype
Downloads
27
Maintainers
Readme
Add scrollup / scrolldown / scrollleft / scrollright
to jQuery.prototype
(debounce integrated)
§ Demo
§ Installation
⊙ npm
npm i -S jquery.fn.scrollx
⊙ CDN
<script src="//unpkg.com/jquery.fn.scrollx"></script>
§ Usage
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 requiredperiod
(defaults to 100
ms) and unlistenerReceiver
are optional
e.g.
$('#foo').scrolldown(listener)
$('#foo').scrollleft(listener, 300)
$('#foo').scrollright(listener, unlistenerReceiver)
§ Reference
- https://stackoverflow.com/a/7076832/5172890
- https://stackoverflow.com/a/4326907/5172890