SlimScroll destroy does not unbind scroll events

I am using the slimScroll jQuery plugin and it seems that the destroy option is not completely destroying the plugin effect on the site.

For example, if you try to destroy a plugin and then scroll through previously scrolled content, the site scrolling feature will stop working. You will be able to scroll using the scroll bar rather than using the mouse / trackpad wheel.

The error reproduces here

Note a few things:

  • Scrolling with the mouse wheel / trackpad over a previously scrolled element blocks scrolling.
  • Scrolling outside of a previously scrolled element works as expected.
  • If you scroll the slimScroll to the very bottom level before destroying it, when destroying it, it works fine, as it should anyway.

I've already reported this in the repository , but there are no answers. It seems to be abandoned. I have tried various suggested solutions , but none of them work as expected.

The lack of a proper method to destroy the plugin seems to be a problem ...

Used code in jsfiddle:

$('.scrollable').slimScroll({
    allowPageScroll: true,
    height: '250px',
    size: '10px',
    alwaysVisible: true
});

$('.destroy').click(function(){
    $('.scrollable').slimScroll({
        destroy:true
    });
});

      

+3


source to share


1 answer


The problem is that the plugin does not remove registered events. This should fix the problem:



$('.destroy').click(function(){
    $('.scrollable').slimScroll({
        destroy:true
    });

    var $elem = $('.scrollable'),
    events = jQuery._data( $elem[0], "events" );

    if (events) {
        jQuery._removeData( $elem[0], "events" );
    }

});

      

+8


source







All Articles