diff --git a/src/jquery.columnizer.js b/src/jquery.columnizer.js
index ad75643..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($("
"));
}
@@ -600,7 +611,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();