Browse Source

src : refractor fitFooLayout

pull/96/head
David DeSandro 14 years ago
parent
commit
8bc68bea5b
  1. 40
      jquery.isotope.js
  2. 2
      jquery.isotope.min.js

40
jquery.isotope.js

@ -892,7 +892,8 @@
_fitRowsLayout : function( $elems ) { _fitRowsLayout : function( $elems ) {
var instance = this, var instance = this,
containerWidth = this.element.width(); containerWidth = this.element.width(),
props = this.fitRows;
$elems.each( function() { $elems.each( function() {
var $this = $(this), var $this = $(this),
@ -900,19 +901,17 @@
atomH = $this.outerHeight(true), atomH = $this.outerHeight(true),
x, y; x, y;
if ( instance.fitRows.x !== 0 && atomW + instance.fitRows.x > containerWidth ) { if ( props.x !== 0 && atomW + props.x > containerWidth ) {
// if this element cannot fit in the current row // if this element cannot fit in the current row
instance.fitRows.x = 0; props.x = 0;
instance.fitRows.y = instance.fitRows.height; props.y = props.height;
} }
// position the atom // position the atom
x = instance.fitRows.x; instance._pushPosition( $this, props.x, props.y );
y = instance.fitRows.y;
instance._pushPosition( $this, x, y );
instance.fitRows.height = Math.max( instance.fitRows.y + atomH, instance.fitRows.height ); props.height = Math.max( props.y + atomH, props.height );
instance.fitRows.x += atomW; props.x += atomW;
}); });
}, },
@ -945,10 +944,8 @@
var $this = $(this), var $this = $(this),
col = props.index % props.cols, col = props.index % props.cols,
row = ~~( props.index / props.cols ), row = ~~( props.index / props.cols ),
x = ( col + 0.5 ) * props.columnWidth - x = ( col + 0.5 ) * props.columnWidth - $this.outerWidth(true) / 2,
$this.outerWidth(true) / 2, y = ( row + 0.5 ) * props.rowHeight - $this.outerHeight(true) / 2;
y = ( row + 0.5 ) * props.rowHeight -
$this.outerHeight(true) / 2;
instance._pushPosition( $this, x, y ); instance._pushPosition( $this, x, y );
props.index ++; props.index ++;
}); });
@ -1085,26 +1082,25 @@
_fitColumnsLayout : function( $elems ) { _fitColumnsLayout : function( $elems ) {
var instance = this, var instance = this,
containerHeight = this.element.height(); containerHeight = this.element.height(),
props = this.fitColumns;
$elems.each( function() { $elems.each( function() {
var $this = $(this), var $this = $(this),
atomW = $this.outerWidth(true), atomW = $this.outerWidth(true),
atomH = $this.outerHeight(true), atomH = $this.outerHeight(true),
x, y; x, y;
if ( instance.fitColumns.y !== 0 && atomH + instance.fitColumns.y > containerHeight ) { if ( props.y !== 0 && atomH + props.y > containerHeight ) {
// if this element cannot fit in the current column // if this element cannot fit in the current column
instance.fitColumns.x = instance.fitColumns.width; props.x = props.width;
instance.fitColumns.y = 0; props.y = 0;
} }
// position the atom // position the atom
x = instance.fitColumns.x; instance._pushPosition( $this, props.x, props.y );
y = instance.fitColumns.y;
instance._pushPosition( $this, x, y );
instance.fitColumns.width = Math.max( instance.fitColumns.x + atomW, instance.fitColumns.width ); props.width = Math.max( props.x + atomW, props.width );
instance.fitColumns.y += atomH; props.y += atomH;
}); });
}, },

2
jquery.isotope.min.js vendored

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