From 994d648f32314188a51ca1b1888184bd8452440a Mon Sep 17 00:00:00 2001 From: David DeSandro Date: Tue, 14 May 2013 07:38:38 -0400 Subject: [PATCH] prevent setting negative size. Fixes #38 negative size causes error in IE --- bower.json | 2 +- js/packery.js | 4 +++- test/defaults-empty.js | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 3a340c5..2d70372 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "packery", - "version": "1.0.4", + "version": "1.0.5", "author": "David DeSandro / Metafizzy", "description": "bin-packing layout library", "main": [ diff --git a/js/packery.js b/js/packery.js index bb72b4b..3bfaaa3 100644 --- a/js/packery.js +++ b/js/packery.js @@ -1,5 +1,5 @@ /*! - * Packery v1.0.4 + * Packery v1.0.5 * bin-packing layout library * http://packery.metafizzy.co * @@ -357,6 +357,8 @@ Packery.prototype.layoutItems = function( items, isInstant ) { elemH += elemSize.paddingBottom + elemSize.paddingTop + elemSize.borderTopWidth + elemSize.borderBottomWidth; } + // prevent negative size, which causes error in IE + elemH = Math.max( elemH, 0 ); this.element.style.height = elemH + 'px'; }; diff --git a/test/defaults-empty.js b/test/defaults-empty.js index cdb7710..67a5156 100644 --- a/test/defaults-empty.js +++ b/test/defaults-empty.js @@ -18,6 +18,8 @@ test( 'defaults / empty', function() { return true; // bind once }); stop(); + // add gutter, to check that container size doesn't get negative number + pckry.options.gutter = 20; pckry.layout(); });