Skip to content

Commit

Permalink
only calcs width when necessary
Browse files Browse the repository at this point in the history
dont recalc width for every "priority" unless num columns hidden is different from last attempt. Saves computation especially because default priority =99!
  • Loading branch information
Jon Apgar committed Jul 6, 2014
1 parent e2e5207 commit 619458f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions jquery.magiccolumns.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@

if (!lastpriority)
return;

while (lastpriority > 0 && ($(table).outerWidth() > $(table).parent().width())) {


var numHidden = 0;
var numHidden = 0;
var lastNumHidden=-1;
while (lastpriority > 0 && (numHidden == lastNumHidden || ($(table).outerWidth() > $(table).parent().width()))) {

lastNumHidden = numHidden;

$(table).find('th').each(function() {
if ($(this).data('priority') == lastpriority) {
$(this).css({display: 'none'});
Expand All @@ -106,7 +108,7 @@
numHidden++;
}
});

// walk down priority in case we're still too large
lastpriority -= 1;

Expand Down

0 comments on commit 619458f

Please sign in to comment.