1

I am trying to get mouse position when mousewheel event.

Here is fiddle. https://jsfiddle.net/xta2ccdt/7/

$("#container").on("mousewheel DOMMouseScroll", function (e) {
  e.preventDefault();
  console.log(e.pageX);
  console.log(e);
}
);

It shows undefined.
What's wrong with this implementation?

General Grievance
  • 4,555
  • 31
  • 31
  • 45
My Favorite Bear
  • 114
  • 1
  • 1
  • 10

1 Answers1

4

Try accessing e.originalEvent.pageX instead, that will access the vanilla JS event that looks like working ok in firefox too.

Looks like this is just a jquery v2 bug. After updating jquery version to jquery 3 in your fiddle it works with e.pageX too.

https://jsfiddle.net/xta2ccdt/8/

Martin Adámek
  • 16,771
  • 5
  • 45
  • 64