movementX/Y are not reported correctly on Windows with devicePixelRatio > 1
Reported by
bengo...@gmail.com,
Nov 21
|
|||
Issue descriptionUserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Steps to reproduce the problem: 1. Open https://jsfiddle.net/4jxc1qty/6/ in Chrome on Windows 10 with a display that has devicePixelRatio > 1. 2. Observe that as you move the mouse across the example page, the accumulated movementX increases faster than the accumulated (screenX - prevScreenX) values. The difference should be negligible, but in the test they're off by a factor of window.devicePixelRatio. What is the expected behavior? In the W3C spec, `movementX` is `screenX - previousScreenX` What went wrong? movementX/Y values are scaled by window.devicePixelRatio and are 2x the values you get doing manual screenX - prevScreenX calculation. Did this work before? N/A Does this work in other browsers? Yes Chrome version: 70.0.3538.102 Channel: stable OS Version: 10 Flash Version: I'm using Windows 10 and have an external display. I've tried devicePixelRatio 1.5 and also 2.0 (changed via Windows Display settings) and it's incorrect in both. I've tested on macOS, in Firefox for Windows and in Edge, and all of them report movementX correctly. I understand eirage's <eirage@chromium.org> patch in https://bugs.chromium.org/p/chromium/issues/detail?id=132914&q=movementX&colspec=ID%20Pri%20M%20Stars%20ReleaseBlock%20Component%20Status%20Owner%20Summary%20OS%20Modified has been reverted, but I think that it may be required to fix this.
,
Nov 22
Yeah. Ella is working on a precise definition of screenX/Y and by extension movementX/Y to get things right.
,
Nov 22
Reporter: Would you mind tell me more about the use case that why you need movementX/Y to be the same scale as screenX/Y? (instead of CSS pixel, since screenX/Y scale is not changing with page zoom(ctrl+/-) The coordinate space of movementX/Y is kinda mess here and we are working on fix it.
,
Nov 23
We have some UI elements that track the mouse while dragging, we adjusted their location based on movementX and movementY. Specifically, the application is a time series graph that can be zoomed and panned using the mouse. We haven't experimented with page zoom yet, but thinking about it now, we would need the movement in CSS pixels in order for the tracking to work properly.
,
Nov 26
Yea, in that case you would probably want to use movementX / devicePixelRatio in chrome. (that's why the patch you mentioned is reverted)
,
Nov 28
Hey folks, thanks for the replies. We honestly don't need movementX/Y to be the same scale as screenX/Y (since we can easily divide by devicePixelRatio in Chrome), but it'd be great if the implementation was consistent with the W3C spec where `movementX = screenX - previousScreenX` and they're both in the same coordinate space. Thanks!
,
Jan 8
|
|||
►
Sign in to add a comment |
|||
Comment 1 by krajshree@chromium.org
, Nov 21