Question

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?

Was it helpful?

Solution

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).

quirks mode

OTHER TIPS

Try using e.clientX and e.clientY.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top