我是靠谱客的博主 拉长雪碧,这篇文章主要介绍mousewheel,DOMMouseScroll判断滚轮滚动方向,现在分享给大家,希望可以做个参考。

firefox使用DOMMouseScroll,其他浏览器使用mousewheel

首先绑定一个滚动事件

//firefox使用DOMMouseScroll,其他浏览器使用mousewheel
$(document).bind('mousewheel DOMMouseScroll',mouseScroll);

当滚动时获取wheelDelta值,firefox使用detail:值为下滚3上滚-3,其他浏览器使用wheelDelta:值为下滚-120上滚120,通过判断其值为正或者负即可判断鼠标滚轮上滚还是下滚

function fullscreenScroll(e){
    var delta = -e.originalEvent.wheelDelta || e.originalEvent.detail;//firefox使用detail:下3上-3,其他浏览器使用wheelDelta:下-120上120//下滚
    if(delta>0){
        console.log('下滚');
    }
    //上滚
    if(delta<0){
        console.log('上滚');
    }
}

 

转载于:https://www.cnblogs.com/gxsyj/p/5946729.html

最后

以上就是拉长雪碧最近收集整理的关于mousewheel,DOMMouseScroll判断滚轮滚动方向的全部内容,更多相关mousewheel内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(127)

评论列表共有 0 条评论

立即
投稿
返回
顶部