Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixing jQuery mouse wheel problems #414

Merged
merged 1 commit into from

2 participants

@thorstein5

Fixing broken mouse wheel when using jQuery 1.7+, and added missing
Mozilla Firefox 3+ mouse wheel support by reusing normalisation code
taken from the non-jQuery events.js file. Fix successfully tested using
jQuery 1.6.3-1.8.2.

@thorstein5 thorstein5 Fixing jQuery mouse wheel problems
Fixing broken mouse wheel when using jQuery 1.7+, and added missing
Mozilla Firefox 3+ mouse wheel support by reusing normalisation code
taken from the non-jQuery events.js file. Fix successfully tested using
jQuery 1.6.3-1.8.2.
a8f23e4
@billinghamj billinghamj merged commit c85f02e into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 11, 2012
  1. @thorstein5

    Fixing jQuery mouse wheel problems

    thorstein5 authored
    Fixing broken mouse wheel when using jQuery 1.7+, and added missing
    Mozilla Firefox 3+ mouse wheel support by reusing normalisation code
    taken from the non-jQuery events.js file. Fix successfully tested using
    jQuery 1.6.3-1.8.2.
This page is out of date. Refresh to see the latest.
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';
+
}
Something went wrong with that request. Please try again.