I'm using Paul Irish's Infinite-Scroll jQuery plugin in combination with Isotope. It seems to be working well except for one thing: the loading animation doesn't appear at all. Also, when you scroll down, the original pagination links are visible for a second, then they disappear, and a second or so later the next 'page' loads. Since it takes a second for the second 'page' to load, I would really like the loading animation to appear so that the user knows another page is loading. How can I force the pagination links to be invisible and the loading animation to appear? Below is the code I'm using:
// Isotope (with Infinite Scroll)
$(function(){
var $container = $('.isotope-container');
$container.imagesLoaded(function(){
$container.masonry({
itemSelector: '.isotope-item',
layoutMode: 'masonry'
});
});
// filter items on button click
$('#filters').on( 'click', 'button', function() {
var selector = $(this).attr('data-filter');
$container.isotope({ filter: selector });
});
$container.infinitescroll({
navSelector : '.pagination', // selector for the paged navigation
nextSelector : '.next-post a', // selector for the NEXT link (to page 2)
itemSelector : '.isotope-item', // selector for all items you'll retrieve
loading: {
finishedMsg: 'No more pages to load.',
msgText: "loading new posts",
img: 'http://i.imgur.com/6RMhx.gif',
selector: "#loading-animation"
}
},
// trigger Masonry as a callback
function( newElements ) {
// hide new items while they are loading
var $newElems = $( newElements ).css({ opacity: 0 });
// ensure that images load before adding to masonry layout
$newElems.imagesLoaded(function(){
// show elems now they're ready
$newElems.animate({ opacity: 1 });
$container.masonry( 'appended', $newElems, true );
});
}
);
});
EDIT: Upon inspecting the page, it looks like the loading div #infscr-loading
is loading at the top of the page beneath the other elements. But I can't figure out how to get it to load at the bottom...