I'm using the SlimScroll plugin for my website.
I would like to reset/restart the slimscroll function on window resize, because the height and width should be changed according to the height and width of the #content_wrapper div.
I tried it trough several ways but nothing seemed to do the trick. Below my current code. Does anyone know how I can achieve this?
$('#content_wrapper').slimScroll({
width: $('#content_wrapper').css({'width':(($(window).width())-240)+'px'}),
height: $('#content_wrapper').css({'height':(($(window).height())-65)+'px'})
});
// scrollbar onresize resetten
$(window).resize(function(){
$('#content_wrapper').slimScroll({
width: $('#content_wrapper').css({'width':(($(window).width())-240)+'px'}),
height: $('#content_wrapper').css({'height':(($(window).height())-65)+'px'})
});
});
Just ran into this problem today and this works for me: when initializing slimScroll, it adds a div with class "slimScrollDiv". You can alter the height of this div and set it the same as your wrapper div...
$(document).ready(function(){
$('#scrollDiv').slimScroll({
height: 'auto'
});
$(window).resize(function(){
var h=$(window).height()-250;
$('#scrollDiv').height(h);
$('.slimScrollDiv').height(h);
});
});
For version 0.5.0, replace the following:
// set up initial height
getBarHeight();
with:
$(window).resize(function() {
getBarHeight();
showBar();
});
I found this on http://dt.infolearn.com.gr/2012/03/jquery-slimscroll-refresh-on-window-resize/ and it worked for me.
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