javascriptjqueryslimscroll

How to listen for Slimscroll "scroll" event?


Basically I want to run some stuff whenever the user scrolls... how could I possibly do that?

I already know about this event which I found on SlimScroll website, but there is no other events other than this one;

//...

var $scrollable = $('.scrollable');

$scrollable.slimScroll().bind('slimscroll', function (e, pos) {
    // SOME CODE...
});

//...

But this only works when the scrollbar reaches either top or bottom of the scrollable section.

The scrollbar itself works fine, just need an event listener!

Thank you


Solution

  • OK, after looking into the slimscroll unminified version I spotted this "slimscrolling" event listener, so I simply replaced this with "slimscroll" and things worked as I wanted!

    So simply run this code;

    //...
    
    var $scrollable = $('.scrollable');
    
    $scrollable.slimScroll().bind('slimscrolling', function (e, pos) {
        // SOME CODE...
    });
    
    //...
    

    Hope this saves your time as I spent ages figuring this out :) Thanks