reactjs - 鼠标上下滚动时如何触发不同的功能
问题描述
我有两个功能 zoomin 和 zoomout。我想在向上滚动时触发 zoomin,在向下滚动时触发 zoomout。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();
}
}
推荐阅读
- python - 如何在 Python 中将 PDF 转换为灰度
- c - 无法显示我的数组堆栈的内容
- sql - 逗号分隔的列中的值
- javascript - 在 js 中按约定记录数组
- php - 一旦找到字符串匹配项,PHP 中有没有办法停止 curl 请求?
- html - 垂直合并 Bootstrap 中的列
- c++ - 如何编写具有相同名称的相同函数以在 C++ 中几乎相似地处理不同的类参数?
- avro - 使用 v1.11.0 编写时将 Parquet 数据加载到雪花云数据库的问题
- react-native - 如何使用 RNFetchBlob.fetch 和 react-native-document-picker 上传多个文件
- javascript - JavaScript 中的实体和 DTO