Skip to content

Instantly share code, notes, and snippets.

@p3drosola
Created April 12, 2012 16:12
Show Gist options
  • Save p3drosola/2368723 to your computer and use it in GitHub Desktop.
Save p3drosola/2368723 to your computer and use it in GitHub Desktop.
Piccsy infinite scroll
// requires Infinite Scroll plugin by Paul Irish
// https://github.com/paulirish/infinite-scroll/blob/master/jquery.infinitescroll.min.js
$(function() {
if ($('#leftColumn').length > 0){
var $ci = $('<div id="container-inner"></div>').prependTo('#container');
$('#header, #fbFloat, #wrapper, #leftColumn, #rightColumn').detach().appendTo($ci);
$ci.infinitescroll({
navSelector: "#pager",
nextSelector: "#pager li:nth-child(2) a",
itemSelector: ".image",
loadingText: "Loading more images..."
}, function (elements) {
var $left = $('#leftColumn'),
$center = $('#centerColumn'),
$right = $('#rightColumn');
$(elements).each(function () {
var $spacer = $('<div>').addClass('spacer'),
$col = ($left.outerHeight() < $center.outerHeight()) ? $left : $center;
$col = ($right.outerHeight() < $col.outerHeight()) ? $right : $col;
$(this).detach().appendTo($col).after($spacer);
});
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment