user-a5567ffg
user-a5567ffg

Reputation: 225

mCustomScrollbar - scrollbar only appearing on F12 press (dev tools / Firebug) and not on hidden elements/divs

Having a weird problem with mCustomScrollbar - Similar problem here:

stubborn prolem with popular custom scrollbar

The scrollbar doesn't show until you re-size the window or hit F12 (tested on both IE9 and FF - so Developer and Firebug). As soon as you do either, the code kicks in. The elements are initially hidden, and shown either using .show() or .fadeIn()

CSS:

.info-text {
    width: 230px;
    height: 170px;
    overflow: hidden;
    display: block;
}

HTML:

<p class = "info-text">
Lorem...
</p>

JS:

$(".info-text").mCustomScrollbar();

The JS is held within a $(window).load(function(){...

Upvotes: 3

Views: 6501

Answers (2)

user-a5567ffg
user-a5567ffg

Reputation: 225

Solved it. The reason that it wasn't firing was because I was trying to add the functionality onto a div that wasn't initially visible, and subsequently brought in using .fadeIn(). For some reason it doesn't like that. I had to use:

.mCustomScrollbar('update');    

to bring in the scrollbar after the element was visible. So in my case it was:

$("#elementFadingIn").fadeIn(500, function() {

    $("#elementFadingIn .scrollableElement").mCustomScrollbar('update');

});

Then it worked.

Upvotes: 1

Stormsson
Stormsson

Reputation: 1551

you could try ,at init time, to use the property

advanced:{  
    updateOnContentResize:true,   
    updateOnBrowserResize:true
  } 

so you should have something similar to:

$(".info-text").mCustomScrollbar({
   advanced:{  
    updateOnContentResize:true,   
    updateOnBrowserResize:true   

  } 
});

Upvotes: 5

Related Questions