vendor/assets/javascripts/packery.pkgd.js in packery-rails-1.3.1 vs vendor/assets/javascripts/packery.pkgd.js in packery-rails-1.3.2
- old
+ new
@@ -1,16 +1,16 @@
/*!
- * Packery PACKAGED v1.3.1
+ * Packery PACKAGED v1.3.2
* bin-packing layout library
* http://packery.metafizzy.co
*
* Commercial use requires one-time purchase of a commercial license
* http://packery.metafizzy.co/license.html
*
* Non-commercial use is licensed under the GPL v3 License
*
- * Copyright 2014 Metafizzy
+ * Copyright 2015 Metafizzy
*/
/**
* Bridget makes jQuery widgets
* v1.1.0
@@ -543,11 +543,11 @@
}
})( window );
/*!
- * eventie v1.0.5
+ * eventie v1.0.6
* event binding helper
* eventie.bind( elem, 'click', myFn )
* eventie.unbind( elem, 'click', myFn )
* MIT license
*/
@@ -623,11 +623,11 @@
} else {
// browser global
window.eventie = eventie;
}
-})( this );
+})( window );
/*!
* docReady v1.0.4
* Cross browser DOMContentLoaded event emitter
* MIT license
@@ -3355,31 +3355,38 @@
}
})( window );
/*!
- * Packery v1.3.1
+ * Packery v1.3.2
* bin-packing layout library
* http://packery.metafizzy.co
*
* Commercial use requires one-time purchase of a commercial license
* http://packery.metafizzy.co/license.html
*
* Non-commercial use is licensed under the GPL v3 License
*
- * Copyright 2014 Metafizzy
+ * Copyright 2015 Metafizzy
*/
( function( window ) {
-// -------------------------- Packery -------------------------- //
-
// used for AMD definition and requires
function packeryDefinition( classie, getSize, Outlayer, Rect, Packer, Item ) {
+// ----- Rect ----- //
+
+// allow for pixel rounding errors IE8-IE11 & Firefox; #227
+Rect.prototype.canFit = function( rect ) {
+ return this.width >= rect.width - 1 && this.height >= rect.height - 1;
+};
+
+// -------------------------- Packery -------------------------- //
+
// create an Outlayer layout class
var Packery = Outlayer.create('packery');
Packery.Item = Item;
Packery.prototype._create = function() {
@@ -3498,17 +3505,34 @@
var w = size.outerWidth;
var h = size.outerHeight;
// size for columnWidth and rowHeight, if available
// only check if size is non-zero, #177
if ( w || h ) {
- var colW = this.columnWidth + this.gutter;
- var rowH = this.rowHeight + this.gutter;
- w = this.columnWidth ? Math.ceil( w / colW ) * colW : w + this.gutter;
- h = this.rowHeight ? Math.ceil( h / rowH ) * rowH : h + this.gutter;
+ w = this._applyGridGutter( w, this.columnWidth );
+ h = this._applyGridGutter( h, this.rowHeight );
}
// rect must fit in packer
rect.width = Math.min( w, this.packer.width );
rect.height = Math.min( h, this.packer.height );
+};
+
+/**
+ * fits item to columnWidth/rowHeight and adds gutter
+ * @param {Number} measurement - item width or height
+ * @param {Number} gridSize - columnWidth or rowHeight
+ * @returns measurement
+ */
+Packery.prototype._applyGridGutter = function( measurement, gridSize ) {
+ // just add gutter if no gridSize
+ if ( !gridSize ) {
+ return measurement + this.gutter;
+ }
+ gridSize += this.gutter;
+ // fit item to columnWidth/rowHeight
+ var remainder = measurement % gridSize;
+ var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
+ measurement = Math[ mathMethod ]( measurement / gridSize ) * gridSize;
+ return measurement;
};
Packery.prototype._getContainerSize = function() {
if ( this.options.isHorizontal ) {
return {