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.
74 lines
1.7 KiB
74 lines
1.7 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'; |
|
|
|
// -------------------------- 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; |
|
|
|
}));
|
|
|