Side navigation
Ticket #4402: mousewheel.patch
File mousewheel.patch, 1.6 KB (added by brandon, March 23, 2009 01:44AM UTC)
Patch to add mousewheel plugin support to jQuery
Index: event.js
===================================================================
--- event.js (revision 6297)
+++ event.js (working copy)
@@ -464,6 +464,39 @@
};
});
+var mousewheelTypes = ['DOMMouseScroll', 'mousewheel'];
+function mousewheelHandler(event) {
+ var args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true;
+
+ event = jQuery.event.fix(event || window.event);
+ event.type = "mousewheel";
+
+ if ( event.wheelDelta ) delta = event.wheelDelta/120;
+ if ( event.detail ) delta = -event.detail/3;
+
+ // Add events and delta to the front of the arguments
+ args.unshift(event, delta);
+
+ return jQuery.event.handle.apply(this, args);
+};
+jQuery.event.special.mousewheel = {
+ setup: function() {
+ if ( this.addEventListener )
+ for ( var i=types.length; i; )
+ this.addEventListener( types[--i], handler, false );
+ else
+ this.onmousewheel = handler;
+ },
+
+ teardown: function() {
+ if ( this.removeEventListener )
+ for ( var i=types.length; i; )
+ this.removeEventListener( types[--i], handler, false );
+ else
+ this.onmousewheel = null;
+ }
+};
+
jQuery.fn.extend({
bind: function( type, data, fn ) {
return type == "unload" ? this.one(type, data, fn) : this.each(function(){
@@ -665,7 +698,7 @@
}
jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
- "mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave," +
+ "mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave,mousewheel" +
"change,select,submit,keydown,keypress,keyup,error").split(","), function(i, name){
// Handle event binding
Download in other formats:
Original Format
File mousewheel.patch, 1.6 KB (added by brandon, March 23, 2009 01:44AM UTC)
Patch to add mousewheel plugin support to jQuery
Index: event.js
===================================================================
--- event.js (revision 6297)
+++ event.js (working copy)
@@ -464,6 +464,39 @@
};
});
+var mousewheelTypes = ['DOMMouseScroll', 'mousewheel'];
+function mousewheelHandler(event) {
+ var args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true;
+
+ event = jQuery.event.fix(event || window.event);
+ event.type = "mousewheel";
+
+ if ( event.wheelDelta ) delta = event.wheelDelta/120;
+ if ( event.detail ) delta = -event.detail/3;
+
+ // Add events and delta to the front of the arguments
+ args.unshift(event, delta);
+
+ return jQuery.event.handle.apply(this, args);
+};
+jQuery.event.special.mousewheel = {
+ setup: function() {
+ if ( this.addEventListener )
+ for ( var i=types.length; i; )
+ this.addEventListener( types[--i], handler, false );
+ else
+ this.onmousewheel = handler;
+ },
+
+ teardown: function() {
+ if ( this.removeEventListener )
+ for ( var i=types.length; i; )
+ this.removeEventListener( types[--i], handler, false );
+ else
+ this.onmousewheel = null;
+ }
+};
+
jQuery.fn.extend({
bind: function( type, data, fn ) {
return type == "unload" ? this.one(type, data, fn) : this.each(function(){
@@ -665,7 +698,7 @@
}
jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
- "mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave," +
+ "mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave,mousewheel" +
"change,select,submit,keydown,keypress,keyup,error").split(","), function(i, name){
// Handle event binding