4

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

2 Answers 2

6

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

3
  • I know this is too old, but I wanted to know if we can detect the direction of scroll (scroll to top or to down ) ?
    – pietà
    Commented Jan 3, 2018 at 16:39
  • 1
    @pietà This isn't something that SlimScroll offers but I've made one for you on Codepen codepen.io/stylish/pen/KZXeJG?editors=0010 Make sure you open your console (alt + cmd + j) Regards
    – ZAD
    Commented Jan 5, 2018 at 11:40
  • Awesome, Thanks a lot :)
    – pietà
    Commented Jan 8, 2018 at 7:21
0

UPDATE:-

For those of you that asked me either privately or here on how you could possibly track the SlimScroll's scroll direction (UP or DOWN)!

The bad news is this isn't something that SlimScroll offers as of yet, however on the other side, the good news is I've been able to put together a little snippet that does the job for you!

[Codepen](https://codepen.io/stylish/pen/KZXeJG?editors=0011)

Hope it helps :) Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.