cannot get mouse coordinates on wheel events

1.2k Views Asked by At

Hello problem is on mozilla firefox browser mouse wheel event doesn't have parameters who can get mouse position coordinates i use jquery 1.9.0 version wheel events:

$("#element").bind("mousewheel wheel DOMMouseScroll MozMousePixelScroll MouseWheelEvent", function (transsmittedEvent) {
var evt = window.event || transsmittedEvent;

if (evt.clientX !== undefined && evt.clientY !== undefined) {
        var x = evt.clientX;
        var y = evt.clientY;
    };
} else if(evt.pageX !== undefined && evt.pageY !== undefined) {
        var x = evt.pageX;
        var y = evt.pageY;
    };        
} else if(evt.offsetX !== undefined && evt.offsetY !== undefined) {
        var x = evt.offsetX;
        var y = evt.offsetY;
}     
});

trasmittedEvent doesn't have parameters who can get coordinates: pageX, offsetX, clientX and etc. but window.event have all this in chrome, but in mozilla firefox window.event is null

1

There are 1 best solutions below

0
On BEST ANSWER

You can get the built-in browser event by looking at transsmittedEvent.originalEvent.

This has clientX and pageX in Firefox as well as Chrome.