如何在窗口滚动移动功能中实现 JQuery 缓动?
通过这段代码,我已经能够捕获鼠标滚轮的移动并将其应用于水平滚动条而不是垂直默认滚动条。
$('html').bind('mousewheel', function(event, delta) {
window.parent.scrollBy(-120 * delta, 0);
return false;
});
有什么方法可以将这个 jQuery 缓动动画添加到滚动运动中吗?
// 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;
}
});
提前非常感谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你需要的是scrollTo插件。似乎符合要求,虽然我个人没有使用过。基本上应该能够像这样调用它,
在这里找到插件演示。 jquery 插件站点目前似乎处于离线状态,但是当其备份时,可以在 此处
i think what you need is the scrollTo plugin. seems to fit the bill, though i haven't used it personally. basically should be able to call it like this
find the plugin demo here. the jquery plugin site appears to be offline currently, but when its back up, the plugin can be found here