Skip to content

@dennishall /columnize.js
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Simple columnize javascript function
function columnize(ul){
var offsetTop = YAHOO.util.Dom.getRegion(ul).top;
var listItems = ul.getElementsByTagName('li');
for(var i=0,l=listItems.length;i<l;i++){
var region = YAHOO.util.Dom.getRegion(listItems[i]);
if(region.bottom - offsetTop > 200){
var clone = ul.cloneNode(true);
// remove all list items that follow this one from the current list. (will be covered by the clone)
for(var j=l-1; j>=i; j--){
ul.removeChild( ul.lastChild );
}
// remove all list items that precede this one from the clone. (are covered by the original list)
for(var j=i; j>0; j--){
clone.removeChild(clone.firstChild);
}
ul.parentNode.appendChild(clone);
// recurse - check whether the clone also needs to be columnized (if it's too tall)
columnize(clone);
return;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.