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

Dave Hyatt wrote:
> Safari in the latest Tiger update supports WinIE's mouse wheel  
> system.

    Mozilla uses addEventListener[1], which is in DOM 2 and DOM 3. (DOM 
3 even adds addEventListenerNS for different namespaces.) By contrast, 
IE uses attachEvent, which is proprietary and doesn't allow you to 
specify the the initial capture. As a result, I would NOT support using 
attachEvent in any WHATWG standard, especially since it does not appear 
functionally different from addEventListener. (Is there even an 
IE-proprietary event listener method that supports namespaces?)

 > We also have a wheelDeltaX and wheelDeltaY so that
> horizontal wheeling can be supported.

    I'm thinking we should define new properties wheelDeltaX and 
wheelDeltaY for MouseEvent. [2]

>>Chris Griego wrote:
>>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);

    Note that for attachEvent, you name the HTML attribute name and not 
the actual DOM event type. Therefore, in DOM, if you wanted a listener 
for a mousemove, you'd use the string "mousemove" and not "onmousemove". 
DOM also employs the method of using "DOM" at the beginning of strings 
that don't correspond to the associated "on" attributes in HTML 4.01. 
Since there is no official HTML5, this makes Mozilla's implementation 
above the most standards correct.

    I think I'd prefer something like "mousewheel" or "DOMmousewheel". 
I'm not sure a new |onmousewheel| attribute is called for, though, 
because there might be semantic arguments against it. Anyone have a take 
on this, by the way?

    So, I guess I'd like to see this happen:

| element.addEventListener("mousewheel",
|   function (e) { document.title = getWheelDelta(e); },
|   true);
|
| function getWheelDelta(e) {
|   return e.wheelDeltaY;
| }

> I had planned to propose this at some point but hadn't gotten
> around to it yet.

    I'm hoping you aren't referring to the blatantly nonstandard IE 
event model shown in Chris Griego's IE example...

[1] 
http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-EventTarget-addEventListener
[2] http://www.w3.org/TR/DOM-Level-3-Events/events.html#Events-MouseEvent

Received on Tuesday, 21 June 2005 08:09:23 UTC