So how do I add or integrate infinite scrolling with my masonry fluid layout? I have already googled but don't understand.Here is what I got so far:
/**
* Base js functions
*/
$(document).ready(function(){
var $container = $('.container');
var gutter = 20;
var min_width = 270;
$container.imagesLoaded( function(){
$container.masonry({
itemSelector : '.box',
gutterWidth: gutter,
isAnimated: true,
columnWidth: function( containerWidth ) {
var box_width = (((containerWidth - 2*gutter)/3) | 0) ;
if (box_width < min_width) {
box_width = (((containerWidth - gutter)/2) | 0);
}
if (box_width < min_width) {
box_width = containerWidth;
}
$('.box').width(box_width);
return box_width;
}
});
});
});
Can someone help? Thank you so much!
If you check out the source code for the infinite scroll example on the masonry site you can see the function that does all the work after the initial Masonry setup. After your $container.imagesLoaded function, add in the Infinite Scroll configs and then trigger Masonry in a callback function. Also, be sure to include jquery.infinitescroll.min.js after jquery.masonry.min.js.
Here's the JS from that page:
});