Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ericrallen/js-scroll-checker
A simple JS scroll-checker that allows for user-defined scroll_stop and scroll_start callbacks.
https://github.com/ericrallen/js-scroll-checker
Last synced: 5 days ago
JSON representation
A simple JS scroll-checker that allows for user-defined scroll_stop and scroll_start callbacks.
- Host: GitHub
- URL: https://github.com/ericrallen/js-scroll-checker
- Owner: ericrallen
- Created: 2013-01-11T19:15:21.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-01-11T19:35:54.000Z (almost 12 years ago)
- Last Synced: 2024-10-11T09:38:17.468Z (28 days ago)
- Size: 109 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
js-scroll-checker
=================A simple JS scroll-checker that allows for user-defined scroll_stop and scroll_start callbacks.
Use
===JSFiddle: http://jsfiddle.net/allenericr/nF5gx/
Just define the `scroll_check.on_start()` and `scroll_check.on_end()` methods and run the `scroll_check.check_scroll()` method when scrolling the window.
//public method added for callback from scroll start
scroll_check.on_start = function() {
//console.log('scroll started');
}//public method added for callback from scroll end
scroll_check.on_end = function() {
//console.log('scroll stopped');
}//on window scroll
$(window).scroll(function() {
//run the check on window scroll
scroll_check.check_scroll();
});Credits
=======The general idea for this script was borrowed from StackOverflow and modified as needed.
StackOverflow: http://stackoverflow.com/questions/3515446/jquery-mousewheel-detecting-when-the-wheel-stops#answer-3515490
It uses an implementation of the Revealing Module Pattern described at the link below (listed under Revealing Module Pattern (Public & Private)).
http://enterprisejquery.com/2010/10/how-good-c-habits-can-encourage-bad-javascript-habits-part-1/