首页 新闻 会员 周边

如何设置鼠标滚轮使其无论滚动幅度大小只相当于滚动一次

0
悬赏园豆:50 [已解决问题] 解决于 2013-06-01 09:05
$("#content").bind('mousewheel', function(event, delta) {
    if (delta > 0){
        keydown();
        }else if (delta < 0){
            keyup();
            }
    return false;
});

如題,有引用jquery.mousewheel.js

如果滾動太大就會多次keyup,但是只希望執行一次

css design的主页 css design | 菜鸟二级 | 园豆:215
提问于:2013-01-24 12:17
< >
分享
最佳答案
1

这个可以用setTimeout来延时执行,比如100毫秒,如果在这时间内又有mousewheel发生就取消上次的setTimeout。

$("#content").bind('mousewheel', function(event, delta) {
    var $this = $(this),
        timeoutId = $this.data('timeoutId');
    if (timeoutId) {
        clearTimeout(timeoutId);
    }
    $this.data('timeoutId', setTimeout(function() {
        //do something
        $this.removeData('timeoutId');
        $this = null
    }, 100));
    return false;
});

 

额,四个月前的事情了。。。

收获园豆:50
Arliang | 菜鸟二级 |园豆:360 | 2013-05-30 21:11

感谢了呵呵

css design | 园豆:215 (菜鸟二级) | 2013-06-01 09:06
其他回答(2)
0

这个不好控制。

chenping2008 | 园豆:9836 (大侠五级) | 2013-01-24 13:02
0

这个做不了。。。

allon6318 | 园豆:858 (小虾三级) | 2013-01-24 17:31
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册