Browse Source

src : layout mode API : add _checkIfSegmentsChanged method; remove namespace arg from _getSegments; layoutModeResize -> layoutModeResizeChanged, which returns boolean;

pull/96/head v1.3
David DeSandro 14 years ago
parent
commit
a7cc0be2a0
  1. 90
      jquery.isotope.js
  2. 4
      jquery.isotope.min.js

90
jquery.isotope.js

@ -1,5 +1,5 @@
/** /**
* Isotope v1.2.110523 * Isotope v1.3.110523
* An exquisite jQuery plugin for magical layouts * An exquisite jQuery plugin for magical layouts
* http://isotope.metafizzy.co * http://isotope.metafizzy.co
* *
@ -636,7 +636,9 @@
resize : function() { resize : function() {
this[ '_' + this.options.layoutMode + 'Resize' ](); if ( this[ '_' + this.options.layoutMode + 'ResizeChanged' ]() ) {
this.reLayout();
}
}, },
@ -757,11 +759,15 @@
}, },
// ====================== LAYOUTS ======================
// calculates number of rows or columns // calculates number of rows or columns
// requires columnWidth or rowHeight to be set on namespaced object // requires columnWidth or rowHeight to be set on namespaced object
// i.e. this.masonry.columnWidth = 200 // i.e. this.masonry.columnWidth = 200
_getSegments : function( namespace, isRows ) { _getSegments : function( isRows ) {
var measure = isRows ? 'rowHeight' : 'columnWidth', var namespace = this.layoutMode,
measure = isRows ? 'rowHeight' : 'columnWidth',
size = isRows ? 'height' : 'width', size = isRows ? 'height' : 'width',
UCSize = isRows ? 'Height' : 'Width', UCSize = isRows ? 'Height' : 'Width',
segmentsName = isRows ? 'rows' : 'cols', segmentsName = isRows ? 'rows' : 'cols',
@ -787,8 +793,16 @@
}, },
// ====================== LAYOUTS ====================== _checkIfSegmentsChanged : function( isRows ) {
var segmentsName = isRows ? 'rows' : 'cols',
prevSegments = this[ this.layoutMode ][ segmentsName ];
// update cols/rows
this._getSegments( isRows );
// return if updated cols/rows is not equal to previous
var changed = ( this[ this.layoutMode ][ segmentsName ] !== prevSegments );
console.log( changed );
return changed;
},
// ====================== Masonry ====================== // ====================== Masonry ======================
@ -858,7 +872,7 @@
// layout-specific props // layout-specific props
this.masonry = {}; this.masonry = {};
// FIXME shouldn't have to call this again // FIXME shouldn't have to call this again
this._getSegments('masonry'); this._getSegments();
var i = this.masonry.cols; var i = this.masonry.cols;
this.masonry.colYs = []; this.masonry.colYs = [];
while (i--) { while (i--) {
@ -866,14 +880,8 @@
} }
}, },
_masonryResize : function() { _masonryResizeChanged : function() {
var prevColCount = this.masonry.cols; return this._checkIfSegmentsChanged();
// get updated colCount
this._getSegments('masonry');
if ( this.masonry.cols !== prevColCount ) {
// if column count has changed, do a new column cound
this.reLayout();
}
}, },
_masonryGetContainerSize : function() { _masonryGetContainerSize : function() {
@ -923,8 +931,8 @@
return { height : this.fitRows.height }; return { height : this.fitRows.height };
}, },
_fitRowsResize : function() { _fitRowsResizeChanged : function() {
this.reLayout(); return true;
}, },
@ -932,7 +940,7 @@
_cellsByRowReset : function() { _cellsByRowReset : function() {
this.cellsByRow = {}; this.cellsByRow = {};
this._getSegments('cellsByRow'); this._getSegments();
this.cellsByRow.rowHeight = this.options.cellsByRow.rowHeight || this.$allAtoms.outerHeight(true); this.cellsByRow.rowHeight = this.options.cellsByRow.rowHeight || this.$allAtoms.outerHeight(true);
}, },
@ -954,14 +962,8 @@
return { height : Math.ceil( this.cellsByRow.atomsLen / this.cellsByRow.cols ) * this.cellsByRow.rowHeight + this.posTop }; return { height : Math.ceil( this.cellsByRow.atomsLen / this.cellsByRow.cols ) * this.cellsByRow.rowHeight + this.posTop };
}, },
_cellsByRowResize : function() { _cellsByRowResizeChanged : function() {
var prevCols = this.cellsByRow.cols; return this._getIfSegmentsChanged();
this._getSegments('cellsByRow');
// if column count has changed, do a new column cound
if ( this.cellsByRow.cols !== prevCols ) {
this.reLayout();
}
}, },
@ -987,8 +989,8 @@
return { height : this.straightDown.y + this.posTop }; return { height : this.straightDown.y + this.posTop };
}, },
_straightDownResize : function() { _straightDownResizeChanged : function() {
this.reLayout(); return true;
}, },
@ -1057,7 +1059,7 @@
// layout-specific props // layout-specific props
this.masonryHorizontal = {}; this.masonryHorizontal = {};
// FIXME shouldn't have to call this again // FIXME shouldn't have to call this again
this._getSegments( 'masonryHorizontal', true ); this._getSegments( true );
var i = this.masonryHorizontal.rows; var i = this.masonryHorizontal.rows;
this.masonryHorizontal.rowXs = []; this.masonryHorizontal.rowXs = [];
while (i--) { while (i--) {
@ -1065,14 +1067,8 @@
} }
}, },
_masonryHorizontalResize : function() { _masonryHorizontalResizeChanged : function() {
var prevRows = this.masonryHorizontal.rows; return this._getIfSegmentsChanged();
// get updated colCount
this._getSegments( 'masonryHorizontal', true );
if ( this.masonryHorizontal.rows !== prevRows ) {
// if column count has changed, do a new column cound
this.reLayout();
}
}, },
_masonryHorizontalGetContainerSize : function() { _masonryHorizontalGetContainerSize : function() {
@ -1121,8 +1117,8 @@
return { width : this.fitColumns.width }; return { width : this.fitColumns.width };
}, },
_fitColumnsResize : function() { _fitColumnsResizeChanged : function() {
this.reLayout(); return true;
}, },
@ -1131,7 +1127,7 @@
_cellsByColumnReset : function() { _cellsByColumnReset : function() {
this.cellsByColumn = {}; this.cellsByColumn = {};
this._getSegments( 'cellsByColumn', true ); this._getSegments( true );
this.cellsByColumn.columnWidth = this.options.cellsByColumn.columnWidth || this.$allAtoms.outerHeight(true); this.cellsByColumn.columnWidth = this.options.cellsByColumn.columnWidth || this.$allAtoms.outerHeight(true);
}, },
@ -1153,14 +1149,8 @@
return { width : Math.ceil( this.cellsByColumn.atomsLen / this.cellsByColumn.rows ) * this.cellsByColumn.columnWidth + this.posLeft }; return { width : Math.ceil( this.cellsByColumn.atomsLen / this.cellsByColumn.rows ) * this.cellsByColumn.columnWidth + this.posLeft };
}, },
_cellsByColumnResize : function() { _cellsByColumnResizeChanged : function() {
var prevRows = this.cellsByColumn.rows; return this._getIfSegmentsChanged();
this._getSegments( 'cellsByColumn', true );
// if column count has changed, do a new column cound
if ( this.cellsByColumn.rows !== prevRows ) {
this.reLayout();
}
}, },
// ====================== straightAcross ====================== // ====================== straightAcross ======================
@ -1185,8 +1175,8 @@
return { width : this.straightAcross.x + this.posLeft }; return { width : this.straightAcross.x + this.posLeft };
}, },
_straightAcrossResize : function() { _straightAcrossResizeChanged : function() {
this.reLayout(); return true;
} }
}; };

4
jquery.isotope.min.js vendored

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