function mousewheelHandler(e){
var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail)));
console.log(delta > 0 ? "向上滚动" : "向下滚动");
}
//for Firefox
document.addEventListener("DOMMouseScroll", mousewheelHandler, false);
//for Chrome Safari
document.addEventListener("mousewheel", mousewheelHandler, false);
时间: 2024-10-06 03:15:15