In this example you can see how to use the plugin to obtain an infinite scroll.
The first thing to do is to initialize the gallery as usually.
$('#gallery').justifiedGallery({rowHeight:120});Then you need to initialize the infinite scroll as you want. But is necessary to implement its finish callback to recall Justified Gallery again. For example:
$(window).scroll(function() { if($(window).scrollTop() + $(window).height() == $(document).height()) { for (var i = 0; i < 5; i++) { $('#gallery').append('<a class="item">' + '<img src="http://path/to/image" />' + '</a>'); } $('#gallery').justifiedGallery('norewind'); //callback } });You can notice that we call Justified Gallery using the special parameter
'norewind'
. In this way the plugin doesn't re-analyzes all the images, but only the new ones. This parameter increases the performance, and also prevents the page to have strange behaviours with the scrollbars.