cubiq / iscroll

Smooth scrolling for the web
http://iscrolljs.com
MIT License
12.87k stars 3.81k forks source link

Bounce not working with mouse scroll #944

Open Vee232 opened 9 years ago

Vee232 commented 9 years ago

I am trying to incorporate the bounce effect with the mouse wheel, so that it will work on mobile and desktop, but it's just not working. Here is the code:

    function loaded () {
myScroll = new IScroll('#wrapper', {
    bounce: true,
    scrollbars: true,
    mouseWheel: true,
    interactiveScrollbars: true,
    shrinkScrollbars: 'scale',
    fadeScrollbars: true

  });
      }

I hope someone can help me out with this.

hammtronic commented 9 years ago

Hey, I had the same problem today, and I've managed to solve this problem for now by adding the following two lines of code at the scrollTo function in the code.

scrollTo: function (x, y, time, easing) {
        if(!time)time=600;                             
        easing = easing || utils.ease.back;
        ...

I found that time seems to be equal to 600 when the scroller bounces from other inputs, so we set that to avoid falling into the if(!time) condition a few lines down, and we change the default for easing to back which makes the bounce animation, whereas circular just slows it down.

Hope that works for you too.

Vee232 commented 9 years ago

Thanks so much for the reply, but all it did was make my scrolling super slow.

Sjael commented 8 years ago

Is this to be fixed soon?

matthew-dean commented 7 years ago

I couldn't seem to completely remove jitter, when scrolling with a Magic Trackpad up and down rapidly, but bounce support works with the latest PR. Maybe @cubiq has some ideas about how to smooth it out. I think the animation needs to be tweened between updated "overscroll".