←back to thread

293 points ulrischa | 3 comments | | HN request time: 0s | source
Show context
duxup ◴[] No.42174148[source]
Why are screenX and screenY relevant here as far as their code goes?

Where they using those values in their code?

Very interesting article but I'm missing the step where it would impact their code ...

replies(1): >>42174292 #
t43562 ◴[] No.42174292[source]
...because when they are 0 one can infer that the event came from a keypress rather than a mouse. They want to know this.
replies(3): >>42174436 #>>42174868 #>>42175013 #
1. shdon ◴[] No.42174436[source]
Then it would make a lot more sense to check event.pointerType == 'mouse' vs event.pointerType == '' (for keyboard)
replies(2): >>42175068 #>>42175287 #
2. ◴[] No.42175068[source]
3. jorams ◴[] No.42175287[source]
That does seem quite obviously better. Even when insisting on checking coordinates why use the coordinate system carried by the event that you have the least control over. Why not .pageX/.pageY, which can't trigger the failure case as long as you make sure the element isn't in the far top left.