Skip to content

Instantly share code, notes, and snippets.

Last active October 28, 2022 20:24
  • Star 21 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
jQuery - Get mousewheel scroll event to detect scrolling direction cross browser
$('body').on('mousewheel DOMMouseScroll', function(e){
if(typeof e.originalEvent.detail == 'number' && e.originalEvent.detail !== 0) {
if(e.originalEvent.detail > 0) {
} else if(e.originalEvent.detail < 0){
} else if (typeof e.originalEvent.wheelDelta == 'number') {
if(e.originalEvent.wheelDelta < 0) {
} else if(e.originalEvent.wheelDelta > 0) {
Copy link

Thanks. Very help me

Copy link

Waoh, I was looking for something like that for a looooooong time, my goal was to disable the scroll on a specific div while still being able to navigate throught a slider with the mousewheel.

Thanks a lot !

Copy link

My hero!

Copy link

Bro, huge thank you

Copy link

That's very helpful but it's taking too much time to scroll down or up on mouse wheel event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment