Loading ...
Sorry, an error occurred while loading the content.

Handling mousewheel events

Expand Messages
  • jessekeller
    The events module doesn t seem to have anything built in for handling mousewheel events -- seems like something useful to add, since it s inconsistent across
    Message 1 of 1 , Apr 25, 2006
    • 0 Attachment
      The events module doesn't seem to have anything built in for handling
      mousewheel events -- seems like something useful to add, since it's
      inconsistent across browsers.

      I'm using the code below, which is only slightly modified from Adomas
      Paltanavicius's example, here: http://adomas.org/notes/mouse-wheel.html

      /* For mozilla. */
      if (window.addEventListener)
      window.addEventListener('DOMMouseScroll', wheel, false);
      else
      /* IE. */
      window.onmousewheel=document.onmousewheel=wheel;

      function doWheel (e) {
      var delta = 0;
      if (e.wheelDelta) // IE case
      delta = e.wheelDelta;
      else if (e.detail) // MZ case
      delta = -e.detail; // MZ & IE deltas differ in sign
      if (delta) {
      if (delta>0)
      rollUp(delta); // Code for rolling up
      else
      rollDown(-1 * delta); // Code for rolling down
      }
      }
    Your message has been successfully submitted and would be delivered to recipients shortly.