js判断鼠标上下滚动及停止滚动

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="" content="">
  <title></title>
  <style>
  </style>
</head>

<body>
  <p>ok</p>

  <script>
   
 var moveWheel1 = true;
    var moveWheel2 = false;
    var wheelClock;
    function stopWheel(){
        if(moveWheel2 == true){
            console.log("滚轮停止了");
            moveWheel2 = false;
            moveWheel1 = true;
        }
    }
    function moveWheel(e){
      var e = e || window.event;
        if(moveWheel1==true){
          if(e.wheelDelta){
            if(e.wheelDelta > 0) {
              console.log("鼠标滚轮向上滚动")
            };
            if(e.wheelDelta < 0){
              console.log("鼠标滚轮向下滚动")
            }
          }
            moveWheel1 = false;
            moveWheel2 = true;
            wheelClock = setTimeout(stopWheel,200);
        }
        else {
            clearTimeout(wheelClock);
            wheelClock = setTimeout(stopWheel,150);
        }
      }
      document.addEventListener(wheel, moveWheel, false);
  </script>
</body>

</html>

 

js判断鼠标上下滚动及停止滚动

上一篇:webservice客户端连接方式


下一篇:数据库mysql之视图的删除