function wheelFun(element,up,down){
element.onmousewheel = fn;
if (window.addEventListener) {
element.addEventListener("DOMMouseScroll",fn, false);
}
function fn(event){
var event = event || window.event;
if (event.wheelDelta > 0 || event.detail < 0) {
up();
} else{
down();
}
}
}
wheelFun(document,function(){
console.log(1);
},function(){
console.log(2);
});
时间: 2024-10-13 01:46:12