1/* Copyright (c) 2006 Brandon Aaron ([email protected] || http://brandonaaron.net) 2 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 3 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. 4 * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers. 5 * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. 6 * 7 * $LastChangedDate: 2007-12-20 09:02:08 -0600 (Thu, 20 Dec 2007) $ 8 * $Rev: 4265 $ 9 * 10 * Version: 3.0 11 * 12 * Requires: $ 1.2.2+ 13 */ 14 15(function($) { 16 17$.event.special.mousewheel = { 18 setup: function() { 19 var handler = $.event.special.mousewheel.handler; 20 21 // Fix pageX, pageY, clientX and clientY for mozilla 22 if ( $.browser.mozilla ) 23 $(this).bind('mousemove.mousewheel', function(event) { 24 $.data(this, 'mwcursorposdata', { 25 pageX: event.pageX, 26 pageY: event.pageY, 27 clientX: event.clientX, 28 clientY: event.clientY 29 }); 30 }); 31 32 if ( this.addEventListener ) 33 this.addEventListener( ($.browser.mozilla ? 'DOMMouseScroll' : 'mousewheel'), handler, false); 34 else 35 this.onmousewheel = handler; 36 }, 37 38 teardown: function() { 39 var handler = $.event.special.mousewheel.handler; 40 41 $(this).unbind('mousemove.mousewheel'); 42 43 if ( this.removeEventListener ) 44 this.removeEventListener( ($.browser.mozilla ? 'DOMMouseScroll' : 'mousewheel'), handler, false); 45 else 46 this.onmousewheel = function(){}; 47 48 $.removeData(this, 'mwcursorposdata'); 49 }, 50 51 handler: function(event) { 52 var args = Array.prototype.slice.call( arguments, 1 ); 53 54 event = $.event.fix(event || window.event); 55 // Get correct pageX, pageY, clientX and clientY for mozilla 56 $.extend( event, $.data(this, 'mwcursorposdata') || {} ); 57 var delta = 0, returnValue = true; 58 59 if ( event.wheelDelta ) delta = event.wheelDelta/120; 60 if ( event.detail ) delta = -event.detail/3; 61// if ( $.browser.opera ) delta = -event.wheelDelta; 62 63 event.data = event.data || {}; 64 event.type = "mousewheel"; 65 66 // Add delta to the front of the arguments 67 args.unshift(delta); 68 // Add event to the front of the arguments 69 args.unshift(event); 70 71 return $.event.handle.apply(this, args); 72 } 73}; 74 75$.fn.extend({ 76 mousewheel: function(fn) { 77 return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel"); 78 }, 79 80 unmousewheel: function(fn) { 81 return this.unbind("mousewheel", fn); 82 } 83}); 84 85})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.