|
20 | 20 | overflow : false, |
21 | 21 | // this function is called after content is columnized |
22 | 22 | doneFunc : function(){}, |
23 | | - // if the content should be columnized into a |
| 23 | + // if the content should be columnized into a |
24 | 24 | // container node other than it's own node |
25 | 25 | target : false, |
26 | 26 | // re-columnizing when images reload might make things |
|
119 | 119 | * is a text node, then it will try to split that text node. otherwise |
120 | 120 | * it will leave the node in $pullOutHere and return with a height |
121 | 121 | * smaller than targetHeight. |
122 | | - * |
| 122 | + * |
123 | 123 | * Returns a boolean on whether we did some splitting successfully at a text point |
124 | 124 | * (so we know we don't need to split a real element). return false if the caller should |
125 | 125 | * split a node if possible to end this column. |
|
207 | 207 | } |
208 | 208 |
|
209 | 209 | /** |
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 |
211 | 211 | * two copies of the element with it's contents divided between each |
212 | 212 | */ |
213 | 213 | function split($putInHere, $pullOutHere, $parentColumn, targetHeight){ |
|
258 | 258 | }else if($clone.is("img") || $cloneMe.hasClass(prefixTheClassName("dontsplit"))){ |
259 | 259 | // |
260 | 260 | // 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 |
262 | 262 | // next column |
263 | 263 | $clone.remove(); |
264 | 264 | }else{ |
|
375 | 375 | function columnizeIt() { |
376 | 376 | //reset adjustment var |
377 | 377 | adjustment = 0; |
378 | | - if(lastWidth == $inBox.width()) return; |
379 | | - lastWidth = $inBox.width(); |
| 378 | + if(lastWidth == $inBox.outerWidth()) return; |
| 379 | + lastWidth = $inBox.outerWidth(); |
380 | 380 |
|
381 | | - var numCols = Math.round($inBox.width() / options.width); |
| 381 | + var numCols = Math.round($inBox.outerWidth() / options.width); |
382 | 382 | var optionWidth = options.width; |
383 | 383 | var optionHeight = options.height; |
384 | 384 | if(options.columns) numCols = options.columns; |
|
418 | 418 | } |
419 | 419 |
|
420 | 420 | // |
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 |
422 | 422 | // but if the last column is higher than the first ones (which can happen, depending on split |
423 | 423 | // points) we need to raise 'adjustment'. We try this over a few iterations until we're 'solid'. |
424 | 424 | // |
|
590 | 590 | $col.removeClass(prefixTheClassName("last")); |
591 | 591 | } |
592 | 592 | }); |
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"); |
594 | 604 | } |
595 | 605 | $inBox.append($("<br style='clear:both;'>")); |
596 | 606 | } |
|
0 commit comments