Dave,

This sounds really sweet. How did you define the values for wheelDeltaX and wheelDeltaY?

erik

Dave Hyatt wrote:
Safari in the latest Tiger update supports WinIE's mouse wheel system. We also have a wheelDeltaX and wheelDeltaY so that horizontal wheeling can be supported. I had planned to propose this at some point but hadn't gotten around to it yet.

dave

On Jun 20, 2005, at 3:01 PM, Erik Arvidsson wrote:

Chris Griego wrote:

Currently the only way to capture and use the mouse wheel on the web
is within the Macromedia Flash v7 plugin which added event handling
for the mouse wheel.


That's incorrect. Both IE (since 5.5?) and Mozilla supports this. Unfortunately they do it in different ways.

IE:

element.attachEvent("onmousewheel", function () {
   document.title = window.event.wheelDelta;
});

Mozilla:

element.addEventListener("DOMMouseScroll", function (e) {
   document.title = e.detail;
}, true);

The values here are bit different.

In Mozilla, if you have set Mozilla to scroll a certain number of rows you get the number of steps here. If you have it set to scroll one page at a time you get large values and I'm not sure if these represents the number of rows in some way.

In IE it returns multiples of 120 but I guess it really represent 3 rows * 40 twips/row and that changing this in some control panel applet or in the registry might give you other alternative results.

The values in IE is negative when Mozilla is positive and the other way around.

Here is a pretty simple way to unify these to some extent:

function getWheelDelta(e) {
   if (window.event) { // IE
      return e.wheelDelta / 40;
   } else {
      // In case the user has "one screen at a time" we get a
      // very big value
      var v = e.detail || 0;
      if (v > 1000) {
         v = 3;
      } else if (v < -1000) {
         v = -3;
      }
      return - v;
   }
}

erik



Reply via email to