Browse Source

src : refactor masonryPlaceBrick methods

pull/96/head
David DeSandro 14 years ago
parent
commit
4a599367a3
  1. 37
      jquery.isotope.js
  2. 4
      jquery.isotope.min.js

37
jquery.isotope.js

@ -1,5 +1,5 @@
/** /**
* Isotope v1.3.110524 * Isotope v1.3.110525
* An exquisite jQuery plugin for magical layouts * An exquisite jQuery plugin for magical layouts
* http://isotope.metafizzy.co * http://isotope.metafizzy.co
* *
@ -844,17 +844,15 @@
// worker method that places brick in the columnSet // worker method that places brick in the columnSet
// with the the minY // with the the minY
_masonryPlaceBrick : function( $brick, setY ) { _masonryPlaceBrick : function( $brick, setY ) {
// get the minimum Y value from the columns // get the minimum Y value from the columns
var minimumY = Math.min.apply( Math, setY ), var minimumY = Math.min.apply( Math, setY ),
setHeight = minimumY + $brick.outerHeight(true), shortCol = 0;
i = setY.length,
shortCol = i, // Find index of short column, the first from the left
setSpan = this.masonry.cols + 1 - i, for (var i=0, len = setY.length; i < len; i++) {
x, y ;
// Which column has the minY value, closest to the left
while (i--) {
if ( setY[i] === minimumY ) { if ( setY[i] === minimumY ) {
shortCol = i; shortCol = i;
break;
} }
} }
@ -864,6 +862,8 @@
this._pushPosition( $brick, x, y ); this._pushPosition( $brick, x, y );
// apply setHeight to necessary columns // apply setHeight to necessary columns
var setHeight = minimumY + $brick.outerHeight(true),
setSpan = this.masonry.cols + 1 - len;
for ( i=0; i < setSpan; i++ ) { for ( i=0; i < setSpan; i++ ) {
this.masonry.colYs[ shortCol + i ] = setHeight; this.masonry.colYs[ shortCol + i ] = setHeight;
} }
@ -1032,18 +1032,14 @@
}, },
_masonryHorizontalPlaceBrick : function( $brick, setX ) { _masonryHorizontalPlaceBrick : function( $brick, setX ) {
// here, `this` refers to a child element or "brick" // get the minimum Y value from the columns
// get the minimum Y value from the columns
var minimumX = Math.min.apply( Math, setX ), var minimumX = Math.min.apply( Math, setX ),
setWidth = minimumX + $brick.outerWidth(true), smallRow = 0;
i = setX.length, // Find index of smallest row, the first from the top
smallRow = i, for (var i=0, len = setX.length; i < len; i++) {
setSpan = this.masonryHorizontal.rows + 1 - i,
x, y ;
// Which column has the minY value, closest to the left
while (i--) {
if ( setX[i] === minimumX ) { if ( setX[i] === minimumX ) {
smallRow = i; smallRow = i;
break;
} }
} }
@ -1053,10 +1049,11 @@
this._pushPosition( $brick, x, y ); this._pushPosition( $brick, x, y );
// apply setHeight to necessary columns // apply setHeight to necessary columns
var setWidth = minimumX + $brick.outerWidth(true),
setSpan = this.masonryHorizontal.rows + 1 - len;
for ( i=0; i < setSpan; i++ ) { for ( i=0; i < setSpan; i++ ) {
this.masonryHorizontal.rowXs[ smallRow + i ] = setWidth; this.masonryHorizontal.rowXs[ smallRow + i ] = setWidth;
} }
}, },
_masonryHorizontalGetContainerSize : function() { _masonryHorizontalGetContainerSize : function() {

4
jquery.isotope.min.js vendored

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save