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.
60 lines
1.3 KiB
60 lines
1.3 KiB
12 years ago
|
( function( window ) {
|
||
|
|
||
|
'use strict';
|
||
|
|
||
12 years ago
|
function cellsByRowDefinition( LayoutMode ) {
|
||
12 years ago
|
|
||
12 years ago
|
var CellsByRow = LayoutMode.create( 'cellsByRow' );
|
||
12 years ago
|
|
||
|
CellsByRow.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 cols
|
||
12 years ago
|
this.cols = Math.floor( this.isotope.size.innerWidth / this.columnWidth );
|
||
12 years ago
|
this.cols = Math.max( this.cols, 1 );
|
||
|
};
|
||
|
|
||
|
CellsByRow.prototype._getItemLayoutPosition = function( item ) {
|
||
|
item.getSize();
|
||
|
var col = this.itemIndex % this.cols;
|
||
|
var row = Math.floor( this.itemIndex / this.cols );
|
||
|
// 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 };
|
||
|
};
|
||
|
|
||
|
CellsByRow.prototype._getContainerSize = function() {
|
||
|
return {
|
||
12 years ago
|
height: Math.ceil( this.itemIndex / this.cols ) * this.rowHeight
|
||
12 years ago
|
};
|
||
|
};
|
||
|
|
||
|
return CellsByRow;
|
||
|
|
||
|
}
|
||
|
|
||
|
if ( typeof define === 'function' && define.amd ) {
|
||
|
// AMD
|
||
|
define( [
|
||
12 years ago
|
'../js/layout-mode',
|
||
12 years ago
|
'get-size/get-size'
|
||
|
],
|
||
|
cellsByRowDefinition );
|
||
|
} else {
|
||
|
// browser global
|
||
|
cellsByRowDefinition(
|
||
12 years ago
|
window.Isotope.LayoutMode,
|
||
12 years ago
|
window.getSize
|
||
|
);
|
||
|
}
|
||
|
|
||
|
|
||
|
})( window );
|
||
|
|
||
|
|