如何在鼠标向上滚动和向下滚动时触发不同的功能
How to trigger different functions when the mouse is scrolled up and scrolled down
我有两个函数 zoomin 和 zoomout.I 想在向上滚动时触发 zoomin 和在滚动时触发 zoomout down.onwheel 不提供向上和向下功能
onWheel={()=>this.zoomIn()}
您可以从event.deltaY
查看
onWheel={(e)=>this.zoomState(e)}
zoomState(e) {
switch (e.deltaY > 0) {
case true:
this.zoomIn();
break;
default:
this.zoomOut();
}
}
我有两个函数 zoomin 和 zoomout.I 想在向上滚动时触发 zoomin 和在滚动时触发 zoomout down.onwheel 不提供向上和向下功能
onWheel={()=>this.zoomIn()}
您可以从event.deltaY
onWheel={(e)=>this.zoomState(e)}
zoomState(e) {
switch (e.deltaY > 0) {
case true:
this.zoomIn();
break;
default:
this.zoomOut();
}
}