So I have a Packery grid, looking to shuffle items so that they perfectly organize at least to the height of the container...if the width is off, that's fine.
Looking at a layout like this:
<div class="grid">
<div class="grid-item grid-sizer"><img src="http://placehold.it/350x150" border="0" class="img-responsive" /></div>
<div class="grid-item"><img src="http://placehold.it/150x150" border="0" class="img-responsive" /></div>
<div class="grid-item grid-item--width2"><img src="http://placehold.it/700x250" border="0" class="img-responsive" /></div>
<div class="grid-item grid-item--width2"><img src="http://placehold.it/700x200" border="0" class="img-responsive" /></div>
<div class="grid-item"><img src="http://placehold.it/350x150" border="0" class="img-responsive" /></div>
<div class="grid-item"><img src="http://placehold.it/350x150" border="0" class="img-responsive" /></div>
<div class="grid-item"><img src="http://placehold.it/350x150" border="0" class="img-responsive" /></div>
<div class="grid-item grid-item--width2"><img src="http://placehold.it/700x200" border="0" class="img-responsive" /></div>
<div class="grid-item grid-item--width2"><img src="http://placehold.it/700x200" border="0" class="img-responsive" /></div>
<div class="grid-item"><img src="http://placehold.it/350x150" border="0" class="img-responsive" /></div>
<div class="grid-item"><img src="http://placehold.it/150x150" border="0" class="img-responsive" /></div>
<div class="grid-item"><img src="http://placehold.it/350x150" border="0" class="img-responsive" /></div>
<div class="grid-item"><img src="http://placehold.it/350x150" border="0" class="img-responsive" /></div>
</div>
Some general styling:
.grid-sizer, .grid-item{
width: 20%;
float: left;
img{
width: 100%;
height: auto;
}
}
.grid-item--width2{
width: 40%;
}
Lastly, the initiator:
var $grid = $('.grid').imagesLoaded( function() {
$grid.packery({
columnWidth: '.grid-sizer',
itemSelector: '.grid-item',
gutter: 0,
precentPosition: true
});
});
So I've decided that without some additional jquery which I can write later if I want, there is going to have to be specs on uploads. It's impossible to avoid the gappage without it, if someone wants to blow my mind and show me, without using a stack of jQuery which I know it can be done then.
However, the shuffle, I did write up a piece, and then packery it back up, actually ends up doing pretty darn well most the time...still get some gaps until I standardize my specs though.