Skip to content

Instantly share code, notes, and snippets.

@ericclemmons
Created September 10, 2009 20:59
Show Gist options
  • Save ericclemmons/184821 to your computer and use it in GitHub Desktop.
Save ericclemmons/184821 to your computer and use it in GitHub Desktop.
Run this script on FMyLife.com for endless scroll
(function($) {
$.extend($.expr[':'],{
inView: function(a) {
var st = (document.documentElement.scrollTop || document.body.scrollTop),
ot = $(a).offset().top,
wh = (window.innerHeight && window.innerHeight < $(window).height()) ? window.innerHeight : $(window).height();
return ot > st && ($(a).height() + ot) < (st + wh);
}
});
var element = ".pagination";
var check = function() {
if ($(element).is(':inView')) {
var path = "#wrapper";
var next = jQuery('.pagination a').filter('[innerHTML~=Next]');
var url = next.attr('href') + " " + path;
$(element).empty().load(url).removeClass('pagination');
}
};
$(window).scroll(check);
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment