平滑水平滚动绑定到鼠标滚轮 [英] Smooth horizontal scroll bound to mousewheel

查看:94
本文介绍了平滑水平滚动绑定到鼠标滚轮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是带鼠标滚轮的水平滚动的工作示例,但不能平滑滚动。顺便说一句,我的意思是像Firefox或Opera中的普通垂直滚动一样。

Here is a working example of horizontal scroll with mousewheel, but it does not scroll smoothly. By smoothly I mean like ordinary vertical scroll in Firefox or Opera.

$(function() {
    $("html, body").mousewheel(function(event, delta) {
        this.scrollLeft -= (delta * 30);
        event.preventDefault();
    });
});

http://brandonaaron.net/code/mousewheel/docs

我做了一个现场演示来演示这个。
http://jsfiddle.net/Dw4Aj/

I've made a live demo to demonstrate this. http://jsfiddle.net/Dw4Aj/

我希望这个滚动像垂直滚动一样工作,都有鼠标滚轮和光滑度。

I want this scroll to work like the vertical one, both with mousewheel and smoothness.

有人能帮帮我吗?

推荐答案

我只想把它留在这里。

http://jsfiddle.net/Dw4Aj/19/

jQuery(document).ready(function($) {
$("html, body").mousewheel(function(e, delta) { 
    $('html, body').stop().animate({scrollLeft: '-='+(150*delta)+'px' }, 200, 'easeOutQuint');
    e.preventDefault();
});

});

这篇关于平滑水平滚动绑定到鼠标滚轮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆