鼠标滚轮事件

// 绑定滚轮事件
//chrome ie
document.addEventListener('mousewheel', scrollMove);
//firefox
document.addEventListener('DOMMouseScroll', scrollMove);

/*
* 实现滚轮滚动触发的函数
* 事件防抖
* */
var timeId = null;
function scrollMove(event) {
//如果上次定时没有结束,清除
clearTimeout(timeId);
//延迟执行
timeId = setTimeout(function () {
//判断是往上滚动还是往下滚动
var tag = null; //标记滚轮往上滚还是往下滚
if (event.wheelDelta) { //chrome ie
if (event.wheelDelta > 0) {
tag = 'up';
} else {
tag = 'down';
}
} else if (event.detail) { //firefox
if (event.detail > 0) {
tag = 'down';
} else {
tag = 'up';
}
   }
}
}, 300);

}
原文地址:https://www.cnblogs.com/wangsai-666/p/11977643.html