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.
79 lines
2.1 KiB
79 lines
2.1 KiB
/*! |
|
* Masonry layout mode |
|
* sub-classes Masonry |
|
* http://masonry.desandro.com |
|
*/ |
|
|
|
( function( window, factory ) { |
|
'use strict'; |
|
// universal module definition |
|
if ( typeof define == 'function' && define.amd ) { |
|
// AMD |
|
define( [ |
|
'../layout-mode', |
|
'masonry/masonry' |
|
], |
|
factory ); |
|
} else if ( typeof exports == 'object' ) { |
|
// CommonJS |
|
module.exports = factory( |
|
require('../layout-mode'), |
|
require('masonry-layout') |
|
); |
|
} else { |
|
// browser global |
|
factory( |
|
window.Isotope.LayoutMode, |
|
window.Masonry |
|
); |
|
} |
|
|
|
}( window, function factory( LayoutMode, Masonry ) { |
|
'use strict'; |
|
|
|
// -------------------------- helpers -------------------------- // |
|
|
|
// extend objects |
|
function extend( a, b ) { |
|
for ( var prop in b ) { |
|
a[ prop ] = b[ prop ]; |
|
} |
|
return a; |
|
} |
|
|
|
// -------------------------- masonryDefinition -------------------------- // |
|
|
|
// create an Outlayer layout class |
|
var MasonryMode = LayoutMode.create('masonry'); |
|
|
|
// save on to these methods |
|
var _getElementOffset = MasonryMode.prototype._getElementOffset; |
|
var layout = MasonryMode.prototype.layout; |
|
var _getMeasurement = MasonryMode.prototype._getMeasurement; |
|
|
|
// sub-class Masonry |
|
extend( MasonryMode.prototype, Masonry.prototype ); |
|
|
|
// set back, as it was overwritten by Masonry |
|
MasonryMode.prototype._getElementOffset = _getElementOffset; |
|
MasonryMode.prototype.layout = layout; |
|
MasonryMode.prototype._getMeasurement = _getMeasurement; |
|
|
|
var measureColumns = MasonryMode.prototype.measureColumns; |
|
MasonryMode.prototype.measureColumns = function() { |
|
// set items, used if measuring first item |
|
this.items = this.isotope.filteredItems; |
|
measureColumns.call( this ); |
|
}; |
|
|
|
// HACK copy over isOriginLeft/Top options |
|
var _manageStamp = MasonryMode.prototype._manageStamp; |
|
MasonryMode.prototype._manageStamp = function() { |
|
this.options.isOriginLeft = this.isotope.options.isOriginLeft; |
|
this.options.isOriginTop = this.isotope.options.isOriginTop; |
|
_manageStamp.apply( this, arguments ); |
|
}; |
|
|
|
return MasonryMode; |
|
|
|
}));
|
|
|