zoukankan      html  css  js  c++  java
  • 滚轮滚动事件

    封装滚动函数

    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

  • 相关阅读:
    02动手动脑
    动手动脑01
    千锤百炼软工6,7,8
    千锤百炼软工10.5
    千锤百炼软工10.4
    千锤百炼软工10.3
    千锤百炼软工10.2
    千锤百炼软工10.1
    千锤百炼软工9.30
    破解 webstorm
  • 原文地址:https://www.cnblogs.com/xshaohua-com/p/6703366.html
Copyright © 2011-2022 走看看