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

  • 相关阅读:
    每周总结03
    Servlet2
    每周总结02
    周总结4
    河北省重大需求征集系统每日进度6
    周总结3
    hadoop命令
    复习uml
    周总结2
    河北省重大需求征集系统每日进度5
  • 原文地址:https://www.cnblogs.com/xshaohua-com/p/6703366.html
Copyright © 2011-2022 走看看