any-wheel
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

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 轴滚动, 那么你还可以监听到delatXvelocityX的数值变化.

Package Sidebar

Install

npm i any-wheel

Weekly Downloads

0

Version

0.0.2

License

ISC

Unpacked Size

2.25 kB

Total Files

2

Last publish

Collaborators

  • russell-ne