Skip to content

Commit

Permalink
refs #3763: added wheel to dojo/mouse
Browse files Browse the repository at this point in the history
it normalizes mozilla DOMMouseScroll events so it has the same wheelDelta attribute as other browsers

!strict


git-svn-id: http://svn.dojotoolkit.org/src/dojo/trunk@28600 560b804f-0ae3-0310-86f3-f6aa0a117693
  • Loading branch information
liucougar committed May 19, 2012
1 parent 78a389d commit ea48a12
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions mouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ define(["./_base/kernel", "./on", "./has", "./dom", "./_base/window"], function(

has.add("dom-quirks", win.doc && win.doc.compatMode == "BackCompat");
has.add("events-mouseenter", win.doc && "onmouseenter" in win.doc.createElement("div"));
has.add("events-mousewheel", 'onmousewheel' in win.global);

var mouseButtons;
if(has("dom-quirks") || !has("dom-addeventlistener")){
Expand Down Expand Up @@ -113,6 +114,17 @@ define(["./_base/kernel", "./on", "./has", "./dom", "./_base/window"], function(
};
return handler;
}
var wheel;
if(has("events-mousewheel")){
wheel = 'onmousewheel';
}else{ //firefox
wheel = function(node, listener){
return on(node, 'DOMMouseScroll', function(evt){
evt.wheelDelta = -evt.detail;
listener.call(this, evt);
});
};
}
return {
_eventHandler: eventHandler, // for dojo/touch

Expand All @@ -126,6 +138,11 @@ define(["./_base/kernel", "./on", "./has", "./dom", "./_base/window"], function(
// behavior on other browsers.
leave: eventHandler("mouseout"),

// wheel: Normalized Mouse Wheel Event
// This is an extension event for the mousewheel that non-Mozilla browsers provide,
// emulating the behavior on Mozilla based browsers.
wheel: wheel,

isLeft: mouseButtons.isLeft,
/*=====
isLeft: function(){
Expand Down

0 comments on commit ea48a12

Please sign in to comment.