Browse Source

src : re-order layout method

pull/96/head
David DeSandro 14 years ago
parent
commit
513daf5686
  1. 174
      jquery.isotope.js

174
jquery.isotope.js

@ -805,35 +805,18 @@
// ====================== Masonry ====================== // ====================== Masonry ======================
_masonryPlaceBrick : function( $brick, setCount, setY ) { _masonryReset : function() {
// here, `this` refers to a child element or "brick" // layout-specific props
// get the minimum Y value from the columns this.masonry = {};
var minimumY = Math.min.apply( Math, setY ), // FIXME shouldn't have to call this again
setHeight = minimumY + $brick.outerHeight(true), this._getSegments();
i = setY.length, var i = this.masonry.cols;
shortCol = i, this.masonry.colYs = [];
setSpan = this.masonry.cols + 1 - i,
x, y ;
// Which column has the minY value, closest to the left
while (i--) { while (i--) {
if ( setY[i] === minimumY ) { this.masonry.colYs.push( this.posTop );
shortCol = i;
}
}
// position the brick
x = this.masonry.columnWidth * shortCol + this.posLeft;
y = minimumY;
this._pushPosition( $brick, x, y );
// apply setHeight to necessary columns
for ( i=0; i < setSpan; i++ ) {
this.masonry.colYs[ shortCol + i ] = setHeight;
} }
}, },
_masonryLayout : function( $elems ) { _masonryLayout : function( $elems ) {
var instance = this; var instance = this;
$elems.each(function(){ $elems.each(function(){
@ -865,31 +848,54 @@
} }
}); });
}, },
// reset // worker method that places brick in the columnSet
_masonryReset : function() { // with the the minY
// layout-specific props _masonryPlaceBrick : function( $brick, setCount, setY ) {
this.masonry = {}; // get the minimum Y value from the columns
// FIXME shouldn't have to call this again var minimumY = Math.min.apply( Math, setY ),
this._getSegments(); setHeight = minimumY + $brick.outerHeight(true),
var i = this.masonry.cols; i = setY.length,
this.masonry.colYs = []; shortCol = i,
setSpan = this.masonry.cols + 1 - i,
x, y ;
// Which column has the minY value, closest to the left
while (i--) { while (i--) {
this.masonry.colYs.push( this.posTop ); if ( setY[i] === minimumY ) {
shortCol = i;
}
} }
// position the brick
x = this.masonry.columnWidth * shortCol + this.posLeft;
y = minimumY;
this._pushPosition( $brick, x, y );
// apply setHeight to necessary columns
for ( i=0; i < setSpan; i++ ) {
this.masonry.colYs[ shortCol + i ] = setHeight;
}
}, },
_masonryResizeChanged : function() {
return this._checkIfSegmentsChanged();
},
_masonryGetContainerSize : function() { _masonryGetContainerSize : function() {
var containerHeight = Math.max.apply( Math, this.masonry.colYs ) - this.posTop; var containerHeight = Math.max.apply( Math, this.masonry.colYs ) - this.posTop;
return { height: containerHeight }; return { height: containerHeight };
}, },
_masonryResizeChanged : function() {
return this._checkIfSegmentsChanged();
},
// ====================== fitRows ====================== // ====================== fitRows ======================
_fitRowsReset : function() {
this.fitRows = {
x : 0,
y : 0,
height : 0
};
},
_fitRowsLayout : function( $elems ) { _fitRowsLayout : function( $elems ) {
this.width = this.element.width(); this.width = this.element.width();
@ -918,14 +924,6 @@
}); });
}, },
_fitRowsReset : function() {
this.fitRows = {
x : 0,
y : 0,
height : 0
};
},
_fitRowsGetContainerSize : function () { _fitRowsGetContainerSize : function () {
return { height : this.fitRows.height }; return { height : this.fitRows.height };
}, },
@ -1000,35 +998,19 @@
// ====================== masonryHorizontal ====================== // ====================== masonryHorizontal ======================
_masonryHorizontalPlaceBrick : function( $brick, setCount, setX ) { _masonryHorizontalReset : function() {
// here, `this` refers to a child element or "brick" // layout-specific props
// get the minimum Y value from the columns this.masonryHorizontal = {};
var minimumX = Math.min.apply( Math, setX ), // FIXME shouldn't have to call this again
setWidth = minimumX + $brick.outerWidth(true), this._getSegments( true );
i = setX.length, var i = this.masonryHorizontal.rows;
smallRow = i, this.masonryHorizontal.rowXs = [];
setSpan = this.masonryHorizontal.rows + 1 - i,
x, y ;
// Which column has the minY value, closest to the left
while (i--) { while (i--) {
if ( setX[i] === minimumX ) { this.masonryHorizontal.rowXs.push( this.posLeft );
smallRow = i;
}
}
// position the brick
x = minimumX;
y = this.masonryHorizontal.rowHeight * smallRow + this.posTop;
this._pushPosition( $brick, x, y );
// apply setHeight to necessary columns
for ( i=0; i < setSpan; i++ ) {
this.masonryHorizontal.rowXs[ smallRow + i ] = setWidth;
} }
}, },
_masonryHorizontalLayout : function( $elems ) { _masonryHorizontalLayout : function( $elems ) {
var instance = this; var instance = this;
$elems.each(function(){ $elems.each(function(){
@ -1060,26 +1042,42 @@
}); });
}, },
_masonryHorizontalReset : function() { _masonryHorizontalPlaceBrick : function( $brick, setCount, setX ) {
// layout-specific props // here, `this` refers to a child element or "brick"
this.masonryHorizontal = {}; // get the minimum Y value from the columns
// FIXME shouldn't have to call this again var minimumX = Math.min.apply( Math, setX ),
this._getSegments( true ); setWidth = minimumX + $brick.outerWidth(true),
var i = this.masonryHorizontal.rows; i = setX.length,
this.masonryHorizontal.rowXs = []; smallRow = i,
setSpan = this.masonryHorizontal.rows + 1 - i,
x, y ;
// Which column has the minY value, closest to the left
while (i--) { while (i--) {
this.masonryHorizontal.rowXs.push( this.posLeft ); if ( setX[i] === minimumX ) {
smallRow = i;
}
} }
// position the brick
x = minimumX;
y = this.masonryHorizontal.rowHeight * smallRow + this.posTop;
this._pushPosition( $brick, x, y );
// apply setHeight to necessary columns
for ( i=0; i < setSpan; i++ ) {
this.masonryHorizontal.rowXs[ smallRow + i ] = setWidth;
}
}, },
_masonryHorizontalResizeChanged : function() {
return this._checkIfSegmentsChanged(true);
},
_masonryHorizontalGetContainerSize : function() { _masonryHorizontalGetContainerSize : function() {
var containerWidth = Math.max.apply( Math, this.masonryHorizontal.rowXs ) - this.posLeft; var containerWidth = Math.max.apply( Math, this.masonryHorizontal.rowXs ) - this.posLeft;
return { width: containerWidth }; return { width: containerWidth };
}, },
_masonryHorizontalResizeChanged : function() {
return this._checkIfSegmentsChanged(true);
},
// ====================== fitColumns ====================== // ====================== fitColumns ======================

Loading…
Cancel
Save