JQuery jScrollPane reinitialise

Mantisimo picture Mantisimo · Jan 22, 2011 · Viewed 12k times · Source

I'm using the JQuery plugin jScrollPane

I'm intialising it as follows.. It works initially but when I try and change the settings and reinitialise it it doesnt work properly it kindof flickers and then returns to it's previous state, any ideas?

$(document).ready(function() {
     var api = $('.viewer').jScrollPane().data('jsp');
     api.reinitialise({
         showArrows: true
     }); 
});

Here is my test example

http://www.jsfiddle.net/VxYdJ/

Thanks

Answer

martin picture martin · Dec 19, 2011

i had the same problems with the reinitialisation of jsp. i could solve it with this workaround.

destroy …

$("#some > img").click(function() {
    var container = $('.scroll-pane-arrows');
    var api = container.data('jsp');
        api.destroy();

   … calculate width or similar

… and build it up later on:

$('.scroll-pane-arrows').jScrollPane({
    showArrows: true,
    arrowScrollOnHover: true,
    arrowButtonSpeed: 5,
    autoReinitialise: true
});