mdn/content

Note difference in how Touch.screenX/screenY, Touch.clientX/clientY and Touch.pageX/pageY handle zooming

Open

#36.326 aperta il 14 ott 2024

Vedi su GitHub
 (0 commenti) (0 reazioni) (0 assegnatari)Markdown (22.427 fork)batch import
Content:WebAPIarea: UI Eventshelp wanted

Metriche repository

Star
 (8900 star)
Metriche merge PR
 (Merge medio 7g 3h) (147 PR mergiate in 30 g)

Descrizione

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/Touch

What specific section or headline is this issue about?

Instance properties

What information was incorrect, unhelpful, or incomplete?

The descriptions of Touch.screenX/screenY, Touch.clientX/clientY and Touch.pageX/pageY make it seem like the only difference between them is the location of the coordinate origin.

What did you expect to see?

In practice there is another important difference: If you zoom in using pinch zoom, then Touch.clientX/clientY and Touch.pageX/pageY will use the same pixel size that CSS uses (i.e. dragging over an element with width: 1px will always result in a change of 1 in the coordinates). However, Touch.screenX/screenY uses the some kind of screen-space CSS pixels. If you have not zoomed in then 1 client/page pixel matches 1 screen pixel, but if you have zoomed in, then screen pixels will be smaller (i.e. dragging over an element with width: 1px will result in a change of more than 1 in the screen coordinates).

Do you have any supporting links, references, or citations?

I tested the behavior on Chrome on Android. I do not know for sure if other mobile browsers have the same behavior and I could not find anything in the spec that actually requires this behavior.

Do you have anything more you want to share?

No response

MDN metadata

Guida contributor