MouseWheel scroll in JS with JQuery


/ Published in: JavaScript
Save to your folder(s)

Works on every modern Browser, including Firefox. Requires JQuery.


Copy this code and paste it in your HTML
  1. $(document).unbind('mousewheel DOMMouseScroll').on('mousewheel DOMMouseScroll', function(event) {
  2. var delta = event.originalEvent.detail < 0 || event.originalEvent.wheelDelta > 0 ? 1 : -1;
  3.  
  4. if (delta < 0) {
  5. // scroll down
  6. } else {
  7. // scroll up
  8. }
  9. return false;
  10. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.