增加Javascript鼠标事件
我想知道是否有办法提高JS的mousemove事件的采样率。 当我快速穿过窗口时,我只收到大约 10-20 个事件,不足以达到目的 的应用程序,当我慢慢地做时,我可以达到+100;
提前致谢,
I would like to know if is there any way to increase the sample rate of mousemove events of JS.
When I cross the window quickly I only get around 10-20 events, not enough for the purpose
of the app, when I do it slowly I can reach +100;
Thanks in advance,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为,但也许我错了,
mousemove
事件的“采样率”不是由javascript决定的,而是由鼠标的采样率决定的。这意味着每当鼠标向浏览器发送事件时,就会触发一个事件(如果鼠标移动了至少一个像素)并且您可以响应它。采样率较高的鼠标会创建更多事件(并且更精确),而采样率较低的鼠标会创建较少的事件。这就是为什么当你玩《雷神之锤 4》时,鼠标的采样率会影响你的瞄准精度。
所以我不认为这是javascript的问题,你应该让你的应用程序对鼠标生成的事件做出相应的响应。在具有自动瞄准选项的第一人称射击游戏中也可以完成同样的操作。
I think, but maybe i'm wrong, that
mousemove
events "sample rate" is not determined by javascript, but from the sample rate of your mouse. This means that whenever the mouse sends an event to the browser, an event is fired (if the mouse has moved of at least one pixel) and you can respond to it.Mouse with higher sample rates create more events (and are more precise), where mouse with lower sample rate create fewer events. This is why when you play quake 4 the sample rate of your mouse affects the precision of your aiming.
So i don't think it's a problem of javascript, and you should have your app respond accordingly to the events generated from the mouse. The same thing is done in first person shooter with the auto aiming option.