通过滚动条/鼠标滚轮区分滚动

时间:2012-02-07 19:24:41

标签: javascript jquery html scroll web

有没有办法区分页面是基于鼠标滚轮滚动还是拖动滚动条?我需要对两者采取不同的行动。

2 个答案:

答案 0 :(得分:0)

使用mousewheel事件,该事件将在使用鼠标滚轮从here滚动页面时触发。

答案 1 :(得分:0)

看起来有一些现有的插件可以处理鼠标滚轮事件:

https://github.com/brandonaaron/jquery-mousewheel

这些事件采用现有的onmousewheel事件并使它们跨浏览器,但我认为最近版本的jQuery可能已经使用mousewheel事件执行此操作:

$('#myselector').bind('mousewheel', function() { } );