鼠標滾輪插件jQuery mousewheel

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
發佈了74 篇原創文章 · 獲贊 43 · 訪問量 24萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章