delta的值是負的即-1,那麼滾輪就是向下滾動,正的1就是向上。
插件方法:
1.爲了監聽滾輪事件,該插件引入了mousewheel事件,所以我們可以監聽元素的mousewheel事件
2.該插件還提供了元素快捷方法mousewheel和
unmousewheel用於監聽和去掉元素對鼠標滾輪事件支持
$(document)
.mousewheel(function(event, delta) {
loghandle(event, delta);
}); //頁面中滾動
$('#test6')
.mousewheel(function(event, delta) {
loghandle(event, delta);
event.stopPropagation();
event.preventDefault();
}); //元素中滾動,且頁面不滾動
插件地址:https://github.com/brandonaaron/jquery-mousewheel