Browse Source

src : fix layout logic in cellsByRow and cellsByColumn

fixes when getContainerSize is f'ed after appending with these layout modes
pull/96/head
David DeSandro 14 years ago
parent
commit
83f0ace775
  1. 46
      jquery.isotope.js

46
jquery.isotope.js

@ -938,27 +938,33 @@
// ====================== cellsByRow ====================== // ====================== cellsByRow ======================
_cellsByRowReset : function() { _cellsByRowReset : function() {
this.cellsByRow = {}; this.cellsByRow = {
index : 0
};
// get this.cellsByRow.columnWidth
this._getSegments(); this._getSegments();
this.cellsByRow.rowHeight = this.options.cellsByRow.rowHeight || this.$allAtoms.outerHeight(true); // get this.cellsByRow.rowHeight
this._getSegments(true);
}, },
_cellsByRowLayout : function( $elems ) { _cellsByRowLayout : function( $elems ) {
var instance = this, var instance = this,
cols = this.cellsByRow.cols; props = this.cellsByRow;
this.cellsByRow.atomsLen = $elems.length; $elems.each( function(){
$elems.each( function( i ){
var $this = $(this), var $this = $(this),
x = ( i % cols + 0.5 ) * instance.cellsByRow.columnWidth - col = props.index % props.cols,
row = ~~( props.index / props.cols ),
x = ( col + 0.5 ) * props.columnWidth -
$this.outerWidth(true) / 2 + instance.posLeft, $this.outerWidth(true) / 2 + instance.posLeft,
y = ( ~~( i / cols ) + 0.5 ) * instance.cellsByRow.rowHeight - y = ( row + 0.5 ) * props.rowHeight -
$this.outerHeight(true) / 2 + instance.posTop; $this.outerHeight(true) / 2 + instance.posTop;
instance._pushPosition( $this, x, y ); instance._pushPosition( $this, x, y );
props.index ++;
}); });
}, },
_cellsByRowGetContainerSize : function() { _cellsByRowGetContainerSize : function() {
return { height : Math.ceil( this.cellsByRow.atomsLen / this.cellsByRow.cols ) * this.cellsByRow.rowHeight + this.posTop }; return { height : Math.ceil( this.$filteredAtoms.length / this.cellsByRow.cols ) * this.cellsByRow.rowHeight + this.posTop };
}, },
_cellsByRowResizeChanged : function() { _cellsByRowResizeChanged : function() {
@ -1125,27 +1131,33 @@
// ====================== cellsByColumn ====================== // ====================== cellsByColumn ======================
_cellsByColumnReset : function() { _cellsByColumnReset : function() {
this.cellsByColumn = {}; this.cellsByColumn = {
this._getSegments( true ); index : 0
this.cellsByColumn.columnWidth = this.options.cellsByColumn.columnWidth || this.$allAtoms.outerHeight(true); };
// get this.cellsByColumn.columnWidth
this._getSegments();
// get this.cellsByColumn.rowHeight
this._getSegments(true);
}, },
_cellsByColumnLayout : function( $elems ) { _cellsByColumnLayout : function( $elems ) {
var instance = this, var instance = this,
rows = this.cellsByColumn.rows; props = this.cellsByColumn;
this.cellsByColumn.atomsLen = $elems.length; $elems.each( function(){
$elems.each( function( i ){
var $this = $(this), var $this = $(this),
x = ( ~~( i / rows ) + 0.5 ) * instance.cellsByColumn.columnWidth - col = ~~( props.index / props.rows ),
row = props.index % props.rows,
x = ( col + 0.5 ) * props.columnWidth -
$this.outerWidth(true) / 2 + instance.posLeft, $this.outerWidth(true) / 2 + instance.posLeft,
y = ( i % rows + 0.5 ) * instance.cellsByColumn.rowHeight - y = ( row + 0.5 ) * props.rowHeight -
$this.outerHeight(true) / 2 + instance.posTop; $this.outerHeight(true) / 2 + instance.posTop;
instance._pushPosition( $this, x, y ); instance._pushPosition( $this, x, y );
props.index ++;
}); });
}, },
_cellsByColumnGetContainerSize : function() { _cellsByColumnGetContainerSize : function() {
return { width : Math.ceil( this.cellsByColumn.atomsLen / this.cellsByColumn.rows ) * this.cellsByColumn.columnWidth + this.posLeft }; return { width : Math.ceil( this.$filteredAtoms.length / this.cellsByColumn.rows ) * this.cellsByColumn.columnWidth + this.posLeft };
}, },
_cellsByColumnResizeChanged : function() { _cellsByColumnResizeChanged : function() {

Loading…
Cancel
Save