React: support for event.movementX/Y [feature-request]

Created on 7 May 2016  路  10Comments  路  Source: facebook/react

currently it seems synthetic events don't have those properties on mousemove

DOM Feature Request

Most helpful comment

If we add something to the synthetic event object, it needs to be available in all browsers.

All 10 comments

oh .nativeEvent sorry

@zpao @syranide @spicyj Is this something we want to support? Looks like the status is "Candidate Recommendation" but it is supported by a couple browsers.

Sounds like Firefox, Chrome, and Edge all support it. We might as well too though I don't know if it's worth polyfilling.

@jimfb @spicyj so do you guys want to add it only in supported browsers, or polyfill it as well?

If we add something to the synthetic event object, it needs to be available in all browsers.

Does the synthetic event system have a way to access the previous instance of an event? Since movementX is the difference between the current screenX and last screenX value. Or should that possibly be tracked in something like MouseMetrics?

I'm always a bit weary when polyfilling things that require rather non-trivial logic as opposed to just interpolating some data. Case in point; to do this I can only assume we would be required to have a permanent global mouse move listener which tracks the last X/Y value, this feels bad (EDIT: There was a lot of fuss to _get rid_ of the ViewportMetrics listener). There's potential for issues here, an event being stopped, event order (or is it just for mousemove?), unnecessary global mouse move listener, etc.

It should be just for mousemove. If it just calculates the difference between the last two mousemove events it doesn't seem too complicated to keep track of but I'm sure I might not be considering some corner cases/gotchas with my PR.

I've added a new PR for this
https://github.com/facebook/react/pull/9018

Closed, with https://github.com/facebook/react/pull/9018. Thanks again, @jasonwilliams!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gaearon picture gaearon  路  133Comments

gaearon picture gaearon  路  227Comments

acdlite picture acdlite  路  83Comments

sophiebits picture sophiebits  路  107Comments

fdecampredon picture fdecampredon  路  139Comments