From 3d9cbeee5bbc8485a2e64ffcd29151677092a915 Mon Sep 17 00:00:00 2001 From: Nazin Date: Sat, 24 Nov 2012 13:19:11 +0100 Subject: [PATCH 1/2] fix in condition --- src/jquery.columnizer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jquery.columnizer.js b/src/jquery.columnizer.js index ad75643..5f8f20b 100644 --- a/src/jquery.columnizer.js +++ b/src/jquery.columnizer.js @@ -600,7 +600,7 @@ $inBox.find(prefixTheClassName("column", true)).find(':last' + prefixTheClassName("removeiflast", true)).remove(); $inBox.data("columnizing", false); - if(options.overflow){ + if(options.overflow && options.overflow.doneFunc){ options.overflow.doneFunc(); } options.doneFunc(); From 7f8eaffb5c4584024a4cc48b3719e4edf5038d10 Mon Sep 17 00:00:00 2001 From: Nazin Date: Sat, 24 Nov 2012 13:54:07 +0100 Subject: [PATCH 2/2] new options resizeContainer --- src/jquery.columnizer.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/jquery.columnizer.js b/src/jquery.columnizer.js index 5f8f20b..c1ce615 100644 --- a/src/jquery.columnizer.js +++ b/src/jquery.columnizer.js @@ -28,6 +28,9 @@ ignoreImageLoading : true, // should columns float left or right columnFloat : "left", + // resize container to width of filled columns only + // works with width and height options set + resizeContainer : false, // ensure the last column is never the tallest column lastNeverTallest : false, // (int) the minimum number of characters to jump when splitting @@ -580,6 +583,7 @@ } }else{ // it's scrolling horizontally, fix the width/classes of the columns + var nonEmptyColumns = 0; $inBox.children().each(function(i){ $col = $inBox.children().eq(i); $col.width(optionWidth + "px"); @@ -591,8 +595,15 @@ $col.removeClass(prefixTheClassName("first")); $col.removeClass(prefixTheClassName("last")); } + if($col.html() != ''){ + nonEmptyColumns++; + } }); - $inBox.width($inBox.children().length * optionWidth + "px"); + if(nonEmptyColumns && options.resizeContainer){ + $inBox.width(nonEmptyColumns * optionWidth + "px"); + }else{ + $inBox.width($inBox.children().length * optionWidth + "px"); + } } $inBox.append($("
")); }