jQuery.event.special.scrolltop
The scrolltop event is raised when scrolling near the top of the window or scrollable container element.
This is commonly useful for enabling endless scrolling interfaces.
Usage
// handle the 'scrolltop' event on an entire document
$(document).on('scrolltop', function() {
// handle event
});
// handle the 'scrolltop' event of a vertically-overflowing div
$('#SomeOverflowingDiv').on('scrollend', function() {
// handle event
});
// handle the 'scrolltop' event on an entire document with custom parameters
$(document).on('scrolltop', {
padding: 150, // distance from the top at which 'scrolltop' is raised
delay: 250 // frequency to check scroll position during a scroll
}, function() {
// handle event
});
Tip: When performing an asynchronous request on a scrolltop
or scrollend
event, a flag should be set to block subsequent requests until the current request is complete.