mousewheel

判断鼠标往上还是往下滚动

html代码:

<div class="div">

</div>

css代码:

.div{
  position:absolute;

  width:100%;

  height:120%;

  border:1px red solid;

}

js代码:

/IE CHORME/

document.body.onmousewheel=function(event){

  event=event||window.event;

  var direction=event.wheelDelta&&(event.wheelDelta>0?"mouseup":"mousedown");

  console.log(direction);

}

/firefix/

document.body.addListener('DOMMouseScroll',function(event){

  var direction=event.detail&&(event.detail>0?"mousedown":"mouseup");

  console.log(direction);

}

上一篇:JavaScript 自定义对象


下一篇:(Java)利用ListIterator(iterator 重复器/迭代器的子接口) 操作ArrayList