|
|
|
/*!
|
|
|
|
* 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';
|
|
|
|
|
|
|
|
// -------------------------- masonryDefinition -------------------------- //
|
|
|
|
|
|
|
|
// create an Outlayer layout class
|
|
|
|
var MasonryMode = LayoutMode.create('masonry');
|
|
|
|
|
|
|
|
var proto = MasonryMode.prototype;
|
|
|
|
|
|
|
|
var keepModeMethods = {
|
|
|
|
_getElementOffset: true,
|
|
|
|
layout: true,
|
|
|
|
_getMeasurement: true
|
|
|
|
};
|
|
|
|
|
|
|
|
// inherit Masonry prototype
|
|
|
|
for ( var method in Masonry.prototype ) {
|
|
|
|
// do not inherit mode methods
|
|
|
|
if ( !keepModeMethods[ method ] ) {
|
|
|
|
proto[ method ] = Masonry.prototype[ method ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var measureColumns = proto.measureColumns;
|
|
|
|
proto.measureColumns = function() {
|
|
|
|
// set items, used if measuring first item
|
|
|
|
this.items = this.isotope.filteredItems;
|
|
|
|
measureColumns.call( this );
|
|
|
|
};
|
|
|
|
|
|
|
|
// point to mode options for fitWidth
|
|
|
|
var _getOption = proto._getOption;
|
|
|
|
proto._getOption = function( option ) {
|
|
|
|
if ( option == 'fitWidth' ) {
|
|
|
|
return this.options.isFitWidth !== undefined ?
|
|
|
|
this.options.isFitWidth : this.options.fitWidth;
|
|
|
|
}
|
|
|
|
return _getOption.apply( this.isotope, arguments );
|
|
|
|
};
|
|
|
|
|
|
|
|
return MasonryMode;
|
|
|
|
|
|
|
|
}));
|