admin管理员组文章数量:1357653
In this fiddle demo, press and move the mouse will draw the dot according to the mouse's position. The draw method is listen to mousemove
callback, but it draw the discrete dot which show that the mousemove
event is not fired continuously.
What is more, I collect the event.timeStamp
and log in console. I found that the offset between adjacent event is near 16.7ms. So is mousemove
event fire once in per frame?
In this fiddle demo, press and move the mouse will draw the dot according to the mouse's position. The draw method is listen to mousemove
callback, but it draw the discrete dot which show that the mousemove
event is not fired continuously.
What is more, I collect the event.timeStamp
and log in console. I found that the offset between adjacent event is near 16.7ms. So is mousemove
event fire once in per frame?
- Just to add a data point, I have exactly 60 mouse move events on a 60 Hz monitor on both Firefox and Chromium on Gnome on Arch Linux, which is really problematic if you want to do high quality painting in a browser. – Konrad Höffner Commented Sep 26, 2017 at 14:43
1 Answer
Reset to default 9The mousemove
event frequency is implementation specific, and not defined by any specification.
A user agent MUST dispatch this event when a pointing device is moved while it is over an element. The frequency rate of events while the pointing device is moved is implementation-, device-, and platform-specific, but multiple consecutive mousemove events SHOULD be fired for sustained pointer-device movement, rather than a single event for each instance of mouse movement. Implementations are encouraged to determine the optimal frequency rate to balance responsiveness with performance.
-- UI Events, W3C Working Draft, 04 August 2016
It's entirely possible some browsers on some platforms will limit it to once per-frame. There is no guarantee any browser that may do this will continue to do so however.
If you want to draw a continuous line, you would need to create interpolation data between each two points.
本文标签: javascriptIs mousemove event fire once in per frameStack Overflow
版权声明:本文标题:javascript - Is mousemove event fire once in per frame? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744079381a2587348.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论