I used slimScroll on my web page with the content is added by AJAX.
If I scroll down the scroll then reload with more content (AJAX load), the scroll bar itself always keep its position the same as before.
I wonder if the slimScroll has any function that I can call to scroll to top after loading the new content?
I don't think the scroll option described by @rochal is going to work right now, as it doesn't appear to be used by the version currently up on GitHub. Instead try scrollTo or scrollBy.
To scroll to the top:
$('#elem_id').slimScroll({ scrollTo : '0px' });
Conversely, if you want to scroll to the bottom, then the following should work:
var scrollTo_val = $('#elem_id').prop('scrollHeight') + 'px';
$('#elem_id').slimScroll({ scrollTo : scrollTo_val });
Since version 1.0.0 if you need to scroll to the top you can use build in scrollTo method:
$(element).slimScroll({ scrollTo: '0' });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With