W3C home > Mailing lists > Public > whatwg@whatwg.org > June 2005

[whatwg] Suggestion: Mouse Wheel events for Web Apps 1.0

From: Dave Hyatt <hyatt@apple.com>
Date: Mon, 20 Jun 2005 15:07:07 -0700
Message-ID: <A7E4C295-2E81-4C44-B882-52F3D2FE5154@apple.com>
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
>
Received on Monday, 20 June 2005 15:07:07 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:41 UTC