Browse Source

tests : better centered masonry logic

See also desandro/masonry@419606255
pull/96/head
David DeSandro 13 years ago
parent
commit
7ac8b758a7
  1. 21
      _posts/tests/2011-05-18-centered-masonry.html

21
_posts/tests/2011-05-18-centered-masonry.html

@ -85,18 +85,21 @@ category: tests
};
$.Isotope.prototype._masonryGetContainerSize = function() {
var itemsTotalWidth = 0;
this.$filteredAtoms.each(function(){
itemsTotalWidth += $(this).outerWidth(true);
});
var unusedCols = 0,
i = this.masonry.cols;
// count unused columns
while ( --i ) {
if ( this.masonry.colYs[i] !== 0 ) {
break;
}
unusedCols++;
}
var layoutWidth = this.masonry.cols * this.masonry.columnWidth,
size = {
return {
height : Math.max.apply( Math, this.masonry.colYs ),
width : Math.min(layoutWidth, itemsTotalWidth )
// fit container to columns that have been used;
width : (this.masonry.cols - unusedCols) * this.masonry.columnWidth
};
return size;
};

Loading…
Cancel
Save