←back to thread

293 points ulrischa | 1 comments | | HN request time: 0.209s | source
Show context
account42 ◴[] No.42174070[source]
Why are websites getting mouse position in screen coordinates in the first place?
replies(8): >>42174192 #>>42174200 #>>42174236 #>>42174247 #>>42174483 #>>42174549 #>>42174581 #>>42177418 #
DCH3416 ◴[] No.42174200[source]
Uh. So they can keep track of what the user is doing?

Why would you just send a document when you can generate a heat map of where the user is on your website. And then complain about the performance and wonder why it costs so much to run a modern website.

replies(2): >>42174285 #>>42174308 #
1. Sayrus ◴[] No.42174308[source]
The issue isn't so much the coordinate of the mouse within a page, but that the coordinates are relative to the virtual screen layout. It describes where your window is located on the screen(s) and the click is expressed in screen coordinates. Mapping those coordinates to your website's renderer coordinates requires additional calculation.

layerX[1] while non-standard is supported and returns a position relative to the top of the page or the top of the parent element. This makes coordinates positive only and 50,50 is the same for all users. For screenX, 3000,1567 is the same coordinate as 15,37 depending on where the window is located.

[1] https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/...