wmh/jquery-scrollbox

Ability to remove/stop function, or alter the distance property?

Closed this issue · 2 comments

Hello,

I'm trying to alter the distance property when the page resizes down to mobile dimensions and my gallery of image is resized a little. I have some code that calls the following scrollbox initialisation function whenever the page resizes:

    $(function () {
        $('#site-menu').scrollbox({
            direction: 'h', // vertical or horizontal
            distance: 170 // the distance between items
        });
    });

However this is leading to multiple instances of the function being attached to the #site-menu element as I keep resizing the page. How can I remove the previous instance, or better yet how can I update the distance value?

Hope you can help!

wmh commented

You can try to remove the distance property when you initialize the plugin. If that is not work, a new custom function to set the property is required.

I've been looking through previous issues raised, and found that someone also wanted to change the config when altering the page size, and wrote a method for doing so which you added:

#13

// in client side javascript 
$(self.scrollContainer).trigger('updateConfig', [{
                switchItems: switchItems
 }]);

// in jquery.scrollbox
container.bind('updateConfig', function (event,options) {
   config = $.extend(config, options);
});

I have now written this:

$('#gallery').trigger('updateConfig', [{
    distance: 170
}]);

This is triggering the updateConfig piece of code, but the altered distance value is not being updated - using console.log(config.distance) before and after the config = $.extend(config, options); line I can see the value has not changed.

Where am I going wrong?