jamesflorentino / nanoScrollerJS

A jQuery plugin that offers a simplistic way of implementing Lion OS scrollbars.
http://jamesflorentino.github.com/nanoScrollerJS/
MIT License
2.69k stars 504 forks source link

How to reinitialize nanoScroller when its container is display:none #305

Open topasi opened 9 years ago

topasi commented 9 years ago

Thanks for the great plugin.

I am using this plugin now to my project, and I am also using bootstrap modal by default the modal is in hidden state (display:none) and appears when you toggle it. I used nanoScroller on the modal. The problem is why the slider wont appear.

what I found is when I resizing the browser or press F12, anything that changes the behavior of the screen the slider appears.

kristerkari commented 9 years ago

You have to have your element shown before re-initializing nanoscroller. That's because it will need to know the height of the element.

topasi commented 9 years ago

That's exactly my problem. I tried re-initialize the nanoScroller

$('#myModal').on('shown.bs.modal', function () { $('.nano').nanoScroller(); });

but wont work either.

kristerkari commented 9 years ago

Maybe the element isn't still fully shown when 'shown.bs.modal' event fires?

Does this make any difference:

$('#myModal').on('shown.bs.modal', function () {
  setTimeout(function() {
    $('.nano').nanoScroller();
  }, 0);
});
onvno commented 8 years ago

@kristerkari This problem i just met.try this:

$('#myModal'').mouseover(function(){ $('.nano').nanoScroller(); })