jQuery-slimScroll
jQuery-slimScroll copied to clipboard
How to automatically scroll down
I use setInterval and waiting ajax response.
setInterval(function(){
var timestamp = (new Date()).valueOf();
$.getJSON("/panel/update_log_list/timestamp/"+timestamp, function(json){
$('#noty_bottom_layout_container').remove();
$.each(json, function(key, value) {
$('#dashboard_log_list').append(
"<li><span class=\"green\">["+value.timestamp+"]</span>"+
"<span style=\"color:#305f9c\">["+value.program+"]</span>"+
"<span style=\"color:#333333\">["+value.host[1]+"]</span>["+
value.syslog_severity+"]["+value.message+"]</li>"
);
});
$('.sscroll').slimscroll({
start: 'bottom',
});
});
}, 1000);
when append
$('.sscroll').slimscroll({
start: 'bottom',
});
// append your html
// then calculate the new scroll height
var bottomCoord = $('.sscroll')[0].scrollHeight;
$('.sscroll').slimScroll({scrollTo: bottomCoord});
thanks @elisechant