Skip to content

Commit 137151b

Browse files
committed
fixes issue 55, where the lastnevertallest is not always respected
1 parent a0efd88 commit 137151b

File tree

3 files changed

+71
-5
lines changed

3 files changed

+71
-5
lines changed

samples/issue_55.html

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
4+
<head>
5+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
6+
<link href="css/styles.css" rel="stylesheet" type="text/css" />
7+
<title>Mod Menu</title>
8+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
9+
<script src="../src/jquery.columnizer.js" type="text/javascript" charset="utf-8"></script>
10+
<script type="text/javascript">
11+
$(window).load(function() {
12+
$('.menu-content').columnize({ columns: 2, lastNeverTallest: true });
13+
})
14+
</script>
15+
</head>
16+
17+
<body>
18+
19+
<div class="menu-page">
20+
<div class="menu-content">
21+
<div class="dontsplit" style="background-color: #CCC; height: 233px;">
22+
</div>
23+
<div class="dontsplit" style="background-color: #EEE; height: 220px;">
24+
</div>
25+
<div class="dontsplit" style="background-color: #CCC; height: 266px;">
26+
</div>
27+
</div>
28+
</div>
29+
30+
</body>
31+
32+
</html>

samples/issue_55_2.html

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
4+
<head>
5+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
6+
<link href="css/styles.css" rel="stylesheet" type="text/css" />
7+
<title>Mod Menu</title>
8+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
9+
<script src="../src/jquery.columnizer.js" type="text/javascript" charset="utf-8"></script>
10+
<script type="text/javascript">
11+
$(window).load(function() {
12+
$('.menu-content').columnize({ columns: 2, lastNeverTallest: true });
13+
})
14+
</script>
15+
</head>
16+
17+
<body>
18+
19+
<div class="menu-page">
20+
<div class="menu-content">
21+
<div class="dontsplit" style="background-color: #EEE; height: 220px;">
22+
</div>
23+
<div class="dontsplit" style="background-color: #CCC; height: 266px;">
24+
</div>
25+
</div>
26+
</div>
27+
28+
</body>
29+
30+
</html>

src/jquery.columnizer.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,11 @@
428428
// We loop as we try and workout a good height to use. We know it initially as an average
429429
// but if the last column is higher than the first ones (which can happen, depending on split
430430
// points) we need to raise 'adjustment'. We try this over a few iterations until we're 'solid'.
431-
for(var loopCount=0;loopCount<maxLoops;loopCount++){
431+
//
432+
// also, lets hard code the max loops to 20. that's /a lot/ of loops for columnizer,
433+
// and should keep run aways in check. if somehow someone has content combined with
434+
// options that would cause an infinite loop, then this'll definitely stop it.
435+
for(var loopCount=0;loopCount<maxLoops && maxLoops < 20;loopCount++){
432436
$inBox.empty();
433437
var $destroyable;
434438
try{
@@ -561,12 +565,12 @@
561565
// so allow columns to be taller
562566
// and retry
563567
adjustment += 30;
564-
if(adjustment < 100){
568+
// if(adjustment < 100){
565569
targetHeight = targetHeight + 30;
566570
if(loopCount == maxLoops-1) maxLoops++;
567-
}else{
568-
loopCount = maxLoops;
569-
}
571+
// }else{
572+
// loopCount = maxLoops;
573+
// }
570574
}else if(max - min > 30){
571575
// too much variation, try again
572576
targetHeight = avgH + 30;

0 commit comments

Comments
 (0)