Skip to content

Commit 7f8eaff

Browse files
committed
new options resizeContainer
1 parent 3d9cbee commit 7f8eaff

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/jquery.columnizer.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
ignoreImageLoading : true,
2929
// should columns float left or right
3030
columnFloat : "left",
31+
// resize container to width of filled columns only
32+
// works with width and height options set
33+
resizeContainer : false,
3134
// ensure the last column is never the tallest column
3235
lastNeverTallest : false,
3336
// (int) the minimum number of characters to jump when splitting
@@ -580,6 +583,7 @@
580583
}
581584
}else{
582585
// it's scrolling horizontally, fix the width/classes of the columns
586+
var nonEmptyColumns = 0;
583587
$inBox.children().each(function(i){
584588
$col = $inBox.children().eq(i);
585589
$col.width(optionWidth + "px");
@@ -591,8 +595,15 @@
591595
$col.removeClass(prefixTheClassName("first"));
592596
$col.removeClass(prefixTheClassName("last"));
593597
}
598+
if($col.html() != ''){
599+
nonEmptyColumns++;
600+
}
594601
});
595-
$inBox.width($inBox.children().length * optionWidth + "px");
602+
if(nonEmptyColumns && options.resizeContainer){
603+
$inBox.width(nonEmptyColumns * optionWidth + "px");
604+
}else{
605+
$inBox.width($inBox.children().length * optionWidth + "px");
606+
}
596607
}
597608
$inBox.append($("<br style='clear:both;'>"));
598609
}

0 commit comments

Comments
 (0)