Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created September 30, 2013 14:16
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 billerickson/6764477 to your computer and use it in GitHub Desktop.
Save billerickson/6764477 to your computer and use it in GitHub Desktop.
jQuery(document).ready(function($) {
var $container = $('.content');
$container.masonry({
// options
itemSelector : '.entry',
});
$container.infinitescroll({
navSelector : '.navigation', // selector for the paged navigation
nextSelector : '.navigation a', // selector for the NEXT link (to page 2)
itemSelector : '.entry', // selector for all items you'll retrieve
loading: {
finishedMsg: 'No more pages to load.',
img: 'http://i.imgur.com/6RMhx.gif'
}
},
// 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 );
});
}
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment