封装滚动函数
function addEvent(obj,sEv,fn){
if(obj.addEventListener){
obj.addEventListener(sEv,fn,false)
}else{
obj.attactEvent(‘on‘+sEv,fn)
}
}
function addWheel(obj,fn){
function wheel(ev){
var oEvent=ev || event ;
var bDown=true ; //默认向下
bDown = oEvent.wheelDelta ? oEvent.wheelDelta < 0 : oEvent.detail >0 ; //oEvent.detail>0 向下---->firefox
fn && fn(bDown)
oEvent.preventDefault && oEvent.preventDefault() ;
return false ;
}
if(window.navigator.userAgent.toLowerCase().indexOf(‘firefox‘) !=-1){
addEventListener(‘DOMMouseScroll‘,wheel,false)
}else{
addEvent(obj,‘mousewheel‘,wheel,)
}
}
window.onscroll=fn;
$(‘选择器‘).scroll(fn);
link:http://www.cnblogs.com/yuteng/articles/1894578.html
link:http://www.cnblogs.com/xiaohuochai/p/5831640.html
link: https://www.w3cmm.com/javascript/mousewheel-dommousescroll.html
插件:http://www.jq22.com/jquery-info357