rochal / jQuery-slimScroll

small jQuery plugin that transforms any div into a scrollable area with a nice scrollbar. Demo and more:
http://rocha.la/jQuery-slimScroll
2.23k stars 929 forks source link

Animation in scrollTo #91

Open sheillendra opened 10 years ago

sheillendra commented 10 years ago

Is it possible to animate in scrollTo??

ghost commented 10 years ago

Here is my little hack to create an animated smoothTo scroll:

if (isJump)
          {
            delta = y;
            var offsetTop = delta / me[0].scrollHeight * me.outerHeight();
            offsetTop = Math.min(Math.max(offsetTop, 0), maxTop);
            bar.css({ top: offsetTop + 'px' });
            // tony's custom animation tweak
            me.animate(
              { scrollTop: delta + 'px' },
              1200
            );
          }
          if (!isJump){
          // scroll content
          // tony's custom animation tweak
            me.scrollTop(delta);
          }