Are there any alternatives to the jQuery endless scrolling plugin?
http://www.beyondcoding.com/2009/01/15/release-jquery-plugin-endless-scroll/
This should do the same trick without plugin
$(window).scroll(function () {
if ($(window).scrollTop() >= $(document).height() - $(window).height() - 100) {
//Add something at the end of the page
}
});
According to @pere's comment, it's better to use the code below to avoid excessive amount of event firing.
Inspired from this answer https://stackoverflow.com/a/13298018/153723
var scrollListener = function () {
$(window).one("scroll", function () { //unbinds itself every time it fires
if ($(window).scrollTop() >= $(document).height() - $(window).height() - 100) {
//Add something at the end of the page
}
setTimeout(scrollListener, 200); //rebinds itself after 200ms
});
};
$(document).ready(function () {
scrollListener();
});