Permalink
Browse files

Merge pull request #414 from thorstein5/jquery-mouse-wheel-fixes

Fixing jQuery mouse wheel problems
  • Loading branch information...
2 parents 0a2b11c + a8f23e4 commit c85f02e5596cbc58783d7e7c4eb3eacda7e080c3 @billinghamj billinghamj committed Mar 26, 2013
Showing with 25 additions and 4 deletions.
  1. +25 −4 src/lib/code.util-1.0.6/src/events.jquery.js
View
29 src/lib/code.util-1.0.6/src/events.jquery.js
@@ -15,6 +15,10 @@
*/
add: function(obj, type, handler){
+ if (type === 'mousewheel'){
+ type = this._normaliseMouseWheelType();
+ }
+
$(obj).bind(type, handler);
},
@@ -27,6 +31,10 @@
*/
remove: function(obj, type, handler){
+ if (type === 'mousewheel'){
+ type = this._normaliseMouseWheelType();
+ }
+
$(obj).unbind(type, handler);
},
@@ -42,6 +50,10 @@
event,
args = Array.prototype.slice.call(arguments).splice(2);
+ if (type === 'mousewheel'){
+ type = this._normaliseMouseWheelType();
+ }
+
if (typeof type === "string"){
event = { type: type };
}
@@ -87,11 +99,11 @@
var delta = 0;
- if (!Util.isNothing(event.wheelDelta)){
- delta = event.wheelDelta / 120;
+ if (!Util.isNothing(event.originalEvent.wheelDelta)){
+ delta = event.originalEvent.wheelDelta / 120;
}
- else if (!Util.isNothing(event.detail)){
- delta = -event.detail / 3;
+ else if (!Util.isNothing(event.originalEvent.detail)){
+ delta = -event.originalEvent.detail / 3;
}
return delta;
@@ -106,6 +118,15 @@
$(document).ready(handler);
+ },
+
+ _normaliseMouseWheelType: function(){
+
+ if (Util.Browser.isEventSupported('mousewheel')){
+ return 'mousewheel';
+ }
+ return 'DOMMouseScroll';
+
}

0 comments on commit c85f02e

Please sign in to comment.