Search code examples
javascripthtmlcssslimscroll

two slimscrolls stacked doesn't seem to work


When slimscroll initialisation code is commented out, it works as it should - scrollbars are visible. When slimscroll initialised, it should basically be the same, except native scrollbars should be slimscroll's, but now it just breaks everything. A fiddle http://jsfiddle.net/xyvo4r0a/3.

<div class="slimScroll" style="overflow-y:auto;height:200px;width:250px">
    <div class="child-height-1" style="height:50%;overflow-y:auto">
        <div class="child-content" style="height:300px;background-color:lightgreen">asd</div>
    </div>
    <div class="child-height-2" style="height:50%;overflow-y:auto">
        <div class="child-content" style="height:300px;background-color:lightyellow">asd</div>
    </div>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/slim-scroll/1.3.2/slimscroll.min.js"></script>
<script>
    $(function () {
        //new slimScroll($('.child-height-1')[0]);
        //new slimScroll($('.child-height-2')[0]);
    });
</script>

Solution

  • Try it with this:

    <div class="child-height-1" style="height:50%; overflow: hidden; position: relative;">
    

    Fiddle: http://jsfiddle.net/c8d3ohue/