mirror of https://github.com/metafizzy/isotope
Filter & sort magical layouts
http://isotope.metafizzy.co
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.4 KiB
62 lines
1.4 KiB
12 years ago
|
( function( window ) {
|
||
|
|
||
|
'use strict';
|
||
|
|
||
12 years ago
|
function cellsByColumnDefinition( LayoutMode ) {
|
||
12 years ago
|
|
||
12 years ago
|
var CellsByColumn = LayoutMode.create( 'cellsByColumn' );
|
||
12 years ago
|
|
||
|
CellsByColumn.prototype._resetLayout = function() {
|
||
12 years ago
|
// reset properties
|
||
12 years ago
|
this.itemIndex = 0;
|
||
12 years ago
|
// measurements
|
||
|
this.getColumnWidth();
|
||
|
this.getRowHeight();
|
||
12 years ago
|
// set rows
|
||
12 years ago
|
this.rows = Math.floor( this.isotope.size.innerHeight / this.rowHeight );
|
||
12 years ago
|
this.rows = Math.max( this.rows, 1 );
|
||
|
};
|
||
|
|
||
|
CellsByColumn.prototype._getItemLayoutPosition = function( item ) {
|
||
|
item.getSize();
|
||
|
var col = Math.floor( this.itemIndex / this.rows );
|
||
|
var row = this.itemIndex % this.rows;
|
||
|
// center item within cell
|
||
|
var x = ( col + 0.5 ) * this.columnWidth - item.size.outerWidth / 2;
|
||
|
var y = ( row + 0.5 ) * this.rowHeight - item.size.outerHeight / 2;
|
||
|
this.itemIndex++;
|
||
|
return { x: x, y: y };
|
||
|
};
|
||
|
|
||
|
CellsByColumn.prototype._getContainerSize = function() {
|
||
|
return {
|
||
|
width: Math.ceil( this.itemIndex / this.rows ) * this.columnWidth
|
||
|
};
|
||
|
};
|
||
|
|
||
|
CellsByColumn.prototype.resize = function() {
|
||
12 years ago
|
this.resizeVertical();
|
||
12 years ago
|
};
|
||
|
|
||
|
return CellsByColumn;
|
||
|
|
||
|
}
|
||
|
|
||
|
if ( typeof define === 'function' && define.amd ) {
|
||
|
// AMD
|
||
|
define( [
|
||
12 years ago
|
'../js/layout-mode'
|
||
12 years ago
|
],
|
||
|
cellsByColumnDefinition );
|
||
|
} else {
|
||
|
// browser global
|
||
|
cellsByColumnDefinition(
|
||
12 years ago
|
window.Isotope.LayoutMode
|
||
12 years ago
|
);
|
||
|
}
|
||
|
|
||
|
|
||
|
})( window );
|
||
|
|
||
|
|