Skip to content

Instantly share code, notes, and snippets.

@desbest
Last active May 6, 2018 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save desbest/f75cf33c64ef5cb1575c to your computer and use it in GitHub Desktop.
Save desbest/f75cf33c64ef5cb1575c to your computer and use it in GitHub Desktop.
Auto Pagination
////////javascript libraries used
//// jquery
//// scrollPagination
//// aeImageResize
//// masonry
var offset = 0;
$('#stuffhere').scrollPagination({
'contentPage': 'themes/[var.theme]/ajaxcontrols.php?page=products&offset='+offset, // the page where you are searching for results
'contentData': {}, // you can pass the children().size() to know where is the pagination
'scrollTarget': $(window), // who gonna scroll? in this example, the full window
'heightOffset': 40, // how many pixels before reaching end of the page would loading start? positives numbers only please
'beforeLoad': function(){ // before load, some function, maybe display a preloader div
$('#loading').fadeIn();
},
'afterLoad': function(elementsLoaded, offset){ // after loading, some function to animate results and hide a preloader div
$('#loading').fadeOut();
//var offset = offset + [var.homelist];
$('.statrow').append(elementsLoaded).masonry('appended', elementsLoaded, true ); //masonry plugin
$( ".polaroid img" ).aeImageResize({ height: 200, width: 180 }); //imageresize plugin
//$(elementsLoaded).fadeInWithDelay();
if ($('#stuffhere').children().size() > [var.maxpages] * [var.homelist]){ // when stop stop loading pagination
//$('#nomoreresults').fadeIn();
$('#stuffhere').stopScrollPagination();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment