8

With this code I've been able to capture the mousewheel movement and apply it to the horizontal scroll bars instead of the vertical default.

$('html').bind('mousewheel', function(event, delta) {
   window.parent.scrollBy(-120 * delta, 0);
   return false;
});

Is there any way that I could add this jQuery easing animation to the scroll movement?

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.extend( jQuery.easing, {
   easeInOutBack: function (x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158; 
        if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
        return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
   }
});

Thank you so much in advance!

4

1 回答 1

1

我认为您需要的是 scrollTo 插件。似乎符合要求,虽然我没有亲自使用过。基本上应该可以这样称呼

$.scrollTo( -120*delta, {duration:1000,easing:'easeInOutBack',axis:'x'} )

在这里找到插件演示。jquery 插件站点目前似乎处于脱机状态,但是当它备份时,可以在此处找到该插件

于 2010-06-02T06:10:00.050 回答