Skip to content

Commit e5468b6

Browse files
author
Manoj Mishra
committed
Add support for border,margin & padding
1 parent 0bbd90a commit e5468b6

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

src/jquery.columnizer.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
overflow : false,
2121
// this function is called after content is columnized
2222
doneFunc : function(){},
23-
// if the content should be columnized into a
23+
// if the content should be columnized into a
2424
// container node other than it's own node
2525
target : false,
2626
// re-columnizing when images reload might make things
@@ -119,7 +119,7 @@
119119
* is a text node, then it will try to split that text node. otherwise
120120
* it will leave the node in $pullOutHere and return with a height
121121
* smaller than targetHeight.
122-
*
122+
*
123123
* Returns a boolean on whether we did some splitting successfully at a text point
124124
* (so we know we don't need to split a real element). return false if the caller should
125125
* split a node if possible to end this column.
@@ -207,7 +207,7 @@
207207
}
208208

209209
/**
210-
* Split up an element, which is more complex than splitting text. We need to create
210+
* Split up an element, which is more complex than splitting text. We need to create
211211
* two copies of the element with it's contents divided between each
212212
*/
213213
function split($putInHere, $pullOutHere, $parentColumn, targetHeight){
@@ -258,7 +258,7 @@
258258
}else if($clone.is("img") || $cloneMe.hasClass(prefixTheClassName("dontsplit"))){
259259
//
260260
// it's either an image that's too tall, or an unsplittable node
261-
// that's too tall. leave it in the pullOutHere and we'll add it to the
261+
// that's too tall. leave it in the pullOutHere and we'll add it to the
262262
// next column
263263
$clone.remove();
264264
}else{
@@ -375,10 +375,10 @@
375375
function columnizeIt() {
376376
//reset adjustment var
377377
adjustment = 0;
378-
if(lastWidth == $inBox.width()) return;
379-
lastWidth = $inBox.width();
378+
if(lastWidth == $inBox.outerWidth()) return;
379+
lastWidth = $inBox.outerWidth();
380380

381-
var numCols = Math.round($inBox.width() / options.width);
381+
var numCols = Math.round($inBox.outerWidth() / options.width);
382382
var optionWidth = options.width;
383383
var optionHeight = options.height;
384384
if(options.columns) numCols = options.columns;
@@ -418,7 +418,7 @@
418418
}
419419

420420
//
421-
// We loop as we try and workout a good height to use. We know it initially as an average
421+
// We loop as we try and workout a good height to use. We know it initially as an average
422422
// but if the last column is higher than the first ones (which can happen, depending on split
423423
// points) we need to raise 'adjustment'. We try this over a few iterations until we're 'solid'.
424424
//
@@ -590,7 +590,17 @@
590590
$col.removeClass(prefixTheClassName("last"));
591591
}
592592
});
593-
$inBox.width($inBox.children().length * optionWidth + "px");
593+
$inBox.find('.column').each(function(){
594+
if($(this).children().length == 0)
595+
$(this).remove()
596+
});
597+
var targetWidth = 0;
598+
$inBox.children().each(function(){
599+
targetWidth += $(this).outerWidth()
600+
})
601+
602+
$inBox.width(targetWidth + "px");
603+
// $inBox.width($inBox.children().length * optionWidth + "px");
594604
}
595605
$inBox.append($("<br style='clear:both;'>"));
596606
}

0 commit comments

Comments
 (0)