Skip to content

Instantly share code, notes, and snippets.

@nsbingham
Created July 20, 2012 19:15
Show Gist options
  • Save nsbingham/3152673 to your computer and use it in GitHub Desktop.
Save nsbingham/3152673 to your computer and use it in GitHub Desktop.
Isotope masonryHorizontal gutters
// Execute this before an isotope call
// modified Isotope methods for gutters in masonryHorizontal
$.Isotope.prototype._getMasonryHorizontalGutterRows = function() {
var gutter = this.options.masonryHorizontal && this.options.masonryHorizontal.gutterWidth || 0;
containerHeight = this.element.height();
this.masonryHorizontal.rowHeight = this.options.masonryHorizontal && this.options.masonryHorizontal.rowHeight ||
// or use the size of the first item
this.$filteredAtoms.outerHeight(true) ||
// if there's no items, use size of container
containerHeight;
this.masonryHorizontal.rowHeight += gutter;
this.masonryHorizontal.rows = Math.floor( ( containerHeight + gutter ) / this.masonryHorizontal.rowHeight );
this.masonryHorizontal.rows = Math.max( this.masonryHorizontal.rows, 1 );
};
$.Isotope.prototype._masonryHorizontalReset = function() {
// layout-specific props
this.masonryHorizontal = {};
// FIXME shouldn't have to call this again
this._getSegments( true );
this._getMasonryHorizontalGutterRows();
var i = this.masonryHorizontal.rows;
this.masonryHorizontal.rowXs = [];
while (i--) {
this.masonryHorizontal.rowXs.push( 0 );
}
};
$.Isotope.prototype._masonryHorizontalResizeChanged = function() {
var prevSegments = this.masonryHorizontal.rows;
// update cols/rows
this._getMasonryHorizontalGutterRows();
// return if updated cols/rows is not equal to previous
return ( this.masonryHorizontal.rows !== prevSegments );
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment