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.
59 lines
1.0 KiB
59 lines
1.0 KiB
11 years ago
|
( function( window ) {
|
||
|
|
||
|
'use strict';
|
||
|
|
||
11 years ago
|
function fitRowsDefinition( LayoutMode ) {
|
||
11 years ago
|
|
||
11 years ago
|
var FitRows = LayoutMode.create( 'fitRows', {
|
||
11 years ago
|
foo: 'bar'
|
||
|
});
|
||
11 years ago
|
|
||
|
FitRows.prototype._resetLayout = function() {
|
||
|
this.x = 0;
|
||
|
this.y = 0;
|
||
|
this.maxY = 0;
|
||
|
};
|
||
|
|
||
|
FitRows.prototype._getItemLayoutPosition = function( item ) {
|
||
|
item.getSize();
|
||
|
|
||
|
// if this element cannot fit in the current row
|
||
11 years ago
|
if ( this.x !== 0 && item.size.outerWidth + this.x > this.isotope.size.innerWidth ) {
|
||
11 years ago
|
this.x = 0;
|
||
|
this.y = this.maxY;
|
||
|
}
|
||
|
|
||
|
var position = {
|
||
|
x: this.x,
|
||
|
y: this.y
|
||
|
};
|
||
|
|
||
|
this.maxY = Math.max( this.maxY, this.y + item.size.outerHeight );
|
||
11 years ago
|
this.x += item.size.outerWidth;
|
||
11 years ago
|
|
||
|
return position;
|
||
|
};
|
||
|
|
||
|
FitRows.prototype._getContainerSize = function() {
|
||
|
return { height: this.maxY };
|
||
|
};
|
||
|
|
||
11 years ago
|
return FitRows;
|
||
|
|
||
|
}
|
||
|
|
||
|
if ( typeof define === 'function' && define.amd ) {
|
||
|
// AMD
|
||
|
define( [
|
||
11 years ago
|
'../js/layout-mode'
|
||
11 years ago
|
],
|
||
|
fitRowsDefinition );
|
||
|
} else {
|
||
|
// browser global
|
||
|
fitRowsDefinition(
|
||
11 years ago
|
window.Isotope.LayoutMode
|
||
11 years ago
|
);
|
||
|
}
|
||
|
|
||
11 years ago
|
})( window );
|