Automattic / antiscroll

OS X Lion style cross-browser native scrolling on the web that gets out of the way.
1.07k stars 162 forks source link

Add a rebuild() method #3

Closed bpierre closed 12 years ago

bpierre commented 12 years ago

Useful for containers without explicit dimensions, e.g. :

$(window).resize(function(){
    $myElement.data('antiscroll').rebuild();
});
bpierre commented 12 years ago

I forgot to precise that I call the constructor as a function, but the CSS / Scrollbars part of the constructor could be moved in another method.

rauchg commented 12 years ago

Is there a reason we need to cache the styles of inner ?

bpierre commented 12 years ago

It’s a precaution, in order to reset the styles to their previous values before calling the Antiscroll constructor.

If we replace it with inner.attr('style', ''):

var containers = $('.container');
containers.find('.antiscroll-inner').css('background', 'red'); // The background is red
containers.antiscroll();
containers.each(function(){
  $(this).data('antiscroll').rebuild(); // The red background is removed
});

But if we assume that:

I think it’s relatively safe to remove it. I will add another commit.