Sanjeev K Sanjeev K - 2 months ago 17
CSS Question

Custom Scrollbar - Fix scroller position to bottom

I have customized the scroll to custom scroll using this plugin

I am trying to keep the position of the scroll to the bottom on load.

Here is the JSfiddle working demo



var container1 = $('#container1');
var container2 = $('#container2');

for (var i = 0; i < 500; i++) {
container1.append("<p>"+i+"</p>");
}

for (var i = 0; i < 500; i++) {
container2.append("<p>"+i+"</p>");
}

$('#container1').mCustomScrollbar({
theme:"dark-3"
});

$('#container2').mCustomScrollbar({
theme:"dark-3"
});

//$("#selector_that_matches_zero_elements").mCustomScrollbar("destroy");

#container1,#container2 {
height:200px;
width:100px;
padding:5px;
border:1px solid black;
}

.mCSB_draggerRail{width:20px;}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="http://malihu.github.io/custom-scrollbar/3.0.0/jquery.mCustomScrollbar.min.css" rel="stylesheet"/>
<script src="http://malihu.github.io/custom-scrollbar/3.0.0/jquery.mCustomScrollbar.concat.min.js"></script>

<div id="container1"></div>
<div id="container2"></div>




Answer

Try this code.

$(".xxxxxxxx").mCustomScrollbar("scrollTo","bottom");
Comments