Skip to content
Create a gist now

Instantly share code, notes, and snippets.

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--){
// recurse - check whether the clone also needs to be columnized (if it's too tall)
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.