Package Exports
- watch-wheel
- watch-wheel/dist/index.es.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (watch-wheel) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
watch-wheel
🖱️ 监控鼠标滚动
安装
yarn add watch-wheel使用
import watchWheel from 'watch-wheel';
// 任意元素
const el = document.getElementById('any');
// 监视鼠标指针在该元素上触发的滚轮滚动.
watchWheel(el, (e) => {
console.log(e.type); // wheelstart / wheelmove / wheelend
console.log(e.delatY); // 鼠标滚轮滚动一下的距离
console.log(e.velocityY); // 滚动速度, 每隔16ms取一次值
});如果你的鼠标滚轮支持 x 轴滚动, 那么你还可以监听到delatX和velocityX的数值变化.