You should use clientX
and clientY
instead.
Nobody can explain why we need x/y when we have clientX/Y. Firefox’s take on this property pair is by far the sanest(removed it-gdoron).
Domanda
I'm writing a game and need to capture mouse movements in Firefox. This is my code:
document.onmousemove = function(e) {
mouseState.x = e.x;
mouseState.y = e.y;
}
it works correctly in Chrome/IE however it doesn't seem to work in Firefox. When I do console.log(mouseState.x)
it comes back as undefined
.
What modifications do I need to make to get Firefox to capture mouse movements?
Soluzione
You should use clientX
and clientY
instead.
Nobody can explain why we need x/y when we have clientX/Y. Firefox’s take on this property pair is by far the sanest(removed it-gdoron).
Altri suggerimenti
Try using e.clientX
and e.clientY
.