How to create a button with the Custom Scrollbar plugin?

Asked

Viewed 201 times

-1

Custom Scrollbar

My idea is to create only one button. When you click it it is activated and with the automatic scroll working, when you click again it is disabled and disables the automatic scroll.

  • 1

    Could you give more details?

1 answer

1

Create custom scroll for a div:

$(".content"). mCustomScrollbar({ scrollInertia:150 });

Remove custom scroll from a div:

$('#remove-scroll').click(function(e){
    e.preventDefault();
    $(".content").mCustomScrollbar("destroy");
});

Add the custom scroll

$("#adiciona-scroll").click(function(e){
    e.preventDefault();
    $(".content").mCustomScrollbar("update");
});

Re-create the custom scroll

$("#recria-scroll").click(function(e){
    e.preventDefault();
    $(".content").mCustomScrollbar({
        scrollButtons:{
            enable:true
        }
    });
});
  • It got a little confusing @Victormendoça. I created a JSFIDDLE and imported the css and js file from Custom Scrollbar, try editing it with your logic? http://jsfiddle.net/jeffersonalison/4FTcU/1/

  • I made a fiddle, but it seems that their source site has a small bug in the Java load. http://jsfiddle.net/vmendonca/CbfzT/ Have a look at their page about removing/adding Scrolls: http://manos.malihu.gr/tuts/custom-scrollbar-plugin/disable_destroy_example.html - I recommend you download the plugin on your machine and test it with the code I passed you ;]

  • Um.. worst that seems to be in even trouble. But Victor my idea is to create just a boot.. then when it is activated the automatic scroll works, otherwise it is activated it does not work.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.