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.
61 lines
1.1 KiB
61 lines
1.1 KiB
11 years ago
|
( function( window ) {
|
||
|
|
||
|
'use strict';
|
||
|
|
||
11 years ago
|
function fitColumnsDefinition( LayoutMode ) {
|
||
11 years ago
|
|
||
11 years ago
|
var FitColumns = LayoutMode.create('fitColumns');
|
||
11 years ago
|
|
||
|
FitColumns.prototype._resetLayout = function() {
|
||
|
this.x = 0;
|
||
|
this.y = 0;
|
||
|
this.maxX = 0;
|
||
|
};
|
||
|
|
||
|
FitColumns.prototype._getItemLayoutPosition = function( item ) {
|
||
|
item.getSize();
|
||
|
|
||
|
// if this element cannot fit in the current row
|
||
|
if ( this.y !== 0 && item.size.outerHeight + this.y > this.isotope.size.innerHeight ) {
|
||
|
this.y = 0;
|
||
|
this.x = this.maxX;
|
||
|
}
|
||
|
|
||
|
var position = {
|
||
|
x: this.x,
|
||
|
y: this.y
|
||
|
};
|
||
|
|
||
|
this.maxX = Math.max( this.maxX, this.x + item.size.outerWidth );
|
||
|
this.y += item.size.outerHeight;
|
||
|
|
||
|
return position;
|
||
|
};
|
||
|
|
||
|
FitColumns.prototype._getContainerSize = function() {
|
||
|
return { width: this.maxX };
|
||
|
};
|
||
|
|
||
|
FitColumns.prototype.resize = function() {
|
||
11 years ago
|
this.resizeVertical();
|
||
11 years ago
|
};
|
||
|
|
||
|
return FitColumns;
|
||
|
|
||
|
}
|
||
|
|
||
|
if ( typeof define === 'function' && define.amd ) {
|
||
|
// AMD
|
||
|
define( [
|
||
11 years ago
|
'../js/layout-mode'
|
||
11 years ago
|
],
|
||
|
fitColumnsDefinition );
|
||
|
} else {
|
||
|
// browser global
|
||
|
fitColumnsDefinition(
|
||
11 years ago
|
window.Isotope.LayoutMode
|
||
11 years ago
|
);
|
||
|
}
|
||
|
|
||
|
})( window );
|