From 02de3f0becd8d4a4989c68b5113a6380a009e630 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Wed, 15 Oct 2008 20:35:05 -0500 Subject: [PATCH 001/136] moving mousewheel plugin to git hub --- ChangeLog.markdown | 35 + README.markdown | 10 + jquery.mousewheel.js | 82 ++ test/index.html | 193 +++ test/jquery.js | 3331 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 3651 insertions(+) create mode 100644 ChangeLog.markdown create mode 100644 README.markdown create mode 100644 jquery.mousewheel.js create mode 100644 test/index.html create mode 100644 test/jquery.js diff --git a/ChangeLog.markdown b/ChangeLog.markdown new file mode 100644 index 000000000..8d6943cbc --- /dev/null +++ b/ChangeLog.markdown @@ -0,0 +1,35 @@ +# Mouse Wheel ChangeLog + +# 3.0 + +* Uses new special events API in jQuery 1.2.2+ +* You can now treat "mousewheel" as a normal event and use .bind, .unbind and .trigger +* Using jQuery.data API for expandos + + +# 2.2 + +* Fixed pageX, pageY, clientX and clientY event properties for Mozilla based browsers + + +# 2.1.1 + +* Updated to work with jQuery 1.1.3 +* Used one instead of bind to do unload event for clean up. + + +# 2.1 + +* Fixed an issue with the unload handler + + +# 2.0 + +* Major reduction in code size and complexity (internals have change a whole lot) + + +# 1.0 + +* Fixed Opera issue +* Fixed an issue with children elements that also have a mousewheel handler +* Added ability to handle multiple handlers \ No newline at end of file diff --git a/README.markdown b/README.markdown new file mode 100644 index 000000000..71588f345 --- /dev/null +++ b/README.markdown @@ -0,0 +1,10 @@ +# jQuery Mouse Wheel Plugin + +A jQuery plugin that adds cross-browser mouse wheel support. + + +## License + +The batch plugin is dual licensed *(just like jQuery)* under the [MIT](http://www.opensource.org/licenses/mit-license.php) and [GPL](http://www.opensource.org/licenses/gpl-license.php) licenses. + +Copyright (c) 2007 [Brandon Aaron](http://brandonaaron.net) \ No newline at end of file diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js new file mode 100644 index 000000000..996ee72e2 --- /dev/null +++ b/jquery.mousewheel.js @@ -0,0 +1,82 @@ +/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net) + * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) + * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. + * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers. + * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. + * + * Version: 3.0.1-pre + * + * Requires: 1.2.2+ + */ + +(function($) { + +$.event.special.mousewheel = { + setup: function() { + var handler = $.event.special.mousewheel.handler; + + // Fix pageX, pageY, clientX and clientY for mozilla + if ( $.browser.mozilla ) + $(this).bind('mousemove.mousewheel', function(event) { + $.data(this, 'mwcursorposdata', { + pageX: event.pageX, + pageY: event.pageY, + clientX: event.clientX, + clientY: event.clientY + }); + }); + + if ( this.addEventListener ) + this.addEventListener( ($.browser.mozilla ? 'DOMMouseScroll' : 'mousewheel'), handler, false); + else + this.onmousewheel = handler; + }, + + teardown: function() { + var handler = $.event.special.mousewheel.handler; + + $(this).unbind('mousemove.mousewheel'); + + if ( this.removeEventListener ) + this.removeEventListener( ($.browser.mozilla ? 'DOMMouseScroll' : 'mousewheel'), handler, false); + else + this.onmousewheel = function(){}; + + $.removeData(this, 'mwcursorposdata'); + }, + + handler: function(event) { + var args = Array.prototype.slice.call( arguments, 1 ); + + event = $.event.fix(event || window.event); + // Get correct pageX, pageY, clientX and clientY for mozilla + $.extend( event, $.data(this, 'mwcursorposdata') || {} ); + var delta = 0, returnValue = true; + + if ( event.wheelDelta ) delta = event.wheelDelta/120; + if ( event.detail ) delta = -event.detail/3; + if ( $.browser.opera ) delta = -event.wheelDelta; + + event.data = event.data || {}; + event.type = "mousewheel"; + + // Add delta to the front of the arguments + args.unshift(delta); + // Add event to the front of the arguments + args.unshift(event); + + return $.event.handle.apply(this, args); + } +}; + +$.fn.extend({ + mousewheel: function(fn) { + return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel"); + }, + + unmousewheel: function(fn) { + return this.unbind("mousewheel", fn); + } +}); + +})(jQuery); \ No newline at end of file diff --git a/test/index.html b/test/index.html new file mode 100644 index 000000000..485927fd2 --- /dev/null +++ b/test/index.html @@ -0,0 +1,193 @@ + + + + Testing mousewheel plugin + + + + + + + + +

jQuery mousewheel.js - Test

+

+ + + + +

Test1

+

Test2

+

Test3

+

Test4

+
+

Test5

+
+

Test6

+

Test7

+
+
+ +
+ +
+ + diff --git a/test/jquery.js b/test/jquery.js new file mode 100644 index 000000000..3a90b3a4b --- /dev/null +++ b/test/jquery.js @@ -0,0 +1,3331 @@ +(function(){ +/* + * jQuery 1.2.2b - New Wave Javascript + * + * Copyright (c) 2007 John Resig (jquery.com) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * $Date: 2007-12-19 12:23:46 -0600 (Wed, 19 Dec 2007) $ + * $Rev: 4236 $ + */ + +// Map over jQuery in case of overwrite +if ( window.jQuery ) + var _jQuery = window.jQuery; + +var jQuery = window.jQuery = function( selector, context ) { + // The jQuery object is actually just the init constructor 'enhanced' + return new jQuery.prototype.init( selector, context ); +}; + +// Map over the $ in case of overwrite +if ( window.$ ) + var _$ = window.$; + +// Map the jQuery namespace to the '$' one +window.$ = jQuery; + +// A simple way to check for HTML strings or ID strings +// (both of which we optimize for) +var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/; + +// Is it a simple selector +var isSimple = /^.[^:#\[\.]*$/; + +jQuery.fn = jQuery.prototype = { + init: function( selector, context ) { + // Make sure that a selection was provided + selector = selector || document; + + // Handle $(DOMElement) + if ( selector.nodeType ) { + this[0] = selector; + this.length = 1; + return this; + + // Handle HTML strings + } else if ( typeof selector == "string" ) { + // Are we dealing with HTML string or an ID? + var match = quickExpr.exec( selector ); + + // Verify a match, and that no context was specified for #id + if ( match && (match[1] || !context) ) { + + // HANDLE: $(html) -> $(array) + if ( match[1] ) + selector = jQuery.clean( [ match[1] ], context ); + + // HANDLE: $("#id") + else { + var elem = document.getElementById( match[3] ); + + // Make sure an element was located + if ( elem ) + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem.id != match[3] ) + return jQuery().find( selector ); + + // Otherwise, we inject the element directly into the jQuery object + else { + this[0] = elem; + this.length = 1; + return this; + } + + else + selector = []; + } + + // HANDLE: $(expr, [context]) + // (which is just equivalent to: $(content).find(expr) + } else + return new jQuery( context ).find( selector ); + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( jQuery.isFunction( selector ) ) + return new jQuery( document )[ jQuery.fn.ready ? "ready" : "load" ]( selector ); + + return this.setArray( + // HANDLE: $(array) + selector.constructor == Array && selector || + + // HANDLE: $(arraylike) + // Watch for when an array-like object, contains DOM nodes, is passed in as the selector + (selector.jquery || selector.length && selector != window && !selector.nodeType && selector[0] != undefined && selector[0].nodeType) && jQuery.makeArray( selector ) || + + // HANDLE: $(*) + [ selector ] ); + }, + + // The current version of jQuery being used + jquery: "1.2.2b", + + // The number of elements contained in the matched element set + size: function() { + return this.length; + }, + + // The number of elements contained in the matched element set + length: 0, + + // Get the Nth element in the matched element set OR + // Get the whole matched element set as a clean array + get: function( num ) { + return num == undefined ? + + // Return a 'clean' array + jQuery.makeArray( this ) : + + // Return just the object + this[ num ]; + }, + + // Take an array of elements and push it onto the stack + // (returning the new matched element set) + pushStack: function( elems ) { + // Build a new jQuery matched element set + var ret = jQuery( elems ); + + // Add the old object onto the stack (as a reference) + ret.prevObject = this; + + // Return the newly-formed element set + return ret; + }, + + // Force the current matched set of elements to become + // the specified array of elements (destroying the stack in the process) + // You should use pushStack() in order to do this, but maintain the stack + setArray: function( elems ) { + // Resetting the length to 0, then using the native Array push + // is a super-fast way to populate an object with array-like properties + this.length = 0; + Array.prototype.push.apply( this, elems ); + + return this; + }, + + // Execute a callback for every element in the matched set. + // (You can seed the arguments with an array of args, but this is + // only used internally.) + each: function( callback, args ) { + return jQuery.each( this, callback, args ); + }, + + // Determine the position of an element within + // the matched set of elements + index: function( elem ) { + var ret = -1; + + // Locate the position of the desired element + this.each(function(i){ + if ( this == elem ) + ret = i; + }); + + return ret; + }, + + attr: function( name, value, type ) { + var options = name; + + // Look for the case where we're accessing a style value + if ( name.constructor == String ) + if ( value == undefined ) + return this.length && jQuery[ type || "attr" ]( this[0], name ) || undefined; + + else { + options = {}; + options[ name ] = value; + } + + // Check to see if we're setting style values + return this.each(function(i){ + // Set all the styles + for ( name in options ) + jQuery.attr( + type ? + this.style : + this, + name, jQuery.prop( this, options[ name ], type, i, name ) + ); + }); + }, + + css: function( key, value ) { + // ignore negative width and height values + if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 ) + value = undefined; + return this.attr( key, value, "curCSS" ); + }, + + text: function( text ) { + if ( typeof text != "object" && text != null ) + return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); + + var ret = ""; + + jQuery.each( text || this, function(){ + jQuery.each( this.childNodes, function(){ + if ( this.nodeType != 8 ) + ret += this.nodeType != 1 ? + this.nodeValue : + jQuery.fn.text( [ this ] ); + }); + }); + + return ret; + }, + + wrapAll: function( html ) { + if ( this[0] ) + // The elements to wrap the target around + jQuery( html, this[0].ownerDocument ) + .clone() + .insertBefore( this[0] ) + .map(function(){ + var elem = this; + + while ( elem.firstChild ) + elem = elem.firstChild; + + return elem; + }) + .append(this); + + return this; + }, + + wrapInner: function( html ) { + return this.each(function(){ + jQuery( this ).contents().wrapAll( html ); + }); + }, + + wrap: function( html ) { + return this.each(function(){ + jQuery( this ).wrapAll( html ); + }); + }, + + append: function() { + return this.domManip(arguments, true, false, function(elem){ + if (this.nodeType == 1) + this.appendChild( elem ); + }); + }, + + prepend: function() { + return this.domManip(arguments, true, true, function(elem){ + if (this.nodeType == 1) + this.insertBefore( elem, this.firstChild ); + }); + }, + + before: function() { + return this.domManip(arguments, false, false, function(elem){ + this.parentNode.insertBefore( elem, this ); + }); + }, + + after: function() { + return this.domManip(arguments, false, true, function(elem){ + this.parentNode.insertBefore( elem, this.nextSibling ); + }); + }, + + end: function() { + return this.prevObject || jQuery( [] ); + }, + + find: function( selector ) { + var elems = jQuery.map(this, function(elem){ + return jQuery.find( selector, elem ); + }); + + return this.pushStack( /[^+>] [^+>]/.test( selector ) || selector.indexOf("..") > -1 ? + jQuery.unique( elems ) : + elems ); + }, + + clone: function( events ) { + // Do the clone + var ret = this.map(function(){ + if ( jQuery.browser.msie && !jQuery.isXMLDoc(this) ) { + // IE copies events bound via attachEvent when + // using cloneNode. Calling detachEvent on the + // clone will also remove the events from the orignal + // In order to get around this, we use innerHTML. + // Unfortunately, this means some modifications to + // attributes in IE that are actually only stored + // as properties will not be copied (such as the + // the name attribute on an input). + var clone = this.cloneNode(true), + container = document.createElement("div"), + container2 = document.createElement("div"); + container.appendChild(clone); + container2.innerHTML = container.innerHTML; + return container2.firstChild; + } else + return this.cloneNode(true); + }); + + // Need to set the expando to null on the cloned set if it exists + // removeData doesn't work here, IE removes it from the original as well + // this is primarily for IE but the data expando shouldn't be copied over in any browser + var clone = ret.find("*").andSelf().each(function(){ + if ( this[ expando ] != undefined ) + this[ expando ] = null; + }); + + // Copy the events from the original to the clone + if ( events === true ) + this.find("*").andSelf().each(function(i){ + var events = jQuery.data( this, "events" ); + + for ( var type in events ) + for ( var handler in events[ type ] ) + jQuery.event.add( clone[ i ], type, events[ type ][ handler ], events[ type ][ handler ].data ); + }); + + // Return the cloned set + return ret; + }, + + filter: function( selector ) { + return this.pushStack( + jQuery.isFunction( selector ) && + jQuery.grep(this, function(elem, i){ + return selector.call( elem, i ); + }) || + + jQuery.multiFilter( selector, this ) ); + }, + + not: function( selector ) { + if ( selector.constructor == String ) + // test special case where just one selector is passed in + if ( isSimple.test( selector ) ) + return this.pushStack( jQuery.multiFilter( selector, this, true ) ); + else + selector = jQuery.multiFilter( selector, this ); + + var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType; + return this.filter(function() { + return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector; + }); + }, + + add: function( selector ) { + return !selector ? this : this.pushStack( jQuery.merge( + this.get(), + selector.constructor == String ? + jQuery( selector ).get() : + selector.length != undefined && (!selector.nodeName || jQuery.nodeName(selector, "form")) ? + selector : [selector] ) ); + }, + + is: function( selector ) { + return selector ? + jQuery.multiFilter( selector, this ).length > 0 : + false; + }, + + hasClass: function( selector ) { + return this.is( "." + selector ); + }, + + val: function( value ) { + if ( value == undefined ) { + + if ( this.length ) { + var elem = this[0]; + + // We need to handle select boxes special + if ( jQuery.nodeName( elem, "select" ) ) { + var index = elem.selectedIndex, + values = [], + options = elem.options, + one = elem.type == "select-one"; + + // Nothing was selected + if ( index < 0 ) + return null; + + // Loop through all the selected options + for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { + var option = options[ i ]; + + if ( option.selected ) { + // Get the specifc value for the option + value = jQuery.browser.msie && !option.attributes.value.specified ? option.text : option.value; + + // We don't need an array for one selects + if ( one ) + return value; + + // Multi-Selects return an array + values.push( value ); + } + } + + return values; + + // Everything else, we just grab the value + } else + return (this[0].value || "").replace(/\r/g, ""); + + } + + return undefined; + } + + return this.each(function(){ + if ( this.nodeType != 1 ) + return; + + if ( value.constructor == Array && /radio|checkbox/.test( this.type ) ) + this.checked = (jQuery.inArray(this.value, value) >= 0 || + jQuery.inArray(this.name, value) >= 0); + + else if ( jQuery.nodeName( this, "select" ) ) { + var values = value.constructor == Array ? + value : + [ value ]; + + jQuery( "option", this ).each(function(){ + this.selected = (jQuery.inArray( this.value, values ) >= 0 || + jQuery.inArray( this.text, values ) >= 0); + }); + + if ( !values.length ) + this.selectedIndex = -1; + + } else + this.value = value; + }); + }, + + html: function( value ) { + return value == undefined ? + (this.length ? + this[0].innerHTML : + null) : + this.empty().append( value ); + }, + + replaceWith: function( value ) { + return this.after( value ).remove(); + }, + + eq: function( i ) { + return this.slice( i, i + 1 ); + }, + + slice: function() { + return this.pushStack( Array.prototype.slice.apply( this, arguments ) ); + }, + + map: function( callback ) { + return this.pushStack( jQuery.map(this, function(elem, i){ + return callback.call( elem, i, elem ); + })); + }, + + andSelf: function() { + return this.add( this.prevObject ); + }, + + domManip: function( args, table, reverse, callback ) { + var clone = this.length > 1, elems; + + return this.each(function(){ + if ( !elems ) { + elems = jQuery.clean( args, this.ownerDocument ); + + if ( reverse ) + elems.reverse(); + } + + var obj = this; + + if ( table && jQuery.nodeName( this, "table" ) && jQuery.nodeName( elems[0], "tr" ) ) + obj = this.getElementsByTagName("tbody")[0] || this.appendChild( this.ownerDocument.createElement("tbody") ); + + var scripts = jQuery( [] ); + + jQuery.each(elems, function(){ + var elem = clone ? + this.cloneNode( true ) : + this; + + // execute all scripts after the elements have been injected + if ( jQuery.nodeName( elem, "script" ) ) { + scripts = scripts.add( elem ); + } else { + // Remove any inner scripts for later evaluation + if ( elem.nodeType == 1 ) + scripts = scripts.add( jQuery( "script", elem ).remove() ); + + // Inject the elements into the document + callback.call( obj, elem ); + } + }); + + scripts.each( evalScript ); + }); + } +}; + +// Give the init function the jQuery prototype for later instantiation +jQuery.prototype.init.prototype = jQuery.prototype; + +function evalScript( i, elem ) { + if ( elem.src ) + jQuery.ajax({ + url: elem.src, + async: false, + dataType: "script" + }); + + else + jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); + + if ( elem.parentNode ) + elem.parentNode.removeChild( elem ); +} + +jQuery.extend = jQuery.fn.extend = function() { + // copy reference to target object + var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options; + + // Handle a deep copy situation + if ( target.constructor == Boolean ) { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target != "object" && typeof target != "function" ) + target = {}; + + // extend jQuery itself if only one argument is passed + if ( length == 1 ) { + target = this; + i = 0; + } + + for ( ; i < length; i++ ) + // Only deal with non-null/undefined values + if ( (options = arguments[ i ]) != null ) + // Extend the base object + for ( var name in options ) { + // Prevent never-ending loop + if ( target === options[ name ] ) + continue; + + // Recurse if we're merging object values + if ( deep && options[ name ] && typeof options[ name ] == "object" && target[ name ] && !options[ name ].nodeType ) + target[ name ] = jQuery.extend( target[ name ], options[ name ] ); + + // Don't bring in undefined values + else if ( options[ name ] != undefined ) + target[ name ] = options[ name ]; + + } + + // Return the modified object + return target; +}; + +var expando = "jQuery" + (new Date()).getTime(), uuid = 0, windowData = {}; + +// exclude the following css properties to add px +var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i; + +jQuery.extend({ + noConflict: function( deep ) { + window.$ = _$; + + if ( deep ) + window.jQuery = _jQuery; + + return jQuery; + }, + + // This may seem like some crazy code, but trust me when I say that this + // is the only cross-browser way to do this. --John + isFunction: function( fn ) { + return !!fn && typeof fn != "string" && !fn.nodeName && + fn.constructor != Array && /function/i.test( fn + "" ); + }, + + // check if an element is in a (or is an) XML document + isXMLDoc: function( elem ) { + return elem.documentElement && !elem.body || + elem.tagName && elem.ownerDocument && !elem.ownerDocument.body; + }, + + // Evalulates a script in a global context + globalEval: function( data ) { + data = jQuery.trim( data ); + + if ( data ) { + // Inspired by code by Andrea Giammarchi + // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html + var head = document.getElementsByTagName("head")[0] || document.documentElement, + script = document.createElement("script"); + + script.type = "text/javascript"; + if ( jQuery.browser.msie ) + script.text = data; + else + script.appendChild( document.createTextNode( data ) ); + + head.appendChild( script ); + head.removeChild( script ); + } + }, + + nodeName: function( elem, name ) { + return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase(); + }, + + cache: {}, + + data: function( elem, name, data ) { + elem = elem == window ? + windowData : + elem; + + var id = elem[ expando ]; + + // Compute a unique ID for the element + if ( !id ) + id = elem[ expando ] = ++uuid; + + // Only generate the data cache if we're + // trying to access or manipulate it + if ( name && !jQuery.cache[ id ] ) + jQuery.cache[ id ] = {}; + + // Prevent overriding the named cache with undefined values + if ( data != undefined ) + jQuery.cache[ id ][ name ] = data; + + // Return the named cache data, or the ID for the element + return name ? + jQuery.cache[ id ][ name ] : + id; + }, + + removeData: function( elem, name ) { + elem = elem == window ? + windowData : + elem; + + var id = elem[ expando ]; + + // If we want to remove a specific section of the element's data + if ( name ) { + if ( jQuery.cache[ id ] ) { + // Remove the section of cache data + delete jQuery.cache[ id ][ name ]; + + // If we've removed all the data, remove the element's cache + name = ""; + + for ( name in jQuery.cache[ id ] ) + break; + + if ( !name ) + jQuery.removeData( elem ); + } + + // Otherwise, we want to remove all of the element's data + } else { + // Clean up the element expando + try { + delete elem[ expando ]; + } catch(e){ + // IE has trouble directly removing the expando + // but it's ok with using removeAttribute + if ( elem.removeAttribute ) + elem.removeAttribute( expando ); + } + + // Completely remove the data cache + delete jQuery.cache[ id ]; + } + }, + + // args is for internal usage only + each: function( object, callback, args ) { + if ( args ) { + if ( object.length == undefined ) + for ( var name in object ) + callback.apply( object[ name ], args ); + else + for ( var i = 0, length = object.length; i < length; i++ ) + if ( callback.apply( object[ i ], args ) === false ) + break; + + // A special, fast, case for the most common use of each + } else { + if ( object.length == undefined ) + for ( var name in object ) + callback.call( object[ name ], name, object[ name ] ); + else + for ( var i = 0, length = object.length, value = object[0]; + i < length && callback.call( value, i, value ) !== false; value = object[++i] ){} + } + + return object; + }, + + prop: function( elem, value, type, i, name ) { + // Handle executable functions + if ( jQuery.isFunction( value ) ) + value = value.call( elem, i ); + + // Handle passing in a number to a CSS property + return value && value.constructor == Number && type == "curCSS" && !exclude.test( name ) ? + value + "px" : + value; + }, + + className: { + // internal only, use addClass("class") + add: function( elem, classNames ) { + jQuery.each((classNames || "").split(/\s+/), function(i, className){ + if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) ) + elem.className += (elem.className ? " " : "") + className; + }); + }, + + // internal only, use removeClass("class") + remove: function( elem, classNames ) { + if (elem.nodeType == 1) + elem.className = classNames != undefined ? + jQuery.grep(elem.className.split(/\s+/), function(className){ + return !jQuery.className.has( classNames, className ); + }).join(" ") : + ""; + }, + + // internal only, use is(".class") + has: function( elem, className ) { + return jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1; + } + }, + + // A method for quickly swapping in/out CSS properties to get correct calculations + swap: function( elem, options, callback ) { + var old = {}; + // Remember the old values, and insert the new ones + for ( var name in options ) { + old[ name ] = elem.style[ name ]; + elem.style[ name ] = options[ name ]; + } + + callback.call( elem ); + + // Revert the old values + for ( var name in options ) + elem.style[ name ] = old[ name ]; + }, + + css: function( elem, name, force ) { + if ( name == "width" || name == "height" ) { + var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ]; + + function getWH() { + val = name == "width" ? elem.offsetWidth : elem.offsetHeight; + var padding = 0, border = 0; + jQuery.each( which, function() { + padding += parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0; + border += parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0; + }); + val -= Math.round(padding + border); + } + + if ( jQuery(elem).is(":visible") ) + getWH(); + else + jQuery.swap( elem, props, getWH ); + + return Math.max(0, val); + } + + return jQuery.curCSS( elem, name, force ); + }, + + curCSS: function( elem, name, force ) { + var ret; + + // A helper method for determining if an element's values are broken + function color( elem ) { + if ( !jQuery.browser.safari ) + return false; + + var ret = document.defaultView.getComputedStyle( elem, null ); + return !ret || ret.getPropertyValue("color") == ""; + } + + // We need to handle opacity special in IE + if ( name == "opacity" && jQuery.browser.msie ) { + ret = jQuery.attr( elem.style, "opacity" ); + + return ret == "" ? + "1" : + ret; + } + // Opera sometimes will give the wrong display answer, this fixes it, see #2037 + if ( jQuery.browser.opera && name == "display" ) { + var save = elem.style.display; + elem.style.display = "block"; + elem.style.display = save; + } + + // Make sure we're using the right name for getting the float value + if ( name.match( /float/i ) ) + name = styleFloat; + + if ( !force && elem.style[ name ] ) + ret = elem.style[ name ]; + + else if ( document.defaultView && document.defaultView.getComputedStyle ) { + + // Only "float" is needed here + if ( name.match( /float/i ) ) + name = "float"; + + name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase(); + + var getComputedStyle = document.defaultView.getComputedStyle( elem, null ); + + if ( getComputedStyle && !color( elem ) ) + ret = getComputedStyle.getPropertyValue( name ); + + // If the element isn't reporting its values properly in Safari + // then some display: none elements are involved + else { + var swap = [], stack = []; + + // Locate all of the parent display: none elements + for ( var a = elem; a && color(a); a = a.parentNode ) + stack.unshift(a); + + // Go through and make them visible, but in reverse + // (It would be better if we knew the exact display type that they had) + for ( var i = 0; i < stack.length; i++ ) + if ( color( stack[ i ] ) ) { + swap[ i ] = stack[ i ].style.display; + stack[ i ].style.display = "block"; + } + + // Since we flip the display style, we have to handle that + // one special, otherwise get the value + ret = name == "display" && swap[ stack.length - 1 ] != null ? + "none" : + ( getComputedStyle && getComputedStyle.getPropertyValue( name ) ) || ""; + + // Finally, revert the display styles back + for ( var i = 0; i < swap.length; i++ ) + if ( swap[ i ] != null ) + stack[ i ].style.display = swap[ i ]; + } + + // We should always get a number back from opacity + if ( name == "opacity" && ret == "" ) + ret = "1"; + + } else if ( elem.currentStyle ) { + var camelCase = name.replace(/\-(\w)/g, function(all, letter){ + return letter.toUpperCase(); + }); + + ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ]; + + // From the awesome hack by Dean Edwards + // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 + + // If we're not dealing with a regular pixel number + // but a number that has a weird ending, we need to convert it to pixels + if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) { + // Remember the original values + var style = elem.style.left, runtimeStyle = elem.runtimeStyle.left; + + // Put in the new values to get a computed value out + elem.runtimeStyle.left = elem.currentStyle.left; + elem.style.left = ret || 0; + ret = elem.style.pixelLeft + "px"; + + // Revert the changed values + elem.style.left = style; + elem.runtimeStyle.left = runtimeStyle; + } + } + + return ret; + }, + + clean: function( elems, context ) { + var ret = []; + context = context || document; + // !context.createElement fails in IE with an error but returns typeof 'object' + if (typeof context.createElement == 'undefined') + context = context.ownerDocument || context[0] && context[0].ownerDocument || document; + + jQuery.each(elems, function(i, elem){ + if ( !elem ) + return; + + if ( elem.constructor == Number ) + elem = elem.toString(); + + // Convert html string into DOM nodes + if ( typeof elem == "string" ) { + // Fix "XHTML"-style tags in all browsers + elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){ + return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area)$/i) ? + all : + front + ">"; + }); + + // Trim whitespace, otherwise indexOf won't work as expected + var tags = jQuery.trim( elem ).toLowerCase(), div = context.createElement("div"); + + var wrap = + // option or optgroup + !tags.indexOf("", "" ] || + + !tags.indexOf("", "" ] || + + tags.match(/^<(thead|tbody|tfoot|colg|cap)/) && + [ 1, "", "
" ] || + + !tags.indexOf("", "" ] || + + // matched above + (!tags.indexOf("", "" ] || + + !tags.indexOf("", "" ] || + + // IE can't serialize and + diff --git a/test/jquery.js b/test/jquery.js deleted file mode 100644 index 3a90b3a4b..000000000 --- a/test/jquery.js +++ /dev/null @@ -1,3331 +0,0 @@ -(function(){ -/* - * jQuery 1.2.2b - New Wave Javascript - * - * Copyright (c) 2007 John Resig (jquery.com) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. - * - * $Date: 2007-12-19 12:23:46 -0600 (Wed, 19 Dec 2007) $ - * $Rev: 4236 $ - */ - -// Map over jQuery in case of overwrite -if ( window.jQuery ) - var _jQuery = window.jQuery; - -var jQuery = window.jQuery = function( selector, context ) { - // The jQuery object is actually just the init constructor 'enhanced' - return new jQuery.prototype.init( selector, context ); -}; - -// Map over the $ in case of overwrite -if ( window.$ ) - var _$ = window.$; - -// Map the jQuery namespace to the '$' one -window.$ = jQuery; - -// A simple way to check for HTML strings or ID strings -// (both of which we optimize for) -var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/; - -// Is it a simple selector -var isSimple = /^.[^:#\[\.]*$/; - -jQuery.fn = jQuery.prototype = { - init: function( selector, context ) { - // Make sure that a selection was provided - selector = selector || document; - - // Handle $(DOMElement) - if ( selector.nodeType ) { - this[0] = selector; - this.length = 1; - return this; - - // Handle HTML strings - } else if ( typeof selector == "string" ) { - // Are we dealing with HTML string or an ID? - var match = quickExpr.exec( selector ); - - // Verify a match, and that no context was specified for #id - if ( match && (match[1] || !context) ) { - - // HANDLE: $(html) -> $(array) - if ( match[1] ) - selector = jQuery.clean( [ match[1] ], context ); - - // HANDLE: $("#id") - else { - var elem = document.getElementById( match[3] ); - - // Make sure an element was located - if ( elem ) - // Handle the case where IE and Opera return items - // by name instead of ID - if ( elem.id != match[3] ) - return jQuery().find( selector ); - - // Otherwise, we inject the element directly into the jQuery object - else { - this[0] = elem; - this.length = 1; - return this; - } - - else - selector = []; - } - - // HANDLE: $(expr, [context]) - // (which is just equivalent to: $(content).find(expr) - } else - return new jQuery( context ).find( selector ); - - // HANDLE: $(function) - // Shortcut for document ready - } else if ( jQuery.isFunction( selector ) ) - return new jQuery( document )[ jQuery.fn.ready ? "ready" : "load" ]( selector ); - - return this.setArray( - // HANDLE: $(array) - selector.constructor == Array && selector || - - // HANDLE: $(arraylike) - // Watch for when an array-like object, contains DOM nodes, is passed in as the selector - (selector.jquery || selector.length && selector != window && !selector.nodeType && selector[0] != undefined && selector[0].nodeType) && jQuery.makeArray( selector ) || - - // HANDLE: $(*) - [ selector ] ); - }, - - // The current version of jQuery being used - jquery: "1.2.2b", - - // The number of elements contained in the matched element set - size: function() { - return this.length; - }, - - // The number of elements contained in the matched element set - length: 0, - - // Get the Nth element in the matched element set OR - // Get the whole matched element set as a clean array - get: function( num ) { - return num == undefined ? - - // Return a 'clean' array - jQuery.makeArray( this ) : - - // Return just the object - this[ num ]; - }, - - // Take an array of elements and push it onto the stack - // (returning the new matched element set) - pushStack: function( elems ) { - // Build a new jQuery matched element set - var ret = jQuery( elems ); - - // Add the old object onto the stack (as a reference) - ret.prevObject = this; - - // Return the newly-formed element set - return ret; - }, - - // Force the current matched set of elements to become - // the specified array of elements (destroying the stack in the process) - // You should use pushStack() in order to do this, but maintain the stack - setArray: function( elems ) { - // Resetting the length to 0, then using the native Array push - // is a super-fast way to populate an object with array-like properties - this.length = 0; - Array.prototype.push.apply( this, elems ); - - return this; - }, - - // Execute a callback for every element in the matched set. - // (You can seed the arguments with an array of args, but this is - // only used internally.) - each: function( callback, args ) { - return jQuery.each( this, callback, args ); - }, - - // Determine the position of an element within - // the matched set of elements - index: function( elem ) { - var ret = -1; - - // Locate the position of the desired element - this.each(function(i){ - if ( this == elem ) - ret = i; - }); - - return ret; - }, - - attr: function( name, value, type ) { - var options = name; - - // Look for the case where we're accessing a style value - if ( name.constructor == String ) - if ( value == undefined ) - return this.length && jQuery[ type || "attr" ]( this[0], name ) || undefined; - - else { - options = {}; - options[ name ] = value; - } - - // Check to see if we're setting style values - return this.each(function(i){ - // Set all the styles - for ( name in options ) - jQuery.attr( - type ? - this.style : - this, - name, jQuery.prop( this, options[ name ], type, i, name ) - ); - }); - }, - - css: function( key, value ) { - // ignore negative width and height values - if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 ) - value = undefined; - return this.attr( key, value, "curCSS" ); - }, - - text: function( text ) { - if ( typeof text != "object" && text != null ) - return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); - - var ret = ""; - - jQuery.each( text || this, function(){ - jQuery.each( this.childNodes, function(){ - if ( this.nodeType != 8 ) - ret += this.nodeType != 1 ? - this.nodeValue : - jQuery.fn.text( [ this ] ); - }); - }); - - return ret; - }, - - wrapAll: function( html ) { - if ( this[0] ) - // The elements to wrap the target around - jQuery( html, this[0].ownerDocument ) - .clone() - .insertBefore( this[0] ) - .map(function(){ - var elem = this; - - while ( elem.firstChild ) - elem = elem.firstChild; - - return elem; - }) - .append(this); - - return this; - }, - - wrapInner: function( html ) { - return this.each(function(){ - jQuery( this ).contents().wrapAll( html ); - }); - }, - - wrap: function( html ) { - return this.each(function(){ - jQuery( this ).wrapAll( html ); - }); - }, - - append: function() { - return this.domManip(arguments, true, false, function(elem){ - if (this.nodeType == 1) - this.appendChild( elem ); - }); - }, - - prepend: function() { - return this.domManip(arguments, true, true, function(elem){ - if (this.nodeType == 1) - this.insertBefore( elem, this.firstChild ); - }); - }, - - before: function() { - return this.domManip(arguments, false, false, function(elem){ - this.parentNode.insertBefore( elem, this ); - }); - }, - - after: function() { - return this.domManip(arguments, false, true, function(elem){ - this.parentNode.insertBefore( elem, this.nextSibling ); - }); - }, - - end: function() { - return this.prevObject || jQuery( [] ); - }, - - find: function( selector ) { - var elems = jQuery.map(this, function(elem){ - return jQuery.find( selector, elem ); - }); - - return this.pushStack( /[^+>] [^+>]/.test( selector ) || selector.indexOf("..") > -1 ? - jQuery.unique( elems ) : - elems ); - }, - - clone: function( events ) { - // Do the clone - var ret = this.map(function(){ - if ( jQuery.browser.msie && !jQuery.isXMLDoc(this) ) { - // IE copies events bound via attachEvent when - // using cloneNode. Calling detachEvent on the - // clone will also remove the events from the orignal - // In order to get around this, we use innerHTML. - // Unfortunately, this means some modifications to - // attributes in IE that are actually only stored - // as properties will not be copied (such as the - // the name attribute on an input). - var clone = this.cloneNode(true), - container = document.createElement("div"), - container2 = document.createElement("div"); - container.appendChild(clone); - container2.innerHTML = container.innerHTML; - return container2.firstChild; - } else - return this.cloneNode(true); - }); - - // Need to set the expando to null on the cloned set if it exists - // removeData doesn't work here, IE removes it from the original as well - // this is primarily for IE but the data expando shouldn't be copied over in any browser - var clone = ret.find("*").andSelf().each(function(){ - if ( this[ expando ] != undefined ) - this[ expando ] = null; - }); - - // Copy the events from the original to the clone - if ( events === true ) - this.find("*").andSelf().each(function(i){ - var events = jQuery.data( this, "events" ); - - for ( var type in events ) - for ( var handler in events[ type ] ) - jQuery.event.add( clone[ i ], type, events[ type ][ handler ], events[ type ][ handler ].data ); - }); - - // Return the cloned set - return ret; - }, - - filter: function( selector ) { - return this.pushStack( - jQuery.isFunction( selector ) && - jQuery.grep(this, function(elem, i){ - return selector.call( elem, i ); - }) || - - jQuery.multiFilter( selector, this ) ); - }, - - not: function( selector ) { - if ( selector.constructor == String ) - // test special case where just one selector is passed in - if ( isSimple.test( selector ) ) - return this.pushStack( jQuery.multiFilter( selector, this, true ) ); - else - selector = jQuery.multiFilter( selector, this ); - - var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType; - return this.filter(function() { - return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector; - }); - }, - - add: function( selector ) { - return !selector ? this : this.pushStack( jQuery.merge( - this.get(), - selector.constructor == String ? - jQuery( selector ).get() : - selector.length != undefined && (!selector.nodeName || jQuery.nodeName(selector, "form")) ? - selector : [selector] ) ); - }, - - is: function( selector ) { - return selector ? - jQuery.multiFilter( selector, this ).length > 0 : - false; - }, - - hasClass: function( selector ) { - return this.is( "." + selector ); - }, - - val: function( value ) { - if ( value == undefined ) { - - if ( this.length ) { - var elem = this[0]; - - // We need to handle select boxes special - if ( jQuery.nodeName( elem, "select" ) ) { - var index = elem.selectedIndex, - values = [], - options = elem.options, - one = elem.type == "select-one"; - - // Nothing was selected - if ( index < 0 ) - return null; - - // Loop through all the selected options - for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { - var option = options[ i ]; - - if ( option.selected ) { - // Get the specifc value for the option - value = jQuery.browser.msie && !option.attributes.value.specified ? option.text : option.value; - - // We don't need an array for one selects - if ( one ) - return value; - - // Multi-Selects return an array - values.push( value ); - } - } - - return values; - - // Everything else, we just grab the value - } else - return (this[0].value || "").replace(/\r/g, ""); - - } - - return undefined; - } - - return this.each(function(){ - if ( this.nodeType != 1 ) - return; - - if ( value.constructor == Array && /radio|checkbox/.test( this.type ) ) - this.checked = (jQuery.inArray(this.value, value) >= 0 || - jQuery.inArray(this.name, value) >= 0); - - else if ( jQuery.nodeName( this, "select" ) ) { - var values = value.constructor == Array ? - value : - [ value ]; - - jQuery( "option", this ).each(function(){ - this.selected = (jQuery.inArray( this.value, values ) >= 0 || - jQuery.inArray( this.text, values ) >= 0); - }); - - if ( !values.length ) - this.selectedIndex = -1; - - } else - this.value = value; - }); - }, - - html: function( value ) { - return value == undefined ? - (this.length ? - this[0].innerHTML : - null) : - this.empty().append( value ); - }, - - replaceWith: function( value ) { - return this.after( value ).remove(); - }, - - eq: function( i ) { - return this.slice( i, i + 1 ); - }, - - slice: function() { - return this.pushStack( Array.prototype.slice.apply( this, arguments ) ); - }, - - map: function( callback ) { - return this.pushStack( jQuery.map(this, function(elem, i){ - return callback.call( elem, i, elem ); - })); - }, - - andSelf: function() { - return this.add( this.prevObject ); - }, - - domManip: function( args, table, reverse, callback ) { - var clone = this.length > 1, elems; - - return this.each(function(){ - if ( !elems ) { - elems = jQuery.clean( args, this.ownerDocument ); - - if ( reverse ) - elems.reverse(); - } - - var obj = this; - - if ( table && jQuery.nodeName( this, "table" ) && jQuery.nodeName( elems[0], "tr" ) ) - obj = this.getElementsByTagName("tbody")[0] || this.appendChild( this.ownerDocument.createElement("tbody") ); - - var scripts = jQuery( [] ); - - jQuery.each(elems, function(){ - var elem = clone ? - this.cloneNode( true ) : - this; - - // execute all scripts after the elements have been injected - if ( jQuery.nodeName( elem, "script" ) ) { - scripts = scripts.add( elem ); - } else { - // Remove any inner scripts for later evaluation - if ( elem.nodeType == 1 ) - scripts = scripts.add( jQuery( "script", elem ).remove() ); - - // Inject the elements into the document - callback.call( obj, elem ); - } - }); - - scripts.each( evalScript ); - }); - } -}; - -// Give the init function the jQuery prototype for later instantiation -jQuery.prototype.init.prototype = jQuery.prototype; - -function evalScript( i, elem ) { - if ( elem.src ) - jQuery.ajax({ - url: elem.src, - async: false, - dataType: "script" - }); - - else - jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); - - if ( elem.parentNode ) - elem.parentNode.removeChild( elem ); -} - -jQuery.extend = jQuery.fn.extend = function() { - // copy reference to target object - var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options; - - // Handle a deep copy situation - if ( target.constructor == Boolean ) { - deep = target; - target = arguments[1] || {}; - // skip the boolean and the target - i = 2; - } - - // Handle case when target is a string or something (possible in deep copy) - if ( typeof target != "object" && typeof target != "function" ) - target = {}; - - // extend jQuery itself if only one argument is passed - if ( length == 1 ) { - target = this; - i = 0; - } - - for ( ; i < length; i++ ) - // Only deal with non-null/undefined values - if ( (options = arguments[ i ]) != null ) - // Extend the base object - for ( var name in options ) { - // Prevent never-ending loop - if ( target === options[ name ] ) - continue; - - // Recurse if we're merging object values - if ( deep && options[ name ] && typeof options[ name ] == "object" && target[ name ] && !options[ name ].nodeType ) - target[ name ] = jQuery.extend( target[ name ], options[ name ] ); - - // Don't bring in undefined values - else if ( options[ name ] != undefined ) - target[ name ] = options[ name ]; - - } - - // Return the modified object - return target; -}; - -var expando = "jQuery" + (new Date()).getTime(), uuid = 0, windowData = {}; - -// exclude the following css properties to add px -var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i; - -jQuery.extend({ - noConflict: function( deep ) { - window.$ = _$; - - if ( deep ) - window.jQuery = _jQuery; - - return jQuery; - }, - - // This may seem like some crazy code, but trust me when I say that this - // is the only cross-browser way to do this. --John - isFunction: function( fn ) { - return !!fn && typeof fn != "string" && !fn.nodeName && - fn.constructor != Array && /function/i.test( fn + "" ); - }, - - // check if an element is in a (or is an) XML document - isXMLDoc: function( elem ) { - return elem.documentElement && !elem.body || - elem.tagName && elem.ownerDocument && !elem.ownerDocument.body; - }, - - // Evalulates a script in a global context - globalEval: function( data ) { - data = jQuery.trim( data ); - - if ( data ) { - // Inspired by code by Andrea Giammarchi - // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html - var head = document.getElementsByTagName("head")[0] || document.documentElement, - script = document.createElement("script"); - - script.type = "text/javascript"; - if ( jQuery.browser.msie ) - script.text = data; - else - script.appendChild( document.createTextNode( data ) ); - - head.appendChild( script ); - head.removeChild( script ); - } - }, - - nodeName: function( elem, name ) { - return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase(); - }, - - cache: {}, - - data: function( elem, name, data ) { - elem = elem == window ? - windowData : - elem; - - var id = elem[ expando ]; - - // Compute a unique ID for the element - if ( !id ) - id = elem[ expando ] = ++uuid; - - // Only generate the data cache if we're - // trying to access or manipulate it - if ( name && !jQuery.cache[ id ] ) - jQuery.cache[ id ] = {}; - - // Prevent overriding the named cache with undefined values - if ( data != undefined ) - jQuery.cache[ id ][ name ] = data; - - // Return the named cache data, or the ID for the element - return name ? - jQuery.cache[ id ][ name ] : - id; - }, - - removeData: function( elem, name ) { - elem = elem == window ? - windowData : - elem; - - var id = elem[ expando ]; - - // If we want to remove a specific section of the element's data - if ( name ) { - if ( jQuery.cache[ id ] ) { - // Remove the section of cache data - delete jQuery.cache[ id ][ name ]; - - // If we've removed all the data, remove the element's cache - name = ""; - - for ( name in jQuery.cache[ id ] ) - break; - - if ( !name ) - jQuery.removeData( elem ); - } - - // Otherwise, we want to remove all of the element's data - } else { - // Clean up the element expando - try { - delete elem[ expando ]; - } catch(e){ - // IE has trouble directly removing the expando - // but it's ok with using removeAttribute - if ( elem.removeAttribute ) - elem.removeAttribute( expando ); - } - - // Completely remove the data cache - delete jQuery.cache[ id ]; - } - }, - - // args is for internal usage only - each: function( object, callback, args ) { - if ( args ) { - if ( object.length == undefined ) - for ( var name in object ) - callback.apply( object[ name ], args ); - else - for ( var i = 0, length = object.length; i < length; i++ ) - if ( callback.apply( object[ i ], args ) === false ) - break; - - // A special, fast, case for the most common use of each - } else { - if ( object.length == undefined ) - for ( var name in object ) - callback.call( object[ name ], name, object[ name ] ); - else - for ( var i = 0, length = object.length, value = object[0]; - i < length && callback.call( value, i, value ) !== false; value = object[++i] ){} - } - - return object; - }, - - prop: function( elem, value, type, i, name ) { - // Handle executable functions - if ( jQuery.isFunction( value ) ) - value = value.call( elem, i ); - - // Handle passing in a number to a CSS property - return value && value.constructor == Number && type == "curCSS" && !exclude.test( name ) ? - value + "px" : - value; - }, - - className: { - // internal only, use addClass("class") - add: function( elem, classNames ) { - jQuery.each((classNames || "").split(/\s+/), function(i, className){ - if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) ) - elem.className += (elem.className ? " " : "") + className; - }); - }, - - // internal only, use removeClass("class") - remove: function( elem, classNames ) { - if (elem.nodeType == 1) - elem.className = classNames != undefined ? - jQuery.grep(elem.className.split(/\s+/), function(className){ - return !jQuery.className.has( classNames, className ); - }).join(" ") : - ""; - }, - - // internal only, use is(".class") - has: function( elem, className ) { - return jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1; - } - }, - - // A method for quickly swapping in/out CSS properties to get correct calculations - swap: function( elem, options, callback ) { - var old = {}; - // Remember the old values, and insert the new ones - for ( var name in options ) { - old[ name ] = elem.style[ name ]; - elem.style[ name ] = options[ name ]; - } - - callback.call( elem ); - - // Revert the old values - for ( var name in options ) - elem.style[ name ] = old[ name ]; - }, - - css: function( elem, name, force ) { - if ( name == "width" || name == "height" ) { - var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ]; - - function getWH() { - val = name == "width" ? elem.offsetWidth : elem.offsetHeight; - var padding = 0, border = 0; - jQuery.each( which, function() { - padding += parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0; - border += parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0; - }); - val -= Math.round(padding + border); - } - - if ( jQuery(elem).is(":visible") ) - getWH(); - else - jQuery.swap( elem, props, getWH ); - - return Math.max(0, val); - } - - return jQuery.curCSS( elem, name, force ); - }, - - curCSS: function( elem, name, force ) { - var ret; - - // A helper method for determining if an element's values are broken - function color( elem ) { - if ( !jQuery.browser.safari ) - return false; - - var ret = document.defaultView.getComputedStyle( elem, null ); - return !ret || ret.getPropertyValue("color") == ""; - } - - // We need to handle opacity special in IE - if ( name == "opacity" && jQuery.browser.msie ) { - ret = jQuery.attr( elem.style, "opacity" ); - - return ret == "" ? - "1" : - ret; - } - // Opera sometimes will give the wrong display answer, this fixes it, see #2037 - if ( jQuery.browser.opera && name == "display" ) { - var save = elem.style.display; - elem.style.display = "block"; - elem.style.display = save; - } - - // Make sure we're using the right name for getting the float value - if ( name.match( /float/i ) ) - name = styleFloat; - - if ( !force && elem.style[ name ] ) - ret = elem.style[ name ]; - - else if ( document.defaultView && document.defaultView.getComputedStyle ) { - - // Only "float" is needed here - if ( name.match( /float/i ) ) - name = "float"; - - name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase(); - - var getComputedStyle = document.defaultView.getComputedStyle( elem, null ); - - if ( getComputedStyle && !color( elem ) ) - ret = getComputedStyle.getPropertyValue( name ); - - // If the element isn't reporting its values properly in Safari - // then some display: none elements are involved - else { - var swap = [], stack = []; - - // Locate all of the parent display: none elements - for ( var a = elem; a && color(a); a = a.parentNode ) - stack.unshift(a); - - // Go through and make them visible, but in reverse - // (It would be better if we knew the exact display type that they had) - for ( var i = 0; i < stack.length; i++ ) - if ( color( stack[ i ] ) ) { - swap[ i ] = stack[ i ].style.display; - stack[ i ].style.display = "block"; - } - - // Since we flip the display style, we have to handle that - // one special, otherwise get the value - ret = name == "display" && swap[ stack.length - 1 ] != null ? - "none" : - ( getComputedStyle && getComputedStyle.getPropertyValue( name ) ) || ""; - - // Finally, revert the display styles back - for ( var i = 0; i < swap.length; i++ ) - if ( swap[ i ] != null ) - stack[ i ].style.display = swap[ i ]; - } - - // We should always get a number back from opacity - if ( name == "opacity" && ret == "" ) - ret = "1"; - - } else if ( elem.currentStyle ) { - var camelCase = name.replace(/\-(\w)/g, function(all, letter){ - return letter.toUpperCase(); - }); - - ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ]; - - // From the awesome hack by Dean Edwards - // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 - - // If we're not dealing with a regular pixel number - // but a number that has a weird ending, we need to convert it to pixels - if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) { - // Remember the original values - var style = elem.style.left, runtimeStyle = elem.runtimeStyle.left; - - // Put in the new values to get a computed value out - elem.runtimeStyle.left = elem.currentStyle.left; - elem.style.left = ret || 0; - ret = elem.style.pixelLeft + "px"; - - // Revert the changed values - elem.style.left = style; - elem.runtimeStyle.left = runtimeStyle; - } - } - - return ret; - }, - - clean: function( elems, context ) { - var ret = []; - context = context || document; - // !context.createElement fails in IE with an error but returns typeof 'object' - if (typeof context.createElement == 'undefined') - context = context.ownerDocument || context[0] && context[0].ownerDocument || document; - - jQuery.each(elems, function(i, elem){ - if ( !elem ) - return; - - if ( elem.constructor == Number ) - elem = elem.toString(); - - // Convert html string into DOM nodes - if ( typeof elem == "string" ) { - // Fix "XHTML"-style tags in all browsers - elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){ - return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area)$/i) ? - all : - front + ">"; - }); - - // Trim whitespace, otherwise indexOf won't work as expected - var tags = jQuery.trim( elem ).toLowerCase(), div = context.createElement("div"); - - var wrap = - // option or optgroup - !tags.indexOf("", "" ] || - - !tags.indexOf("", "" ] || - - tags.match(/^<(thead|tbody|tfoot|colg|cap)/) && - [ 1, "", "
" ] || - - !tags.indexOf("", "" ] || - - // matched above - (!tags.indexOf("", "" ] || - - !tags.indexOf("", "" ] || - - // IE can't serialize and From e43f46b11110f92c749413284cc8749c8af45334 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Fri, 12 Feb 2010 17:05:51 -0600 Subject: [PATCH 010/136] updatin readme and license --- ChangeLog.markdown | 1 - LICENSE.txt | 20 ++++++++++++ README.markdown | 17 ++++++++-- jquery.mousewheel.js | 74 ++++++++++++++++++++++---------------------- 4 files changed, 72 insertions(+), 40 deletions(-) create mode 100644 LICENSE.txt diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 8dd106beb..af82a30b9 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,6 +1,5 @@ # Mouse Wheel ChangeLog - # 3.0.2 * Fixed delta being opposite value in latest Opera diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 000000000..74c597096 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,20 @@ +Copyright 2010, Brandon Aaron (http://brandonaaron.net/) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.markdown b/README.markdown index 7ec6d039b..cd849886a 100644 --- a/README.markdown +++ b/README.markdown @@ -2,10 +2,23 @@ A jQuery plugin that adds cross-browser mouse wheel support. -The latest stable release can be downloaded from the [project page](http://plugins.jquery.com/project/mousewheel) +In order to use the plugin, simply bind the "mousewheel" event to an element. It also provides two helper methods called `mousewheel` and `unmousewheel` that act just like other event helper methods in jQuery. The event callback receives an extra argument which is the normalized "delta" of the mouse wheel. + +Here is an example of using both the bind and helper method syntax. + + // using bind + $('#my_elem').bind('mousewheel', function(event, delta) { + console.log(delta); + }); + + // using the event helper + $('#my_elem').mousewheel(function(event, delta) { + console.log(delta); + }); + ## License -The mousewheel plugin is dual licensed *(just like jQuery)* under the [MIT](http://www.opensource.org/licenses/mit-license.php) and [GPL](http://www.opensource.org/licenses/gpl-license.php) licenses. +The expandable plugin is licensed under the MIT License (LICENSE.txt). Copyright (c) 2009 [Brandon Aaron](http://brandonaaron.net) \ No newline at end of file diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index b6b89ba60..9a9865731 100644 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -1,10 +1,10 @@ -/*! Copyright (c) 2009 Brandon Aaron (http://brandonaaron.net) - * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) - * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. +/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net) + * Licensed under the MIT License (LICENSE.txt). + * * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers. * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. * - * Version: 3.0.2 + * Version: 3.0.3-pre * * Requires: 1.2.2+ */ @@ -14,47 +14,47 @@ var types = ['DOMMouseScroll', 'mousewheel']; $.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; - } + 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; + } }; $.fn.extend({ - mousewheel: function(fn) { - return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel"); - }, - - unmousewheel: function(fn) { - return this.unbind("mousewheel", fn); - } + mousewheel: function(fn) { + return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel"); + }, + + unmousewheel: function(fn) { + return this.unbind("mousewheel", fn); + } }); function handler(event) { - var args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true; - - event = $.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); + var args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true; + + event = $.event.fix(event || window.event); + event.type = "mousewheel"; + + if ( event.wheelDelta ) delta = event.wheelDelta/120; + if ( event.detail ) delta = -event.detail/3; + + // Add event and delta to the front of the arguments + args.unshift(event, delta); - return $.event.handle.apply(this, args); + return $.event.handle.apply(this, args); } })(jQuery); \ No newline at end of file From 9ceaad61e51b967f1123443935362251536271ab Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Sun, 14 Feb 2010 21:24:32 -0700 Subject: [PATCH 011/136] Updating copyright --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index cd849886a..583d19e47 100644 --- a/README.markdown +++ b/README.markdown @@ -21,4 +21,4 @@ Here is an example of using both the bind and helper method syntax. The expandable plugin is licensed under the MIT License (LICENSE.txt). -Copyright (c) 2009 [Brandon Aaron](http://brandonaaron.net) \ No newline at end of file +Copyright (c) 2010 [Brandon Aaron](http://brandonaaron.net) \ No newline at end of file From dbdbb866676fd8467620ede20f37f6e4918c34b3 Mon Sep 17 00:00:00 2001 From: Seamus Leahy Date: Sun, 14 Feb 2010 22:40:25 -0500 Subject: [PATCH 012/136] Adding deltaX and deltaY for horizontal scrolling --- jquery.mousewheel.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index 9a9865731..126c90542 100644 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -43,16 +43,31 @@ $.fn.extend({ function handler(event) { - var args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true; + var orgEvent = event; + var args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0; event = $.event.fix(event || window.event); event.type = "mousewheel"; + // Old school scrollwheel delta if ( event.wheelDelta ) delta = event.wheelDelta/120; if ( event.detail ) delta = -event.detail/3; + // New school multidimensional scroll (touchpads) deltas + deltaY = delta; + + // Gecko + if( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) { + deltaY = 0; + deltaX = -1*delta; + } + + // Webkit + if( orgEvent.wheelDeltaY !== undefined ) deltaY = orgEvent.wheelDeltaY/120; + if( orgEvent.wheelDeltaX !== undefined ) deltaX = -1*orgEvent.wheelDeltaX/120; + // Add event and delta to the front of the arguments - args.unshift(event, delta); + args.unshift(event, delta, deltaX, deltaY); return $.event.handle.apply(this, args); } From 3b4d81a8f0c3f7b5119f13d9efd07825893aeeaf Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Mon, 23 Aug 2010 07:56:18 -0500 Subject: [PATCH 013/136] White space changes and adding thanks statement to header comment --- jquery.mousewheel.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index 126c90542..7035f9f81 100644 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -3,6 +3,7 @@ * * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers. * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. + * Thanks to: Seamus Leahy for adding deltaX and deltaY * * Version: 3.0.3-pre * @@ -43,8 +44,7 @@ $.fn.extend({ function handler(event) { - var orgEvent = event; - var args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0; + var orgEvent = event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0; event = $.event.fix(event || window.event); event.type = "mousewheel"; @@ -57,18 +57,18 @@ function handler(event) { deltaY = delta; // Gecko - if( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) { - deltaY = 0; - deltaX = -1*delta; + if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) { + deltaY = 0; + deltaX = -1*delta; } // Webkit - if( orgEvent.wheelDeltaY !== undefined ) deltaY = orgEvent.wheelDeltaY/120; - if( orgEvent.wheelDeltaX !== undefined ) deltaX = -1*orgEvent.wheelDeltaX/120; + if ( orgEvent.wheelDeltaY !== undefined ) deltaY = orgEvent.wheelDeltaY/120; + if ( orgEvent.wheelDeltaX !== undefined ) deltaX = -1*orgEvent.wheelDeltaX/120; // Add event and delta to the front of the arguments args.unshift(event, delta, deltaX, deltaY); - + return $.event.handle.apply(this, args); } From 59a6b4319d1d2ced2e0504854bec9693aed1c57f Mon Sep 17 00:00:00 2001 From: Seamus Leahy Date: Sun, 14 Feb 2010 22:42:19 -0500 Subject: [PATCH 014/136] Updating tests with deltaX and deltaY --- test/index.html | 172 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 143 insertions(+), 29 deletions(-) diff --git a/test/index.html b/test/index.html index ce716a40e..ed2da733c 100644 --- a/test/index.html +++ b/test/index.html @@ -8,7 +8,7 @@ From 8b9dcb784c6a180fa16ec0068bf5ca8104d18100 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Mon, 23 Aug 2010 08:03:15 -0500 Subject: [PATCH 015/136] Adding curly braces --- jquery.mousewheel.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index 7035f9f81..e14438c6b 100644 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -16,19 +16,23 @@ var types = ['DOMMouseScroll', 'mousewheel']; $.event.special.mousewheel = { setup: function() { - if ( this.addEventListener ) - for ( var i=types.length; i; ) + if ( this.addEventListener ) { + for ( var i=types.length; i; ) { this.addEventListener( types[--i], handler, false ); - else + } + } else { this.onmousewheel = handler; + } }, teardown: function() { - if ( this.removeEventListener ) - for ( var i=types.length; i; ) + if ( this.removeEventListener ) { + for ( var i=types.length; i; ) { this.removeEventListener( types[--i], handler, false ); - else + } + } else { this.onmousewheel = null; + } } }; @@ -50,8 +54,8 @@ function handler(event) { event.type = "mousewheel"; // Old school scrollwheel delta - if ( event.wheelDelta ) delta = event.wheelDelta/120; - if ( event.detail ) delta = -event.detail/3; + if ( event.wheelDelta ) { delta = event.wheelDelta/120; } + if ( event.detail ) { delta = -event.detail/3; } // New school multidimensional scroll (touchpads) deltas deltaY = delta; @@ -63,8 +67,8 @@ function handler(event) { } // Webkit - if ( orgEvent.wheelDeltaY !== undefined ) deltaY = orgEvent.wheelDeltaY/120; - if ( orgEvent.wheelDeltaX !== undefined ) deltaX = -1*orgEvent.wheelDeltaX/120; + if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; } + if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; } // Add event and delta to the front of the arguments args.unshift(event, delta, deltaX, deltaY); From 234889ffd87078b7a2752d0f2bca8572d513e678 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Mon, 23 Aug 2010 08:04:55 -0500 Subject: [PATCH 016/136] Updating README with deltaX and deltaY info --- README.markdown | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.markdown b/README.markdown index 583d19e47..492f37f2a 100644 --- a/README.markdown +++ b/README.markdown @@ -2,18 +2,18 @@ A jQuery plugin that adds cross-browser mouse wheel support. -In order to use the plugin, simply bind the "mousewheel" event to an element. It also provides two helper methods called `mousewheel` and `unmousewheel` that act just like other event helper methods in jQuery. The event callback receives an extra argument which is the normalized "delta" of the mouse wheel. +In order to use the plugin, simply bind the "mousewheel" event to an element. It also provides two helper methods called `mousewheel` and `unmousewheel` that act just like other event helper methods in jQuery. The event callback receives three extra arguments which are the normalized "deltas" of the mouse wheel. Here is an example of using both the bind and helper method syntax. // using bind - $('#my_elem').bind('mousewheel', function(event, delta) { - console.log(delta); + $('#my_elem').bind('mousewheel', function(event, delta, deltaX, deltaY) { + console.log(delta, deltaX, deltaY); }); // using the event helper - $('#my_elem').mousewheel(function(event, delta) { - console.log(delta); + $('#my_elem').mousewheel(function(event, delta, deltaX, deltaY) { + console.log(delta, deltaX, deltaY); }); From 1e79a6f5434fa3ab35cc3a69c2c88a167c15ab95 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Mon, 23 Aug 2010 08:05:22 -0500 Subject: [PATCH 017/136] Updating version to 3.0.3 --- ChangeLog.markdown | 5 +++++ jquery.mousewheel.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index af82a30b9..6efe3eb9b 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,5 +1,10 @@ # Mouse Wheel ChangeLog +# 3.0.3 + +* Added deltaX and deltaY for horizontal scrolling support (Thanks to Seamus Leahy) + + # 3.0.2 * Fixed delta being opposite value in latest Opera diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index e14438c6b..528defee0 100644 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -5,7 +5,7 @@ * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. * Thanks to: Seamus Leahy for adding deltaX and deltaY * - * Version: 3.0.3-pre + * Version: 3.0.3 * * Requires: 1.2.2+ */ From 5ef1603eba169b4b96dede109d1fddac4d8c2b63 Mon Sep 17 00:00:00 2001 From: Kelvin Luck Date: Thu, 2 Sep 2010 10:26:19 +0100 Subject: [PATCH 018/136] Fix for brandonaaron/jquery-mousewheel#3 - new mousewheel plugin wasn't working in IE... --- jquery.mousewheel.js | 1 + 1 file changed, 1 insertion(+) mode change 100644 => 100755 jquery.mousewheel.js diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js old mode 100644 new mode 100755 index 528defee0..18bc5342f --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -50,6 +50,7 @@ $.fn.extend({ function handler(event) { var orgEvent = event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0; + var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0; event = $.event.fix(event || window.event); event.type = "mousewheel"; From e51b295e96979fa507dbb32d7e44c741904d2b5c Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Thu, 2 Sep 2010 10:59:10 -0500 Subject: [PATCH 019/136] Touch up patch for IE issue --- jquery.mousewheel.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index 18bc5342f..aeb06077e 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -48,10 +48,8 @@ $.fn.extend({ function handler(event) { - var orgEvent = event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0; - var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0; - event = $.event.fix(event || window.event); + event = $.event.fix(orgEvent); event.type = "mousewheel"; // Old school scrollwheel delta From 0f136d86831e88aab85c62118466f2875e9879ae Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Thu, 2 Sep 2010 11:02:15 -0500 Subject: [PATCH 020/136] Pushing new version to fix IE issue --- ChangeLog.markdown | 5 +++++ jquery.mousewheel.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 6efe3eb9b..9d2c7f3d4 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,5 +1,10 @@ # Mouse Wheel ChangeLog +# 3.0.4 + +* Fix IE issue + + # 3.0.3 * Added deltaX and deltaY for horizontal scrolling support (Thanks to Seamus Leahy) diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index aeb06077e..b7932415c 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -5,7 +5,7 @@ * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. * Thanks to: Seamus Leahy for adding deltaX and deltaY * - * Version: 3.0.3 + * Version: 3.0.4 * * Requires: 1.2.2+ */ From 9f7185bb58e3b621c345d34e31cd93664b0c88a0 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Thu, 27 Oct 2011 08:51:26 -0500 Subject: [PATCH 021/136] add compatibility with jQuery 1.7 --- ChangeLog.markdown | 6 +++++- LICENSE.txt | 4 ++-- README.markdown | 2 +- jquery.mousewheel.js | 14 ++++++++++---- test/index.html | 9 ++++++++- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 9d2c7f3d4..f949dc0a7 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,5 +1,9 @@ # Mouse Wheel ChangeLog +# 3.0.5 + +* jQuery 1.7 compatibility + # 3.0.4 * Fix IE issue @@ -55,4 +59,4 @@ * Fixed Opera issue * Fixed an issue with children elements that also have a mousewheel handler -* Added ability to handle multiple handlers \ No newline at end of file +* Added ability to handle multiple handlers diff --git a/LICENSE.txt b/LICENSE.txt index 74c597096..d3d21c42b 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright 2010, Brandon Aaron (http://brandonaaron.net/) +Copyright 2011, Brandon Aaron (http://brandonaaron.net/) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.markdown b/README.markdown index 492f37f2a..2c9092fbe 100644 --- a/README.markdown +++ b/README.markdown @@ -21,4 +21,4 @@ Here is an example of using both the bind and helper method syntax. The expandable plugin is licensed under the MIT License (LICENSE.txt). -Copyright (c) 2010 [Brandon Aaron](http://brandonaaron.net) \ No newline at end of file +Copyright (c) 2011 [Brandon Aaron](http://brandonaaron.net) diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index b7932415c..0173b89b3 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -1,11 +1,11 @@ -/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net) +/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net) * Licensed under the MIT License (LICENSE.txt). * * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers. * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. * Thanks to: Seamus Leahy for adding deltaX and deltaY * - * Version: 3.0.4 + * Version: 3.0.5 * * Requires: 1.2.2+ */ @@ -14,6 +14,12 @@ var types = ['DOMMouseScroll', 'mousewheel']; +if ($.event.fixHooks) { + for ( var i=types.length; i; ) { + $.event.fixHooks[ types[--i] ] = $.event.mouseHooks; + } +} + $.event.special.mousewheel = { setup: function() { if ( this.addEventListener ) { @@ -72,7 +78,7 @@ function handler(event) { // Add event and delta to the front of the arguments args.unshift(event, delta, deltaX, deltaY); - return $.event.handle.apply(this, args); + return ($.event.dispatch || $.event.handle).apply(this, args); } -})(jQuery); \ No newline at end of file +})(jQuery); diff --git a/test/index.html b/test/index.html index ed2da733c..fa3a8dc72 100644 --- a/test/index.html +++ b/test/index.html @@ -2,7 +2,14 @@ Testing mousewheel plugin - + + + + + + + + - - - -

jQuery mousewheel.js - Test

-

- -
    -
  • Test1 is just using the plain on mousewheel() with a function passed in and does not prevent default. (Also logs the value of pageX and pageY event properties.)
  • -
  • Test2 should prevent the default action.
  • -
  • Test3 should only log a mouseover and mouseout event. Testing unmousewheel().
  • -
  • Test4 has two handlers.
  • -
  • Test5 is like Test2 but has children. The children should not scroll until mousing over them.
  • -
  • Test6 is like Test5 but should not scroll children or parents.
  • -
  • Test7 is like Test6 but has no children. It will propagate the event and scroll test 6 as well.
  • -
- - -

Test1

-

Test2

-

Test3

-

Test4

-
-

Test5

-
-

Test6

-

Test7

-
-
- -
- -
- + #test2 { + background-color: #333; + width: 120px; + height: 100px; + color: #fff; + float: left; + } + + #test3 { + background-color: #666; + width: 120px; + height: 100px; + color: #fff; + float: left; + } + + #test4 { + background-color: #000; + width: 120px; + height: 100px; + color: #fff; + float: left; + } + + #test5 { + background-color: #333; + padding: 5px; + width: 400px; + height: 400px; + color: #fff; + float: left; + } + + #test6 { + background-color: #666; + padding: 5px; + width: 250px; + height: 250px; + color: #fff; + float: left; + } + + #test7 { + background-color: #000; + padding: 5px; + width: 100px; + height: 100px; + color: #fff; + float: left; + } + + #forceScroll { + clear: both; + height: 1000px; + } + + #logger { + position: absolute; + top: 395px; + left: 12px; + width: 460px; + height: 290px; + overflow: auto; + } + + #logger p { + font-family: Arial, sans-serif; + font-size: 13px; + padding: 2px; + border-bottom: 1px solid #ccc; + margin: 0; + } + + #logger p:nth-child(even) { + background-color: #FFFFE8; + } + + #logger p:nth-child(10n) { + border-bottom-color: #000; + } + + + + +

jQuery mousewheel.js - Test

+

+ +
    +
  • Test1 is just using the plain on mousewheel() with a function passed in and does not prevent default. (Also logs the value of pageX and pageY event properties.)
  • +
  • Test2 should prevent the default action.
  • +
  • Test3 should only log a mouseover and mouseout event. Testing unmousewheel().
  • +
  • Test4 has two handlers.
  • +
  • Test5 is like Test2 but has children. The children should not scroll until mousing over them.
  • +
  • Test6 is like Test5 but should not scroll children or parents.
  • +
  • Test7 is like Test6 but has no children. It will propagate the event and scroll test 6 as well.
  • +
+ + +

Test1

+

Test2

+

Test3

+

Test4

+
+

Test5

+
+

Test6

+

Test7

+
+
+ +
+ +
+ From 2e2dc57aaadfa4812b266f61a8ddbacc0a1d6aa9 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Fri, 22 Feb 2013 09:48:58 -0600 Subject: [PATCH 028/136] Use new wheel event if available (fixes Firefox 17+ issues and adds horizontal support to IE9+) Normalize the detal values Support AMD loaders Bump version to 3.1.0 and update copyright --- ChangeLog.markdown | 10 +++ README.markdown | 6 +- jquery.mousewheel.js | 153 +++++++++++++++++++++++------------------ mousewheel.jquery.json | 27 ++++++++ 4 files changed, 125 insertions(+), 71 deletions(-) create mode 100644 mousewheel.jquery.json diff --git a/ChangeLog.markdown b/ChangeLog.markdown index acb1f8710..c7185d113 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,13 +1,23 @@ # Mouse Wheel ChangeLog +# 3.1.0 + +* Fix Firefox 17+ issues by using new wheel event +* Normalize delta values +* Adds horizontal support for IE 9+ by using new wheel event +* Support AMD loaders + + # 3.0.6 * Fix issue with delta being 0 in Firefox + # 3.0.5 * jQuery 1.7 compatibility + # 3.0.4 * Fix IE issue diff --git a/README.markdown b/README.markdown index 9efc3c754..453ed6701 100644 --- a/README.markdown +++ b/README.markdown @@ -2,7 +2,7 @@ A jQuery plugin that adds cross-browser mouse wheel support. -In order to use the plugin, simply bind the "mousewheel" event to an element. It also provides two helper methods called `mousewheel` and `unmousewheel` that act just like other event helper methods in jQuery. The event callback receives three extra arguments which are the normalized "deltas" of the mouse wheel. +In order to use the plugin, simply bind the "mousewheel" event to an element. It also provides two helper methods called `mousewheel` and `unmousewheel` that act just like other event helper methods in jQuery. The event callback receives three extra arguments which are the normalized "deltas" of the mouse wheel. Here is an example of using both the bind and helper method syntax. @@ -10,7 +10,7 @@ Here is an example of using both the bind and helper method syntax. $('#my_elem').bind('mousewheel', function(event, delta, deltaX, deltaY) { console.log(delta, deltaX, deltaY); }); - + // using the event helper $('#my_elem').mousewheel(function(event, delta, deltaX, deltaY) { console.log(delta, deltaX, deltaY); @@ -21,4 +21,4 @@ Here is an example of using both the bind and helper method syntax. This plugin is licensed under the MIT License (LICENSE.txt). -Copyright (c) 2011 [Brandon Aaron](http://brandonaaron.net) +Copyright (c) 2013 [Brandon Aaron](http://brandonaaron.net) diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index 38b60951b..8c603041b 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -1,84 +1,101 @@ -/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net) +/*! Copyright (c) 2013 Brandon Aaron (http://brandonaaron.net) * Licensed under the MIT License (LICENSE.txt). * * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers. * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. * Thanks to: Seamus Leahy for adding deltaX and deltaY * - * Version: 3.0.6 - * + * Version: 3.1.0 + * * Requires: 1.2.2+ */ -(function($) { - -var types = ['DOMMouseScroll', 'mousewheel']; - -if ($.event.fixHooks) { - for ( var i=types.length; i; ) { - $.event.fixHooks[ types[--i] ] = $.event.mouseHooks; +(function (factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['jquery'], factory); + } else { + // Browser globals + factory(jQuery); } -} +}(function ($) { -$.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; + var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll']; + var toBind = 'onwheel' in document || document.documentMode >= 9 ? ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll']; + var lowestDelta, lowestDeltaXY; + + if ($.event.fixHooks) { + for ( var i=toFix.length; i; ) { + $.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks; } } -}; -$.fn.extend({ - mousewheel: function(fn) { - return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel"); - }, - - unmousewheel: function(fn) { - return this.unbind("mousewheel", fn); + $.event.special.mousewheel = { + setup: function() { + if ( this.addEventListener ) { + for ( var i=toBind.length; i; ) { + this.addEventListener( toBind[--i], handler, false ); + } + } else { + this.onmousewheel = handler; + } + }, + + teardown: function() { + if ( this.removeEventListener ) { + for ( var i=toBind.length; i; ) { + this.removeEventListener( toBind[--i], handler, false ); + } + } else { + this.onmousewheel = null; + } + } + }; + + $.fn.extend({ + mousewheel: function(fn) { + return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel"); + }, + + unmousewheel: function(fn) { + return this.unbind("mousewheel", fn); + } + }); + + + function handler(event) { + var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, deltaX = 0, deltaY = 0, absDelta = 0, absDeltaXY = 0; + event = $.event.fix(orgEvent); + event.type = "mousewheel"; + + // Old school scrollwheel delta + if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta; } + if ( orgEvent.detail ) { delta = orgEvent.detail * -1; } + + // New school wheel delta (wheel event) + if ( orgEvent.deltaY ) { + deltaY = orgEvent.deltaY * -1; + delta = deltaY; + } + if ( orgEvent.deltaX ) { + deltaX = orgEvent.deltaX; + delta = deltaX * -1; + } + + // Webkit + if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY; } + if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = orgEvent.wheelDeltaX * -1; } + + absDelta = Math.abs(delta); + if ( !lowestDelta || absDelta < lowestDelta ) { lowestDelta = absDelta; } + + absDeltaXY = Math.max( Math.abs(deltaY), Math.abs(deltaX) ); + if ( !lowestDeltaXY || absDeltaXY < lowestDeltaXY ) { lowestDeltaXY = absDeltaXY; } + + // Add event and delta to the front of the arguments + args.unshift(event, Math.floor(delta/lowestDelta), Math.floor(deltaX/lowestDeltaXY), Math.floor(deltaY/lowestDeltaXY)); + + return ($.event.dispatch || $.event.handle).apply(this, args); } -}); - -function handler(event) { - var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0; - event = $.event.fix(orgEvent); - event.type = "mousewheel"; - - // Old school scrollwheel delta - if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta/120; } - if ( orgEvent.detail ) { delta = -orgEvent.detail/3; } - - // New school multidimensional scroll (touchpads) deltas - deltaY = delta; - - // Gecko - if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) { - deltaY = 0; - deltaX = -1*delta; - } - - // Webkit - if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; } - if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; } - - // Add event and delta to the front of the arguments - args.unshift(event, delta, deltaX, deltaY); - - return ($.event.dispatch || $.event.handle).apply(this, args); -} - -})(jQuery); +})); diff --git a/mousewheel.jquery.json b/mousewheel.jquery.json new file mode 100644 index 000000000..4b52f1d7b --- /dev/null +++ b/mousewheel.jquery.json @@ -0,0 +1,27 @@ +{ + "name": "mousewheel", + "title": "jQuery Mousewheel", + "description": "A jQuery plugin that adds cross-browser mouse wheel support.", + "keywords": [ + "mousewheel", + "mouse", + "event" + ], + "version": "3.1.0", + "author": { + "name": "Brandon Aaron", + "url": "http://brandonaaron.net" + }, + "licenses": [ + { + "type": "MIT", + "url": "https://raw.github.com/brandonaaron/jquery-mousewheel/master/LICENSE.txt" + } + ], + "bugs": "https://github.com/brandonaaron/jquery-mousewheel/issues", + "homepage": "https://github.com/brandonaaron/jquery-mousewheel", + "download": "https://github.com/brandonaaron/jquery-mousewheel/tags", + "dependencies": { + "jquery": ">=1.2.2" + } +} From 4b3f1b73b290fdde88c60e7c4940fe09b20851a8 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Sat, 23 Feb 2013 18:12:57 -0600 Subject: [PATCH 029/136] fix rounding issue when delta is less than 0 --- jquery.mousewheel.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index 8c603041b..4f402485b 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -64,7 +64,7 @@ function handler(event) { - var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, deltaX = 0, deltaY = 0, absDelta = 0, absDeltaXY = 0; + var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, deltaX = 0, deltaY = 0, absDelta = 0, absDeltaXY = 0, fn; event = $.event.fix(orgEvent); event.type = "mousewheel"; @@ -86,14 +86,20 @@ if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY; } if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = orgEvent.wheelDeltaX * -1; } + // Look for lowest delta to normalize the delta values absDelta = Math.abs(delta); if ( !lowestDelta || absDelta < lowestDelta ) { lowestDelta = absDelta; } - absDeltaXY = Math.max( Math.abs(deltaY), Math.abs(deltaX) ); if ( !lowestDeltaXY || absDeltaXY < lowestDeltaXY ) { lowestDeltaXY = absDeltaXY; } + // Get a whole value for the deltas + fn = delta > 0 ? 'floor' : 'ceil'; + delta = Math[fn](delta/lowestDelta); + deltaX = Math[fn](deltaX/lowestDeltaXY); + deltaY = Math[fn](deltaY/lowestDeltaXY); + // Add event and delta to the front of the arguments - args.unshift(event, Math.floor(delta/lowestDelta), Math.floor(deltaX/lowestDeltaXY), Math.floor(deltaY/lowestDeltaXY)); + args.unshift(event, delta, deltaX, deltaY); return ($.event.dispatch || $.event.handle).apply(this, args); } From 746a5346d5ab4ca10aa32caf317657e47f2c2c1e Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Sat, 23 Feb 2013 18:16:53 -0600 Subject: [PATCH 030/136] Bumping version to 3.1.1 --- ChangeLog.markdown | 5 +++++ jquery.mousewheel.js | 2 +- mousewheel.jquery.json | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index c7185d113..abee92e07 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,5 +1,10 @@ # Mouse Wheel ChangeLog +# 3.1.1 + +* Fix rounding issue with deltas less than zero + + # 3.1.0 * Fix Firefox 17+ issues by using new wheel event diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index 4f402485b..7c398d76b 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -5,7 +5,7 @@ * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. * Thanks to: Seamus Leahy for adding deltaX and deltaY * - * Version: 3.1.0 + * Version: 3.1.1 * * Requires: 1.2.2+ */ diff --git a/mousewheel.jquery.json b/mousewheel.jquery.json index 4b52f1d7b..f8ea8f99c 100644 --- a/mousewheel.jquery.json +++ b/mousewheel.jquery.json @@ -7,7 +7,7 @@ "mouse", "event" ], - "version": "3.1.0", + "version": "3.1.1", "author": { "name": "Brandon Aaron", "url": "http://brandonaaron.net" From 25fb173d43d1bb4e77f9e5478d066069fc081e12 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Fri, 22 Feb 2013 18:18:45 +0200 Subject: [PATCH 031/136] LICENSE.txt: bump copyright year --- LICENSE.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index d3d21c42b..d64b7076b 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,5 +1,5 @@ -Copyright 2011, Brandon Aaron (http://brandonaaron.net/) - +Copyright (c) 2013, Brandon Aaron (http://brandonaaron.net/) + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including @@ -7,10 +7,10 @@ without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND From 3386135c0cff45e371955f3c6fc52804246511bb Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Fri, 22 Feb 2013 18:26:17 +0200 Subject: [PATCH 032/136] test/index.html: * remove unneeded type="text/javascript" * specify charset="iso-8859-1" and lang="en" --- test/index.html | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/index.html b/test/index.html index 33191f53c..a7992c1fd 100644 --- a/test/index.html +++ b/test/index.html @@ -1,6 +1,7 @@ - - + + + Testing mousewheel plugin - + - + diff --git a/test/browserify/main.js b/test/browserify/main.js new file mode 100644 index 000000000..7462bae19 --- /dev/null +++ b/test/browserify/main.js @@ -0,0 +1,2 @@ +var $ = require('jquery-browserify'); +require('../../jquery.mousewheel.js')($); From a450a11a02a75f18dd979176f001ed8de581ba8e Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Tue, 12 Mar 2013 09:26:05 -0500 Subject: [PATCH 039/136] bump version to 3.1.2 --- jquery.mousewheel.js | 2 +- mousewheel.jquery.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index e8cb6e01d..38355c6a1 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -5,7 +5,7 @@ * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. * Thanks to: Seamus Leahy for adding deltaX and deltaY * - * Version: 3.1.1 + * Version: 3.1.2 * * Requires: 1.2.2+ */ diff --git a/mousewheel.jquery.json b/mousewheel.jquery.json index f8ea8f99c..d73184cb3 100644 --- a/mousewheel.jquery.json +++ b/mousewheel.jquery.json @@ -7,7 +7,7 @@ "mouse", "event" ], - "version": "3.1.1", + "version": "3.1.2", "author": { "name": "Brandon Aaron", "url": "http://brandonaaron.net" diff --git a/package.json b/package.json index 627ea4421..f44fdfc5b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name" : "jquery-mousewheel", - "version": "3.1.1", + "version": "3.1.2", "description" : "A jQuery plugin that adds cross-browser mouse wheel support.", "main" : "./jquery.mousewheel.js", "repository" : { From 0a0f7c47bf9c61c50de10d0705d727645c6636a4 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Tue, 12 Mar 2013 09:27:28 -0500 Subject: [PATCH 040/136] update changelog --- ChangeLog.markdown | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 49029a802..9d6dc12ed 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,5 +1,11 @@ # Mouse Wheel ChangeLog +## 3.1.2 + +* Include grunt utilities for development purposes (jshint and uglify) +* Include support for browserify +* Some basic cleaning up + ## 3.1.1 * Fix rounding issue with deltas less than zero From 527edc4d2441e529622728bec8964c5d8241096c Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Wed, 13 Mar 2013 00:28:08 +0400 Subject: [PATCH 041/136] add MozMousePixelScroll to the fixed events list --- jquery.mousewheel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index 38355c6a1..ad9b12d14 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -23,7 +23,7 @@ } }(function ($) { - var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll']; + var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll']; var toBind = 'onwheel' in document || document.documentMode >= 9 ? ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll']; var lowestDelta, lowestDeltaXY; From 61d8ef360591e3890e706305557011f50e902943 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Tue, 12 Mar 2013 17:37:02 -0500 Subject: [PATCH 042/136] bump version to 3.1.3 --- ChangeLog.markdown | 4 ++++ jquery.mousewheel.js | 2 +- mousewheel.jquery.json | 2 +- package.json | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 9d6dc12ed..6609c7626 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,5 +1,9 @@ # Mouse Wheel ChangeLog +## 3.1.3 + +* Include MozMousePixelScroll in the to fix list to avoid inconsistent behavior in older Firefox + ## 3.1.2 * Include grunt utilities for development purposes (jshint and uglify) diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index ad9b12d14..9d65c7162 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -5,7 +5,7 @@ * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. * Thanks to: Seamus Leahy for adding deltaX and deltaY * - * Version: 3.1.2 + * Version: 3.1.3 * * Requires: 1.2.2+ */ diff --git a/mousewheel.jquery.json b/mousewheel.jquery.json index d73184cb3..a9517fb3c 100644 --- a/mousewheel.jquery.json +++ b/mousewheel.jquery.json @@ -7,7 +7,7 @@ "mouse", "event" ], - "version": "3.1.2", + "version": "3.1.3", "author": { "name": "Brandon Aaron", "url": "http://brandonaaron.net" diff --git a/package.json b/package.json index f44fdfc5b..a17cc1f1c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name" : "jquery-mousewheel", - "version": "3.1.2", + "version": "3.1.3", "description" : "A jQuery plugin that adds cross-browser mouse wheel support.", "main" : "./jquery.mousewheel.js", "repository" : { From d0b926b80b44ecf84b6cf6d6ce15519bb1943cbe Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Wed, 29 May 2013 19:34:30 +0300 Subject: [PATCH 043/136] Normalize package.json and add missing properties. Also refactor the properties in a more sane way. --- package.json | 59 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index a17cc1f1c..d8f5abea3 100644 --- a/package.json +++ b/package.json @@ -1,27 +1,38 @@ { - "name" : "jquery-mousewheel", - "version": "3.1.3", -"description" : "A jQuery plugin that adds cross-browser mouse wheel support.", - "main" : "./jquery.mousewheel.js", - "repository" : { - "type" : "git", - "url" : "https://github.com/brandonaaron/jquery-mousewheel.git" - }, - "keywords" : [ "jquery", "mouse", "wheel", "event", "mousewheel", "plugin", "browser" ], - "author" : { - "name" : "Brandon Aaron", - "email" : "brandon.aaron@gmail.com", - "url" : "http://brandonaaron.net/" - }, - "licenses": [ - { - "type": "MIT", - "url": "https://raw.github.com/brandonaaron/jquery-mousewheel/master/LICENSE.txt" - } - ], - "devDependencies": { - "grunt-contrib-jshint": "~0.2.0", - "grunt-contrib-uglify": "~0.1.2", - "grunt": "~0.4.0" + "name": "jquery-mousewheel", + "version": "3.1.3", + "author": "Brandon Aaron (http://brandonaaron.net/)", + "description": "A jQuery plugin that adds cross-browser mouse wheel support.", + "main": "./jquery.mousewheel.js", + "repository": { + "type": "git", + "url": "https://github.com/brandonaaron/jquery-mousewheel.git" + }, + "bugs": { + "url": "https://github.com/brandonaaron/jquery-mousewheel/issues" + }, + "keywords": [ + "jquery", + "mouse", + "wheel", + "event", + "mousewheel", + "plugin", + "browser" + ], + "licenses": [ + { + "type": "MIT", + "url": "https://raw.github.com/brandonaaron/jquery-mousewheel/master/LICENSE.txt" } + ], + "devDependencies": { + "grunt-contrib-jshint": "~0.4.3", + "grunt-contrib-uglify": "~0.2.0", + "grunt": "~0.4.1" + }, + "readmeFilename": "README.markdown", + "directories": { + "test": "test" + } } From ad29b7e8705e845adca44198844f327c070367e9 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sat, 7 Sep 2013 10:25:55 +0300 Subject: [PATCH 044/136] Update dependencies. --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index d8f5abea3..633fc807d 100644 --- a/package.json +++ b/package.json @@ -27,9 +27,9 @@ } ], "devDependencies": { - "grunt-contrib-jshint": "~0.4.3", - "grunt-contrib-uglify": "~0.2.0", - "grunt": "~0.4.1" + "grunt": "~0.4.1", + "grunt-contrib-jshint": "~0.6.4", + "grunt-contrib-uglify": "~0.2.4" }, "readmeFilename": "README.markdown", "directories": { From 9602df3f7003625e6544a9d32fe35c19469f32c3 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 10 Sep 2013 10:26:28 +0300 Subject: [PATCH 045/136] Update docs. Use code syntax in more places and link to jquery. --- ChangeLog.markdown | 6 +++--- README.markdown | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 6609c7626..f7cdfe356 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -2,7 +2,7 @@ ## 3.1.3 -* Include MozMousePixelScroll in the to fix list to avoid inconsistent behavior in older Firefox +* Include `MozMousePixelScroll` in the to fix list to avoid inconsistent behavior in older Firefox ## 3.1.2 @@ -40,7 +40,7 @@ ## 3.0.3 -* Added deltaX and deltaY for horizontal scrolling support (Thanks to Seamus Leahy) +* Added `deltaX` and `deltaY` for horizontal scrolling support (Thanks to Seamus Leahy) ## 3.0.2 @@ -71,7 +71,7 @@ ## 2.1.1 * Updated to work with jQuery 1.1.3 -* Used one instead of bind to do unload event for clean up. +* Used one instead of bind to do unload event for clean up ## 2.1 diff --git a/README.markdown b/README.markdown index 66086b43a..4853e06cd 100644 --- a/README.markdown +++ b/README.markdown @@ -1,13 +1,13 @@ # jQuery Mouse Wheel Plugin -A jQuery plugin that adds cross-browser mouse wheel support. +A [jQuery](http://jquery.com/) plugin that adds cross-browser mouse wheel support. In order to use the plugin, simply bind the `mousewheel` event to an element. It also provides two helper methods called `mousewheel` and `unmousewheel` that act just like other event helper methods in jQuery. The event callback receives three extra arguments which are the normalized "deltas" of the mouse wheel. -Here is an example of using both the bind and helper method syntax. +Here is an example of using both the bind and helper method syntax: ```js // using bind From 26b1117f9433cb13adc6a6889d273a43f1a5b50a Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 10 Sep 2013 10:37:42 +0300 Subject: [PATCH 046/136] Use single quotes consistently. --- .jshintrc | 1 + Gruntfile.js | 2 +- jquery.mousewheel.js | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.jshintrc b/.jshintrc index 862068c59..6025094ce 100644 --- a/.jshintrc +++ b/.jshintrc @@ -11,6 +11,7 @@ "noarg": true, "node" : true, "noempty": true, + "quotmark": "single", "plusplus": false, "regexp": true, "strict": false, diff --git a/Gruntfile.js b/Gruntfile.js index 6a4d398f3..fff8672c7 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -17,7 +17,7 @@ module.exports = function(grunt) { } }); - // Load the plugin that provides the "uglify" task. + // Load the plugin that provides the 'uglify' task. grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-jshint'); diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index 9d65c7162..573a44313 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -57,11 +57,11 @@ $.fn.extend({ mousewheel: function(fn) { - return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel"); + return fn ? this.bind('mousewheel', fn) : this.trigger('mousewheel'); }, unmousewheel: function(fn) { - return this.unbind("mousewheel", fn); + return this.unbind('mousewheel', fn); } }); @@ -76,7 +76,7 @@ absDeltaXY = 0, fn; event = $.event.fix(orgEvent); - event.type = "mousewheel"; + event.type = 'mousewheel'; // Old school scrollwheel delta if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta; } From d6941b9ed7960eca5b9149368f45dfc6bfe6b392 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 10 Sep 2013 10:41:10 +0300 Subject: [PATCH 047/136] Fix loading JSHint options. --- Gruntfile.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Gruntfile.js b/Gruntfile.js index fff8672c7..80633c8f0 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -13,6 +13,9 @@ module.exports = function(grunt) { } }, jshint: { + options: { + jshintrc: '.jshintrc' + }, all: ['*.js'] } }); From c60712d15033fdf8242aedf46e821cee8abf5396 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 10 Sep 2013 10:48:18 +0300 Subject: [PATCH 048/136] Gruntfile.js: Fix JSHint issues. --- Gruntfile.js | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 80633c8f0..b3102a7ff 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,30 +1,30 @@ module.exports = function(grunt) { - // Project configuration. - grunt.initConfig({ - pkg: grunt.file.readJSON('package.json'), - uglify: { - options: { - preserveComments: 'some' - }, - build: { - src: 'jquery.mousewheel.js', - dest: 'build/jquery.mousewheel.min.js' - } - }, - jshint: { - options: { - jshintrc: '.jshintrc' - }, - all: ['*.js'] - } - }); + // Project configuration. + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + uglify: { + options: { + preserveComments: 'some' + }, + build: { + src: 'jquery.mousewheel.js', + dest: 'build/jquery.mousewheel.min.js' + } + }, + jshint: { + options: { + jshintrc: '.jshintrc' + }, + all: ['*.js'] + } + }); - // Load the plugin that provides the 'uglify' task. - grunt.loadNpmTasks('grunt-contrib-uglify'); - grunt.loadNpmTasks('grunt-contrib-jshint'); + // Load the plugin that provides the 'uglify' task. + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-jshint'); - // Default task(s). - grunt.registerTask('default', ['jshint', 'uglify']); + // Default task(s). + grunt.registerTask('default', ['jshint', 'uglify']); }; From b1dad433fbf5c3431a97e292ec8ff8c336d5cc64 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 10 Sep 2013 10:45:22 +0300 Subject: [PATCH 049/136] Normalize .jshintrc. --- .jshintrc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.jshintrc b/.jshintrc index 6025094ce..d3eb60ed3 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,6 +1,6 @@ { "bitwise": true, - "browser" : true, + "browser": true, "camelcase": true, "curly": true, "eqeqeq": true, @@ -9,10 +9,10 @@ "latedef": true, "maxerr": 50, "noarg": true, - "node" : true, + "node": true, "noempty": true, - "quotmark": "single", "plusplus": false, + "quotmark": "single", "regexp": true, "strict": false, "trailing": true, From d3f6b0d677007a9a20b9e79354b28cd5c4a6bf62 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Fri, 18 Oct 2013 10:36:50 -0500 Subject: [PATCH 050/136] include require as a global as well as define --- .jshintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.jshintrc b/.jshintrc index d3eb60ed3..8532f9b3b 100644 --- a/.jshintrc +++ b/.jshintrc @@ -17,5 +17,5 @@ "strict": false, "trailing": true, "unused": true, - "globals": { "define": true } + "globals": { "define": true, "require": true } } From c61e8d55bb900f56eea7017d6ef7f73c80890a69 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Fri, 18 Oct 2013 10:36:56 -0500 Subject: [PATCH 051/136] Include jam package manager support --- package.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/package.json b/package.json index 633fc807d..39add5cfe 100644 --- a/package.json +++ b/package.json @@ -34,5 +34,10 @@ "readmeFilename": "README.markdown", "directories": { "test": "test" + }, + "jam": { + "dependencies": { + "jquery": ">=1.2.2" + } } } From 7246c14e0e9f064cff665cf7de736a8829d55d8c Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Fri, 18 Oct 2013 10:37:25 -0500 Subject: [PATCH 052/136] include bower package manager support --- bower.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 bower.json diff --git a/bower.json b/bower.json new file mode 100644 index 000000000..f4149f5e2 --- /dev/null +++ b/bower.json @@ -0,0 +1,16 @@ +{ + "name": "jquery-mousewheel", + "version": "3.1.3", + "main": "./jquery.mousewheel.js", + "ignore": [ + ".*", + "*.txt", + "*.markdown", + "*.json", + "test", + "Gruntfile.js" + ], + "dependencies": { + "jquery": ">=1.2.2" + } +} From d5b6f9eb3684f1ea13c8af0e78405c1d474e610a Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Fri, 18 Oct 2013 18:42:06 +0300 Subject: [PATCH 053/136] Update README.markdown. Use the new GitHub "io" domain. --- README.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 4853e06cd..a24321f76 100644 --- a/README.markdown +++ b/README.markdown @@ -22,13 +22,13 @@ $('#my_elem').mousewheel(function(event, delta, deltaX, deltaY) { ``` ## See it in action -[See the tests on Github](http://brandonaaron.github.com/jquery-mousewheel/test). +[See the tests on Github](http://brandonaaron.github.io/jquery-mousewheel/test). ## Using with [Browserify](http://browserify.org) Support for browserify is baked in. -```js +```bash npm install jquery-mousewheel npm install jquery-browserify ``` From ac59cbd3af1b04d29d5952319a14668ef6d3ae99 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Fri, 18 Oct 2013 18:48:54 +0300 Subject: [PATCH 054/136] Update Gruntfile.js. * remove unneeded variable * move jshint first * update uglify-js options --- Gruntfile.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index b3102a7ff..ec9e4e5fa 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -2,27 +2,29 @@ module.exports = function(grunt) { // Project configuration. grunt.initConfig({ - pkg: grunt.file.readJSON('package.json'), - uglify: { - options: { - preserveComments: 'some' - }, - build: { - src: 'jquery.mousewheel.js', - dest: 'build/jquery.mousewheel.min.js' - } - }, jshint: { options: { jshintrc: '.jshintrc' }, all: ['*.js'] + }, + uglify: { + options: { + compress: true, + mangle: true, + preserveComments: 'some', + report: 'gzip' + }, + build: { + src: 'jquery.mousewheel.js', + dest: 'build/jquery.mousewheel.min.js' + } } }); // Load the plugin that provides the 'uglify' task. - grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-contrib-uglify'); // Default task(s). grunt.registerTask('default', ['jshint', 'uglify']); From 125bba8a0a6327feecd4706502fb5003a382c63b Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Fri, 18 Oct 2013 10:57:40 -0500 Subject: [PATCH 055/136] Include the jquery version in the header of the test. Can change this with ?v=1.2.2 --- test/index.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/index.html b/test/index.html index a7992c1fd..65a5c629e 100644 --- a/test/index.html +++ b/test/index.html @@ -111,6 +111,7 @@ -

jQuery mousewheel.js - Test

+

jQuery mousewheel.js Test with jQuery

    From 75dddb776be76b77f7b9474a293a32ef9f1ee823 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Fri, 18 Oct 2013 10:58:20 -0500 Subject: [PATCH 056/136] Fix the position of the logger in the test --- test/index.html | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/test/index.html b/test/index.html index 65a5c629e..9b34c55f4 100644 --- a/test/index.html +++ b/test/index.html @@ -19,6 +19,9 @@ + + +

    jQuery mousewheel.js Test with jQuery

    From 5ad50175e1cfc690b0d79a1d890013263c425a96 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 18 Nov 2013 18:04:13 +0200 Subject: [PATCH 098/136] test/index.html: remove unused variables. --- test/index.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/index.html b/test/index.html index 6a10d2280..94a005c00 100644 --- a/test/index.html +++ b/test/index.html @@ -146,13 +146,13 @@ }; $('#test1') - .mousewheel(function(event, delta, deltaX, deltaY) { + .mousewheel(function(event, delta) { loghandle(event, delta); log('pageX: ' + event.pageX + ' pageY: ' + event.pageY ); }); $('#test2') - .mousewheel(function(event, delta, deltaX, deltaY) { + .mousewheel(function(event, delta) { loghandle(event, delta); return false; // prevent default }); @@ -169,33 +169,33 @@ }; $('#test4') - .mousewheel(function(event, delta, deltaX, deltaY) { + .mousewheel(function(event, delta) { loghandle(event, delta); return false; }) .mousewheel(testRemoval) - .mousewheel(function(event, delta, deltaX, deltaY) { + .mousewheel(function(event, delta) { loghandle(event, delta); return false; }) .unmousewheel(testRemoval); $('#test5') - .mousewheel(function(event, delta, deltaX, deltaY) { + .mousewheel(function(event, delta) { loghandle(event, delta); event.stopPropagation(); event.preventDefault(); }); $('#test6') - .mousewheel(function(event, delta, deltaX, deltaY) { + .mousewheel(function(event, delta) { loghandle(event, delta); event.stopPropagation(); event.preventDefault(); }); $('#test7') - .mousewheel(function(event, delta, deltaX, deltaY) { + .mousewheel(function(event, delta) { loghandle(event, delta); event.preventDefault(); }); From 932c3c52fe5191dd29e7f1b5dd0f4f5caf1017ac Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 18 Nov 2013 18:14:47 +0200 Subject: [PATCH 099/136] test/index.html: put a few common properties together. --- test/index.html | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/test/index.html b/test/index.html index 94a005c00..f04c80ce2 100644 --- a/test/index.html +++ b/test/index.html @@ -10,40 +10,37 @@ } #stage { + color: #fff; position: relative; zoom: 1; } + #test1, #test2, #test3, #test4, #test5, #test6, #test7 { + float: left; + } + #test1 { background-color: #000; width: 120px; height: 100px; - color: #fff; - float: left; } #test2 { background-color: #333; width: 120px; height: 100px; - color: #fff; - float: left; } #test3 { background-color: #666; width: 120px; height: 100px; - color: #fff; - float: left; } #test4 { background-color: #000; width: 120px; height: 100px; - color: #fff; - float: left; } #test5 { @@ -51,8 +48,6 @@ padding: 5px; width: 400px; height: 400px; - color: #fff; - float: left; } #test6 { @@ -60,8 +55,6 @@ padding: 5px; width: 250px; height: 250px; - color: #fff; - float: left; } #test7 { @@ -69,8 +62,6 @@ padding: 5px; width: 100px; height: 100px; - color: #fff; - float: left; } #forceScroll { @@ -89,6 +80,7 @@ } #logger p { + color: #000; padding: 2px; border-bottom: 1px solid #ccc; margin: 0; From 5aaaf69c5a247a2d69820f5a54f1654833da5342 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Thu, 12 Dec 2013 14:31:33 -0500 Subject: [PATCH 100/136] Better handle deltaModes 1 (scroll by lines) and 2 (scroll by pages). --- ChangeLog.md | 4 ++++ bower.json | 2 +- jquery.mousewheel.js | 37 +++++++++++++++++++++++++++++++++++-- mousewheel.jquery.json | 2 +- package.json | 2 +- 5 files changed, 42 insertions(+), 5 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 009cea29b..fabdfe8cf 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,9 @@ # Mouse Wheel ChangeLog +## 3.1.7-pre + +* Better handle the `deltaMode` values 1 (lines) and 2 (pages) + ## 3.1.6 * Deprecating `delta`, `deltaX`, and `deltaY` event handler arguments diff --git a/bower.json b/bower.json index 9acd327c8..1bf360728 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery-mousewheel", - "version": "3.1.6", + "version": "3.1.7-pre", "main": "./jquery.mousewheel.js", "ignore": [ "*.json", diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index 920f2299c..a28a661f4 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -1,7 +1,7 @@ /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh) * Licensed under the MIT License (LICENSE.txt). * - * Version: 3.1.6 + * Version: 3.1.7-pre * * Requires: jQuery 1.2.2+ */ @@ -31,7 +31,7 @@ } } - $.event.special.mousewheel = { + var special = $.event.special.mousewheel = { version: '3.1.6', setup: function() { @@ -42,6 +42,9 @@ } else { this.onmousewheel = handler; } + // Store the line height and page height for this particular element + $.data(this, 'mousewheel-line-height', special.getLineHeight(this)); + $.data(this, 'mousewheel-page-height', special.getPageHeight(this)); }, teardown: function() { @@ -52,6 +55,14 @@ } else { this.onmousewheel = null; } + }, + + getLineHeight: function(elem) { + return parseInt($(elem).offsetParent().css('fontSize'), 10); + }, + + getPageHeight: function(elem) { + return $(elem).height(); } }; @@ -104,8 +115,26 @@ // No change actually happened, no reason to go any further if ( deltaY === 0 && deltaX === 0 ) { return; } + // Need to convert lines and pages to pixels if we aren't already in pixels + // There are three delta modes: + // * deltaMode 0 is by pixels, nothing to do + // * deltaMode 1 is by lines + // * deltaMode 2 is by pages + if ( orgEvent.deltaMode === 1 ) { + var lineHeight = $.data(this, 'mousewheel-line-height'); + delta *= lineHeight; + deltaY *= lineHeight; + deltaX *= lineHeight; + } else if ( orgEvent.deltaMode === 2 ) { + var pageHeight = $.data(this, 'mousewheel-page-height'); + delta *= pageHeight; + deltaY *= pageHeight; + deltaX *= pageHeight; + } + // Store lowest absolute delta to normalize the delta values absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) ); + if ( !lowestDelta || absDelta < lowestDelta ) { lowestDelta = absDelta; } @@ -119,6 +148,10 @@ event.deltaX = deltaX; event.deltaY = deltaY; event.deltaFactor = lowestDelta; + // Go ahead and set deltaMode to 0 since we converted to pixels + // Although this is a little odd since we overwrite the deltaX/Y + // properties with normalized deltas. + event.deltaMode = 0; // Add event and delta to the front of the arguments args.unshift(event, delta, deltaX, deltaY); diff --git a/mousewheel.jquery.json b/mousewheel.jquery.json index ce4064c34..e8790b6b0 100644 --- a/mousewheel.jquery.json +++ b/mousewheel.jquery.json @@ -7,7 +7,7 @@ "mouse", "event" ], - "version": "3.1.6", + "version": "3.1.7-pre", "author": { "name": "Brandon Aaron", "url": "http://brandonaaron.net" diff --git a/package.json b/package.json index ffb01ddab..f88cc0e52 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jquery-mousewheel", - "version": "3.1.6", + "version": "3.1.7-pre", "author": "Brandon Aaron (http://brandonaaron.net/)", "description": "A jQuery plugin that adds cross-browser mouse wheel support.", "license": "MIT", From 17b6d369e3608e5b6d1073c0338f240dec9618b0 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Thu, 12 Dec 2013 14:36:47 -0500 Subject: [PATCH 101/136] offsetParent was not added until 1.2.6 and should probably continue support for 1.2.2 since this is going to be a bug fix release --- jquery.mousewheel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index a28a661f4..4c2178c95 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -58,7 +58,7 @@ }, getLineHeight: function(elem) { - return parseInt($(elem).offsetParent().css('fontSize'), 10); + return parseInt($(elem)['offsetParent' in jQuery.fn ? 'offsetParent' : 'parent']().css('fontSize'), 10); }, getPageHeight: function(elem) { From 84f0578a396be3e3d3a6d2c9eb9fd247ff40a940 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Thu, 12 Dec 2013 14:48:58 -0500 Subject: [PATCH 102/136] can just use $ here --- jquery.mousewheel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index 4c2178c95..b2a6a9c45 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -58,7 +58,7 @@ }, getLineHeight: function(elem) { - return parseInt($(elem)['offsetParent' in jQuery.fn ? 'offsetParent' : 'parent']().css('fontSize'), 10); + return parseInt($(elem)['offsetParent' in $.fn ? 'offsetParent' : 'parent']().css('fontSize'), 10); }, getPageHeight: function(elem) { From 41b980a4236caff0634cc1d8d044b532fdd8e27d Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Thu, 12 Dec 2013 17:10:24 -0500 Subject: [PATCH 103/136] fix my indents --- jquery.mousewheel.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index b2a6a9c45..d242796ff 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -58,11 +58,11 @@ }, getLineHeight: function(elem) { - return parseInt($(elem)['offsetParent' in $.fn ? 'offsetParent' : 'parent']().css('fontSize'), 10); + return parseInt($(elem)['offsetParent' in $.fn ? 'offsetParent' : 'parent']().css('fontSize'), 10); }, getPageHeight: function(elem) { - return $(elem).height(); + return $(elem).height(); } }; @@ -121,15 +121,15 @@ // * deltaMode 1 is by lines // * deltaMode 2 is by pages if ( orgEvent.deltaMode === 1 ) { - var lineHeight = $.data(this, 'mousewheel-line-height'); - delta *= lineHeight; - deltaY *= lineHeight; - deltaX *= lineHeight; + var lineHeight = $.data(this, 'mousewheel-line-height'); + delta *= lineHeight; + deltaY *= lineHeight; + deltaX *= lineHeight; } else if ( orgEvent.deltaMode === 2 ) { - var pageHeight = $.data(this, 'mousewheel-page-height'); - delta *= pageHeight; - deltaY *= pageHeight; - deltaX *= pageHeight; + var pageHeight = $.data(this, 'mousewheel-page-height'); + delta *= pageHeight; + deltaY *= pageHeight; + deltaX *= pageHeight; } // Store lowest absolute delta to normalize the delta values From 5d771abbf2d0923a759837ffd579d653a5538dcd Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Fri, 13 Dec 2013 09:22:13 -0500 Subject: [PATCH 104/136] Attempt to beter handle older browsers that use a wheelDelta based on 120 --- ChangeLog.md | 1 + jquery.mousewheel.js | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index fabdfe8cf..d1ad85d99 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,6 +3,7 @@ ## 3.1.7-pre * Better handle the `deltaMode` values 1 (lines) and 2 (pages) +* Attempt to better handle older browsers that use a wheelDelta based on 120 ## 3.1.6 diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index d242796ff..d87724aae 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -139,6 +139,17 @@ lowestDelta = absDelta; } + // Assuming that if the lowestDelta is 120, then that the browser + // is treating this as an older mouse wheel event. + // We'll divide it by 40 to try and get a more usable deltaFactor. + if ( lowestDelta === 120 ) { + // Divide all the things by 40! + delta /= 40; + deltaX /= 40; + deltaY /= 40; + lowestDelta /= 40; + } + // Get a whole, normalized value for the deltas delta = Math[ delta >= 1 ? 'floor' : 'ceil' ](delta / lowestDelta); deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta); From 85b84293c7775d4c2e0ece483e12d693203a3e80 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Fri, 13 Dec 2013 10:35:41 -0500 Subject: [PATCH 105/136] again with my indents --- jquery.mousewheel.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index d87724aae..4b25ebc49 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -143,11 +143,11 @@ // is treating this as an older mouse wheel event. // We'll divide it by 40 to try and get a more usable deltaFactor. if ( lowestDelta === 120 ) { - // Divide all the things by 40! - delta /= 40; - deltaX /= 40; - deltaY /= 40; - lowestDelta /= 40; + // Divide all the things by 40! + delta /= 40; + deltaX /= 40; + deltaY /= 40; + lowestDelta /= 40; } // Get a whole, normalized value for the deltas From cafeaf9f4db3e83d2ef05767165ec60223205d58 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Sat, 14 Dec 2013 13:32:06 -0500 Subject: [PATCH 106/136] Bump version to 3.1.7 and update my info in a few places. --- ChangeLog.md | 2 +- LICENSE.txt | 2 +- bower.json | 2 +- jquery.mousewheel.js | 2 +- mousewheel.jquery.json | 4 ++-- package.json | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index d1ad85d99..4a8d508d3 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,6 @@ # Mouse Wheel ChangeLog -## 3.1.7-pre +## 3.1.7 * Better handle the `deltaMode` values 1 (lines) and 2 (pages) * Attempt to better handle older browsers that use a wheelDelta based on 120 diff --git a/LICENSE.txt b/LICENSE.txt index d64b7076b..ad2020df4 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2013, Brandon Aaron (http://brandonaaron.net/) +Copyright (c) 2013, Brandon Aaron (http://brandon.aaron.sh) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/bower.json b/bower.json index 1bf360728..b6b3c9c8c 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery-mousewheel", - "version": "3.1.7-pre", + "version": "3.1.7, "main": "./jquery.mousewheel.js", "ignore": [ "*.json", diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index 4b25ebc49..004079c72 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -1,7 +1,7 @@ /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh) * Licensed under the MIT License (LICENSE.txt). * - * Version: 3.1.7-pre + * Version: 3.1.7 * * Requires: jQuery 1.2.2+ */ diff --git a/mousewheel.jquery.json b/mousewheel.jquery.json index e8790b6b0..ef357b4c6 100644 --- a/mousewheel.jquery.json +++ b/mousewheel.jquery.json @@ -7,10 +7,10 @@ "mouse", "event" ], - "version": "3.1.7-pre", + "version": "3.1.7", "author": { "name": "Brandon Aaron", - "url": "http://brandonaaron.net" + "url": "http://brandon.aaron.sh" }, "licenses": [ { diff --git a/package.json b/package.json index f88cc0e52..36bf87ee8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "jquery-mousewheel", - "version": "3.1.7-pre", - "author": "Brandon Aaron (http://brandonaaron.net/)", + "version": "3.1.7", + "author": "Brandon Aaron (http://brandon.aaron.sh)", "description": "A jQuery plugin that adds cross-browser mouse wheel support.", "license": "MIT", "homepage": "https://github.com/brandonaaron/jquery-mousewheel", From c7a2d662494a8c83e4e0832a0a834a862592d941 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Sat, 14 Dec 2013 14:08:48 -0500 Subject: [PATCH 107/136] Fix the handling of older 120 based deltas. --- jquery.mousewheel.js | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index 004079c72..599a0df05 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -1,7 +1,7 @@ /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh) * Licensed under the MIT License (LICENSE.txt). * - * Version: 3.1.7 + * Version: 3.1.8-pre * * Requires: jQuery 1.2.2+ */ @@ -23,7 +23,7 @@ toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ? ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'], slice = Array.prototype.slice, - nullLowestDeltaTimeout, lowestDelta; + oldMode, nullLowestDeltaTimeout, lowestDelta; if ( $.event.fixHooks ) { for ( var i = toFix.length; i; ) { @@ -32,7 +32,7 @@ } var special = $.event.special.mousewheel = { - version: '3.1.6', + version: '3.1.8-pre', setup: function() { if ( this.addEventListener ) { @@ -137,17 +137,23 @@ if ( !lowestDelta || absDelta < lowestDelta ) { lowestDelta = absDelta; + + // Assuming that if the lowestDelta is 120, then that the browser + // is treating this as an older mouse wheel event. + // We'll divide it by 40 to try and get a more usable deltaFactor. + if ( lowestDelta === 120 ) { + oldMode = true; + lowestDelta /= 40; + } } - // Assuming that if the lowestDelta is 120, then that the browser - // is treating this as an older mouse wheel event. - // We'll divide it by 40 to try and get a more usable deltaFactor. - if ( lowestDelta === 120 ) { + // When in oldMode the delta is based on 120. We devide + // by 40 to try and get a more usable deltaFactor. + if ( oldMode ) { // Divide all the things by 40! - delta /= 40; - deltaX /= 40; - deltaY /= 40; - lowestDelta /= 40; + delta /= 40; + deltaX /= 40; + deltaY /= 40; } // Get a whole, normalized value for the deltas @@ -179,6 +185,7 @@ function nullLowestDelta() { lowestDelta = null; + oldMode = null; } })); From 89baea9c298b124a6a58e2359c3c4ea8dbbd94eb Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Sat, 14 Dec 2013 14:17:24 -0500 Subject: [PATCH 108/136] add scrolling test --- test/scroll.html | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 test/scroll.html diff --git a/test/scroll.html b/test/scroll.html new file mode 100644 index 000000000..70b9f649d --- /dev/null +++ b/test/scroll.html @@ -0,0 +1,48 @@ + + + + Scroll Test + + + + + + +
    +
    + + From 937799db29b5eeda1a6df7ef0e2dc35a68ada0e8 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Sat, 14 Dec 2013 14:17:39 -0500 Subject: [PATCH 109/136] fix comment --- jquery.mousewheel.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index 599a0df05..486a013bb 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -147,8 +147,8 @@ } } - // When in oldMode the delta is based on 120. We devide - // by 40 to try and get a more usable deltaFactor. + // When in oldMode the delta is based on 120. + // Dividing by 40 to try and get a more usable deltaFactor. if ( oldMode ) { // Divide all the things by 40! delta /= 40; From 16903493985fd87719f91a56fe958848650a8acd Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Sat, 14 Dec 2013 14:19:07 -0500 Subject: [PATCH 110/136] update change log --- ChangeLog.md | 5 +++++ bower.json | 2 +- mousewheel.jquery.json | 2 +- package.json | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 4a8d508d3..5069d8605 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,10 @@ # Mouse Wheel ChangeLog +## 3.1.8-pre + +* Even better handling of older browsers that use a wheelDelta based on 120 +* And fix version reported by `$.event.special.mousewheel` + ## 3.1.7 * Better handle the `deltaMode` values 1 (lines) and 2 (pages) diff --git a/bower.json b/bower.json index b6b3c9c8c..4aa7f861d 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery-mousewheel", - "version": "3.1.7, + "version": "3.1.8-pre, "main": "./jquery.mousewheel.js", "ignore": [ "*.json", diff --git a/mousewheel.jquery.json b/mousewheel.jquery.json index ef357b4c6..489797589 100644 --- a/mousewheel.jquery.json +++ b/mousewheel.jquery.json @@ -7,7 +7,7 @@ "mouse", "event" ], - "version": "3.1.7", + "version": "3.1.8-pre", "author": { "name": "Brandon Aaron", "url": "http://brandon.aaron.sh" diff --git a/package.json b/package.json index 36bf87ee8..77cdc6a7f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jquery-mousewheel", - "version": "3.1.7", + "version": "3.1.8-pre", "author": "Brandon Aaron (http://brandon.aaron.sh)", "description": "A jQuery plugin that adds cross-browser mouse wheel support.", "license": "MIT", From 3efd554e605929ff5cdbe1ccf0a8f88a53f78aa0 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Sat, 14 Dec 2013 14:20:37 -0500 Subject: [PATCH 111/136] bump version to 3.1.8 --- ChangeLog.md | 2 +- bower.json | 2 +- jquery.mousewheel.js | 4 ++-- mousewheel.jquery.json | 2 +- package.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 5069d8605..1e524d9b8 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,6 @@ # Mouse Wheel ChangeLog -## 3.1.8-pre +## 3.1.8 * Even better handling of older browsers that use a wheelDelta based on 120 * And fix version reported by `$.event.special.mousewheel` diff --git a/bower.json b/bower.json index 4aa7f861d..4d7ab62ce 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery-mousewheel", - "version": "3.1.8-pre, + "version": "3.1.8, "main": "./jquery.mousewheel.js", "ignore": [ "*.json", diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index 486a013bb..08e5b53b0 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -1,7 +1,7 @@ /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh) * Licensed under the MIT License (LICENSE.txt). * - * Version: 3.1.8-pre + * Version: 3.1.8 * * Requires: jQuery 1.2.2+ */ @@ -32,7 +32,7 @@ } var special = $.event.special.mousewheel = { - version: '3.1.8-pre', + version: '3.1.8', setup: function() { if ( this.addEventListener ) { diff --git a/mousewheel.jquery.json b/mousewheel.jquery.json index 489797589..b0a211708 100644 --- a/mousewheel.jquery.json +++ b/mousewheel.jquery.json @@ -7,7 +7,7 @@ "mouse", "event" ], - "version": "3.1.8-pre", + "version": "3.1.8", "author": { "name": "Brandon Aaron", "url": "http://brandon.aaron.sh" diff --git a/package.json b/package.json index 77cdc6a7f..92992c15b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jquery-mousewheel", - "version": "3.1.8-pre", + "version": "3.1.8", "author": "Brandon Aaron (http://brandon.aaron.sh)", "description": "A jQuery plugin that adds cross-browser mouse wheel support.", "license": "MIT", From 171976e5dbb9abf8845a55e75d9569adac597d3b Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Sat, 14 Dec 2013 14:55:00 -0500 Subject: [PATCH 112/136] again with my indents --- jquery.mousewheel.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index 08e5b53b0..c41b7af37 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -142,8 +142,8 @@ // is treating this as an older mouse wheel event. // We'll divide it by 40 to try and get a more usable deltaFactor. if ( lowestDelta === 120 ) { - oldMode = true; - lowestDelta /= 40; + oldMode = true; + lowestDelta /= 40; } } From 906ace7c6a7552dfff443fba60744f91fb0d6461 Mon Sep 17 00:00:00 2001 From: James Smith Date: Sun, 15 Dec 2013 10:52:03 -0500 Subject: [PATCH 113/136] Update bower.json --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 4d7ab62ce..fe233c709 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery-mousewheel", - "version": "3.1.8, + "version": "3.1.8", "main": "./jquery.mousewheel.js", "ignore": [ "*.json", From d55a79ef9ff60e4b49cde4598664a2ff682316f5 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Mon, 16 Dec 2013 09:24:00 -0500 Subject: [PATCH 114/136] Bumping to 3.1.9. Including a fix for the broken bower.json in 3.1.8 and updates to the old delta handling code. --- ChangeLog.md | 6 ++++++ bower.json | 2 +- jquery.mousewheel.js | 34 ++++++++++++++++++++++------------ mousewheel.jquery.json | 2 +- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 1e524d9b8..19bb7372e 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,11 @@ # Mouse Wheel ChangeLog +## 3.1.9 + +* Fix bower.json file +* Updated how the deltas are adjusted for older mousewheel based events that have deltas that are factors of 120. +* Add $.event.special.mousewheel.settings.adjustOldDeltas (defaults to true) to turn off adjusting of old deltas that are factors of 120. You'd turn this off if you want to be as close to native scrolling as possible. + ## 3.1.8 * Even better handling of older browsers that use a wheelDelta based on 120 diff --git a/bower.json b/bower.json index fe233c709..3b5f803d5 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery-mousewheel", - "version": "3.1.8", + "version": "3.1.9", "main": "./jquery.mousewheel.js", "ignore": [ "*.json", diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index c41b7af37..63c968a84 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -1,7 +1,7 @@ /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh) * Licensed under the MIT License (LICENSE.txt). * - * Version: 3.1.8 + * Version: 3.1.9 * * Requires: jQuery 1.2.2+ */ @@ -23,7 +23,7 @@ toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ? ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'], slice = Array.prototype.slice, - oldMode, nullLowestDeltaTimeout, lowestDelta; + nullLowestDeltaTimeout, lowestDelta; if ( $.event.fixHooks ) { for ( var i = toFix.length; i; ) { @@ -32,7 +32,7 @@ } var special = $.event.special.mousewheel = { - version: '3.1.8', + version: '3.1.9', setup: function() { if ( this.addEventListener ) { @@ -63,6 +63,10 @@ getPageHeight: function(elem) { return $(elem).height(); + }, + + settings: { + adjustOldDeltas: true } }; @@ -138,18 +142,14 @@ if ( !lowestDelta || absDelta < lowestDelta ) { lowestDelta = absDelta; - // Assuming that if the lowestDelta is 120, then that the browser - // is treating this as an older mouse wheel event. - // We'll divide it by 40 to try and get a more usable deltaFactor. - if ( lowestDelta === 120 ) { - oldMode = true; + // Adjust older deltas if necessary + if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) { lowestDelta /= 40; } } - // When in oldMode the delta is based on 120. - // Dividing by 40 to try and get a more usable deltaFactor. - if ( oldMode ) { + // Adjust older deltas if necessary + if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) { // Divide all the things by 40! delta /= 40; deltaX /= 40; @@ -185,7 +185,17 @@ function nullLowestDelta() { lowestDelta = null; - oldMode = null; + } + + function shouldAdjustOldDeltas(orgEvent, absDelta) { + // If this is an older event and the delta is divisable by 120, + // then we are assuming that the browser is treating this as an + // older mouse wheel event and that we should divide the deltas + // by 40 to try and get a more usable deltaFactor. + // Side note, this actually impacts the reported scroll distance + // in older browsers and can cause scrolling to be slower than native. + // Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false. + return special.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0; } })); diff --git a/mousewheel.jquery.json b/mousewheel.jquery.json index b0a211708..270109e6d 100644 --- a/mousewheel.jquery.json +++ b/mousewheel.jquery.json @@ -7,7 +7,7 @@ "mouse", "event" ], - "version": "3.1.8", + "version": "3.1.9", "author": { "name": "Brandon Aaron", "url": "http://brandon.aaron.sh" From 87aa074958771243a843b327186250fe6ee254a5 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Mon, 16 Dec 2013 09:49:43 -0500 Subject: [PATCH 115/136] missed a version again --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 92992c15b..baa1dff57 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jquery-mousewheel", - "version": "3.1.8", + "version": "3.1.9", "author": "Brandon Aaron (http://brandon.aaron.sh)", "description": "A jQuery plugin that adds cross-browser mouse wheel support.", "license": "MIT", From 1b6db9d4990d753fea64ffaa412a9ad84612561a Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Wed, 19 Feb 2014 11:36:59 -0500 Subject: [PATCH 116/136] bump version to 3.1.10-pre --- ChangeLog.md | 2 ++ bower.json | 2 +- jquery.mousewheel.js | 2 +- mousewheel.jquery.json | 2 +- package.json | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 19bb7372e..0e71908d7 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,7 @@ # Mouse Wheel ChangeLog +## 3.1.10 + ## 3.1.9 * Fix bower.json file diff --git a/bower.json b/bower.json index 3b5f803d5..3ef09c7a9 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery-mousewheel", - "version": "3.1.9", + "version": "3.1.10-pre", "main": "./jquery.mousewheel.js", "ignore": [ "*.json", diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index 63c968a84..0f86946c4 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -1,7 +1,7 @@ /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh) * Licensed under the MIT License (LICENSE.txt). * - * Version: 3.1.9 + * Version: 3.1.10-pre * * Requires: jQuery 1.2.2+ */ diff --git a/mousewheel.jquery.json b/mousewheel.jquery.json index 270109e6d..59cc1eefa 100644 --- a/mousewheel.jquery.json +++ b/mousewheel.jquery.json @@ -7,7 +7,7 @@ "mouse", "event" ], - "version": "3.1.9", + "version": "3.1.10-pre", "author": { "name": "Brandon Aaron", "url": "http://brandon.aaron.sh" diff --git a/package.json b/package.json index baa1dff57..0bf704da3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jquery-mousewheel", - "version": "3.1.9", + "version": "3.1.10-pre", "author": "Brandon Aaron (http://brandon.aaron.sh)", "description": "A jQuery plugin that adds cross-browser mouse wheel support.", "license": "MIT", From 09bb82c73c5650812e36dfd27d605d64d3ed32b8 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Wed, 19 Feb 2014 11:34:51 -0500 Subject: [PATCH 117/136] Fix issue with line height calculation when using older versions of jQuery --- jquery.mousewheel.js | 6 +++++- test/index.html | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index 0f86946c4..2b852cfc6 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -58,7 +58,11 @@ }, getLineHeight: function(elem) { - return parseInt($(elem)['offsetParent' in $.fn ? 'offsetParent' : 'parent']().css('fontSize'), 10); + var $parent = $(elem)['offsetParent' in $.fn ? 'offsetParent' : 'parent'](); + if (!$parent.length) { + $parent = $('body'); + } + return parseInt($parent.css('fontSize'), 10); }, getPageHeight: function(elem) { diff --git a/test/index.html b/test/index.html index f04c80ce2..0c683cf4e 100644 --- a/test/index.html +++ b/test/index.html @@ -113,7 +113,7 @@ $('#jqueryVersion').html($.fn.jquery); var loghandle = function(event, delta) { - var o = '', id = event.currentTarget.id; + var o = '', id = event.currentTarget.id || event.currentTarget.nodeName; o = '#' + id + ':'; @@ -137,6 +137,11 @@ log( o ); }; + $(document) + .mousewheel(function(event, delta) { + loghandle(event, delta); + }); + $('#test1') .mousewheel(function(event, delta) { loghandle(event, delta); From 821f4fde0b81c3cd39ca8db9fdf8c50e4f9861d9 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Wed, 19 Feb 2014 11:38:44 -0500 Subject: [PATCH 118/136] update changelog --- ChangeLog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 0e71908d7..4d90e824e 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,8 @@ ## 3.1.10 +* Fix issue with calculating line height when using older versions of jQuery + ## 3.1.9 * Fix bower.json file From 36f7799fca5a50e66de0f4d8a2215f3a9bed16a3 Mon Sep 17 00:00:00 2001 From: chriscbrock Date: Thu, 20 Feb 2014 09:21:39 +1300 Subject: [PATCH 119/136] Normalise offsetX and offsetY on the event According to the W3C Working Draft, offsetX and offsetY should be relative to the padding edge of the target element. The only browser using this convention is IE. Webkit uses the border edge, Opera uses the content edge, and FireFox does not support the properties. Normalizing to the border edge is easiest to do. --- jquery.mousewheel.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index 63c968a84..6f5e70339 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -87,7 +87,9 @@ delta = 0, deltaX = 0, deltaY = 0, - absDelta = 0; + absDelta = 0, + offsetX = 0, + offsetY = 0; event = $.event.fix(orgEvent); event.type = 'mousewheel'; @@ -160,11 +162,18 @@ delta = Math[ delta >= 1 ? 'floor' : 'ceil' ](delta / lowestDelta); deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta); deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta); + + // Normalise offsetX and offsetY properties + var boundingRect = this.getBoundingClientRect(); + offsetX = event.clientX - boundingRect.left; + offsetY = event.clientY - boundingRect.top; // Add information to the event object event.deltaX = deltaX; event.deltaY = deltaY; event.deltaFactor = lowestDelta; + event.offsetX = offsetX; + event.offsetY = offsetY; // Go ahead and set deltaMode to 0 since we converted to pixels // Although this is a little odd since we overwrite the deltaX/Y // properties with normalized deltas. From 309077ffb65fd9aa49c25fcfbe0a0c2f7f1699bb Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Wed, 9 Apr 2014 13:21:39 -0400 Subject: [PATCH 120/136] make a setting for normalizing the offset and check that getBoundingClientRect function exists before trying to call it --- jquery.mousewheel.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index 0a57c3605..ff5d2471c 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -70,7 +70,8 @@ }, settings: { - adjustOldDeltas: true + adjustOldDeltas: true, // see shouldAdjustOldDeltas() below + normalizeOffset: true // calls getBoundingClientRect for each event } }; @@ -166,11 +167,13 @@ delta = Math[ delta >= 1 ? 'floor' : 'ceil' ](delta / lowestDelta); deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta); deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta); - + // Normalise offsetX and offsetY properties - var boundingRect = this.getBoundingClientRect(); - offsetX = event.clientX - boundingRect.left; - offsetY = event.clientY - boundingRect.top; + if ( special.settings.normalizeOffset && this.getBoundingClientRect ) { + var boundingRect = this.getBoundingClientRect(); + offsetX = event.clientX - boundingRect.left; + offsetY = event.clientY - boundingRect.top; + } // Add information to the event object event.deltaX = deltaX; From 9ad3d85fdf851c6962f887c23811d62cc593c2db Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Wed, 9 Apr 2014 13:30:28 -0400 Subject: [PATCH 121/136] clean up data when tearing down --- jquery.mousewheel.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index ff5d2471c..a3dfc9e85 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -55,6 +55,9 @@ } else { this.onmousewheel = null; } + // Clean up the data we added to the element + $.removeData(this, 'mousewheel-line-height'); + $.removeData(this, 'mousewheel-page-height'); }, getLineHeight: function(elem) { From dc5128e503cf514f860f3ded672e6fe10af04c4b Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Wed, 9 Apr 2014 13:30:51 -0400 Subject: [PATCH 122/136] update changlog --- ChangeLog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 4d90e824e..dbe6dcae6 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,6 +3,8 @@ ## 3.1.10 * Fix issue with calculating line height when using older versions of jQuery +* Add offsetX/Y normalization with setting to turn it off +* Cleans up data on teardown ## 3.1.9 From dce320ae63af29458e95ed2b8b00183848bb2e4f Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Wed, 9 Apr 2014 13:33:33 -0400 Subject: [PATCH 123/136] add minified source --- .gitignore | 3 +-- Gruntfile.js | 2 +- jquery.mousewheel.min.js | 8 ++++++++ 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 jquery.mousewheel.min.js diff --git a/.gitignore b/.gitignore index 9fb87cbc9..384a0ee88 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .DS_Store /npm-debug.log -/build /node_modules -/test/browserify/node_modules \ No newline at end of file +/test/browserify/node_modules diff --git a/Gruntfile.js b/Gruntfile.js index e7aa49e5c..1bba7f3c0 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -17,7 +17,7 @@ module.exports = function(grunt) { }, build: { src: 'jquery.mousewheel.js', - dest: 'build/jquery.mousewheel.min.js' + dest: 'jquery.mousewheel.min.js' } }, connect: { diff --git a/jquery.mousewheel.min.js b/jquery.mousewheel.min.js new file mode 100644 index 000000000..a06929bf3 --- /dev/null +++ b/jquery.mousewheel.min.js @@ -0,0 +1,8 @@ +/*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh) + * Licensed under the MIT License (LICENSE.txt). + * + * Version: 3.1.10-pre + * + * Requires: jQuery 1.2.2+ + */ +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.9",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b)["offsetParent"in a.fn?"offsetParent":"parent"]();return c.length||(c=a("body")),parseInt(c.css("fontSize"),10)},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})}); \ No newline at end of file From 215c5dd3cfa3d4205e14c1ca0fa603b9463e4aca Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Wed, 9 Apr 2014 13:35:38 -0400 Subject: [PATCH 124/136] only jshint against src file --- Gruntfile.js | 2 +- jquery.mousewheel.js | 2 +- jquery.mousewheel.min.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 1bba7f3c0..ccae0d03f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -6,7 +6,7 @@ module.exports = function(grunt) { options: { jshintrc: '.jshintrc' }, - all: ['*.js'] + all: ['jquery.mousewheel.js'] }, uglify: { options: { diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index a3dfc9e85..ba1bd1245 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -32,7 +32,7 @@ } var special = $.event.special.mousewheel = { - version: '3.1.9', + version: '3.1.10-pre', setup: function() { if ( this.addEventListener ) { diff --git a/jquery.mousewheel.min.js b/jquery.mousewheel.min.js index a06929bf3..a6ae0667e 100644 --- a/jquery.mousewheel.min.js +++ b/jquery.mousewheel.min.js @@ -5,4 +5,4 @@ * * Requires: jQuery 1.2.2+ */ -!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.9",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b)["offsetParent"in a.fn?"offsetParent":"parent"]();return c.length||(c=a("body")),parseInt(c.css("fontSize"),10)},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})}); \ No newline at end of file +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.10-pre",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b)["offsetParent"in a.fn?"offsetParent":"parent"]();return c.length||(c=a("body")),parseInt(c.css("fontSize"),10)},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})}); \ No newline at end of file From 1e98e6929491702a8ea6c3262bc710ed29f6be3c Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Wed, 9 Apr 2014 14:21:44 -0400 Subject: [PATCH 125/136] version 3.1.10 --- bower.json | 2 +- jquery.mousewheel.js | 4 ++-- jquery.mousewheel.min.js | 4 ++-- package.json | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index 3ef09c7a9..f97ae0f61 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery-mousewheel", - "version": "3.1.10-pre", + "version": "3.1.10", "main": "./jquery.mousewheel.js", "ignore": [ "*.json", diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index ba1bd1245..4ace67dfc 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -1,7 +1,7 @@ /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh) * Licensed under the MIT License (LICENSE.txt). * - * Version: 3.1.10-pre + * Version: 3.1.10 * * Requires: jQuery 1.2.2+ */ @@ -32,7 +32,7 @@ } var special = $.event.special.mousewheel = { - version: '3.1.10-pre', + version: '3.1.10', setup: function() { if ( this.addEventListener ) { diff --git a/jquery.mousewheel.min.js b/jquery.mousewheel.min.js index a6ae0667e..b886dd477 100644 --- a/jquery.mousewheel.min.js +++ b/jquery.mousewheel.min.js @@ -1,8 +1,8 @@ /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh) * Licensed under the MIT License (LICENSE.txt). * - * Version: 3.1.10-pre + * Version: 3.1.10 * * Requires: jQuery 1.2.2+ */ -!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.10-pre",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b)["offsetParent"in a.fn?"offsetParent":"parent"]();return c.length||(c=a("body")),parseInt(c.css("fontSize"),10)},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})}); \ No newline at end of file +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.10",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b)["offsetParent"in a.fn?"offsetParent":"parent"]();return c.length||(c=a("body")),parseInt(c.css("fontSize"),10)},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})}); \ No newline at end of file diff --git a/package.json b/package.json index 0bf704da3..de2084f68 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jquery-mousewheel", - "version": "3.1.10-pre", + "version": "3.1.10", "author": "Brandon Aaron (http://brandon.aaron.sh)", "description": "A jQuery plugin that adds cross-browser mouse wheel support.", "license": "MIT", From f8635d1f13caa4dd51e8c8fe30f951231232f65a Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Wed, 9 Apr 2014 14:24:13 -0400 Subject: [PATCH 126/136] did it again... --- mousewheel.jquery.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mousewheel.jquery.json b/mousewheel.jquery.json index 59cc1eefa..0fe34e283 100644 --- a/mousewheel.jquery.json +++ b/mousewheel.jquery.json @@ -7,7 +7,7 @@ "mouse", "event" ], - "version": "3.1.10-pre", + "version": "3.1.10", "author": { "name": "Brandon Aaron", "url": "http://brandon.aaron.sh" From 0f395d8949f937b987f384cc8833c30a0648fd9b Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Wed, 9 Apr 2014 14:26:18 -0400 Subject: [PATCH 127/136] bump to 3.1.11 so all the package managers are on the same version --- ChangeLog.md | 4 ++++ bower.json | 2 +- jquery.mousewheel.js | 4 ++-- jquery.mousewheel.min.js | 4 ++-- mousewheel.jquery.json | 2 +- package.json | 2 +- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index dbe6dcae6..7a00439c3 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,9 @@ # Mouse Wheel ChangeLog +## 3.1.11 + +* Fix version number for package managers... + ## 3.1.10 * Fix issue with calculating line height when using older versions of jQuery diff --git a/bower.json b/bower.json index f97ae0f61..ebb06de4b 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery-mousewheel", - "version": "3.1.10", + "version": "3.1.11", "main": "./jquery.mousewheel.js", "ignore": [ "*.json", diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index 4ace67dfc..70340a57a 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -1,7 +1,7 @@ /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh) * Licensed under the MIT License (LICENSE.txt). * - * Version: 3.1.10 + * Version: 3.1.11 * * Requires: jQuery 1.2.2+ */ @@ -32,7 +32,7 @@ } var special = $.event.special.mousewheel = { - version: '3.1.10', + version: '3.1.11', setup: function() { if ( this.addEventListener ) { diff --git a/jquery.mousewheel.min.js b/jquery.mousewheel.min.js index b886dd477..e21c2787c 100644 --- a/jquery.mousewheel.min.js +++ b/jquery.mousewheel.min.js @@ -1,8 +1,8 @@ /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh) * Licensed under the MIT License (LICENSE.txt). * - * Version: 3.1.10 + * Version: 3.1.11 * * Requires: jQuery 1.2.2+ */ -!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.10",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b)["offsetParent"in a.fn?"offsetParent":"parent"]();return c.length||(c=a("body")),parseInt(c.css("fontSize"),10)},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})}); \ No newline at end of file +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.11",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b)["offsetParent"in a.fn?"offsetParent":"parent"]();return c.length||(c=a("body")),parseInt(c.css("fontSize"),10)},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})}); \ No newline at end of file diff --git a/mousewheel.jquery.json b/mousewheel.jquery.json index 0fe34e283..6e9790f5f 100644 --- a/mousewheel.jquery.json +++ b/mousewheel.jquery.json @@ -7,7 +7,7 @@ "mouse", "event" ], - "version": "3.1.10", + "version": "3.1.11", "author": { "name": "Brandon Aaron", "url": "http://brandon.aaron.sh" diff --git a/package.json b/package.json index de2084f68..3b3c0baa0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jquery-mousewheel", - "version": "3.1.10", + "version": "3.1.11", "author": "Brandon Aaron (http://brandon.aaron.sh)", "description": "A jQuery plugin that adds cross-browser mouse wheel support.", "license": "MIT", From 7dfc7532d1c69c1fbca358c1c11e8cae7f272ddb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 10 Jun 2014 07:46:22 -0400 Subject: [PATCH 128/136] Include LICENSE.txt in Bower Fixes #110 --- bower.json | 1 + 1 file changed, 1 insertion(+) diff --git a/bower.json b/bower.json index ebb06de4b..6b612d03e 100644 --- a/bower.json +++ b/bower.json @@ -7,6 +7,7 @@ "*.markdown", "*.txt", ".*", + "!LICENSE.txt", "Gruntfile.js", "test" ], From aa6e7f4087f6ee4e958a25cd022b9ab224cf913a Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Thu, 10 Jul 2014 11:09:36 -0400 Subject: [PATCH 129/136] bump version to 3.1.12-pre --- bower.json | 2 +- jquery.mousewheel.js | 4 ++-- jquery.mousewheel.min.js | 4 ++-- mousewheel.jquery.json | 2 +- package.json | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bower.json b/bower.json index 6b612d03e..df3bbb870 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery-mousewheel", - "version": "3.1.11", + "version": "3.1.12-pre", "main": "./jquery.mousewheel.js", "ignore": [ "*.json", diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index 70340a57a..a7038e602 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -1,7 +1,7 @@ /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh) * Licensed under the MIT License (LICENSE.txt). * - * Version: 3.1.11 + * Version: 3.1.12-pre * * Requires: jQuery 1.2.2+ */ @@ -32,7 +32,7 @@ } var special = $.event.special.mousewheel = { - version: '3.1.11', + version: '3.1.12-pre', setup: function() { if ( this.addEventListener ) { diff --git a/jquery.mousewheel.min.js b/jquery.mousewheel.min.js index e21c2787c..dd3de1e76 100644 --- a/jquery.mousewheel.min.js +++ b/jquery.mousewheel.min.js @@ -1,8 +1,8 @@ /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh) * Licensed under the MIT License (LICENSE.txt). * - * Version: 3.1.11 + * Version: 3.1.12-pre * * Requires: jQuery 1.2.2+ */ -!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.11",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b)["offsetParent"in a.fn?"offsetParent":"parent"]();return c.length||(c=a("body")),parseInt(c.css("fontSize"),10)},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})}); \ No newline at end of file +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12-pre",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b)["offsetParent"in a.fn?"offsetParent":"parent"]();return c.length||(c=a("body")),parseInt(c.css("fontSize"),10)},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})}); \ No newline at end of file diff --git a/mousewheel.jquery.json b/mousewheel.jquery.json index 6e9790f5f..47ac8fee8 100644 --- a/mousewheel.jquery.json +++ b/mousewheel.jquery.json @@ -7,7 +7,7 @@ "mouse", "event" ], - "version": "3.1.11", + "version": "3.1.12-pre", "author": { "name": "Brandon Aaron", "url": "http://brandon.aaron.sh" diff --git a/package.json b/package.json index 3b3c0baa0..42e5b949e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jquery-mousewheel", - "version": "3.1.11", + "version": "3.1.12-pre", "author": "Brandon Aaron (http://brandon.aaron.sh)", "description": "A jQuery plugin that adds cross-browser mouse wheel support.", "license": "MIT", From 669312f49950ae1b8bc2381234c7e4fed086cd86 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Thu, 10 Jul 2014 11:22:35 -0400 Subject: [PATCH 130/136] Use the font-size of the element if the font-size of the parent is 0 and use 16 if both are 0 (applies when deltaMode is 1). --- ChangeLog.md | 4 ++++ jquery.mousewheel.js | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 7a00439c3..77cceacdd 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,9 @@ # Mouse Wheel ChangeLog +## 3.1.12 + +* Fix possible 0 value for line height when in delta mode 1 + ## 3.1.11 * Fix version number for package managers... diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index a7038e602..b59e4d866 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -61,11 +61,12 @@ }, getLineHeight: function(elem) { - var $parent = $(elem)['offsetParent' in $.fn ? 'offsetParent' : 'parent'](); + var $elem = $(elem), + $parent = $elem['offsetParent' in $.fn ? 'offsetParent' : 'parent'](); if (!$parent.length) { $parent = $('body'); } - return parseInt($parent.css('fontSize'), 10); + return parseInt($parent.css('fontSize'), 10) || parseInt($elem.css('fontSize'), 10) || 16; }, getPageHeight: function(elem) { From c61913ebf569c7a3f086b7fb40d941c282d1ce48 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Thu, 10 Jul 2014 11:27:19 -0400 Subject: [PATCH 131/136] bump the version to 3.1.12 --- bower.json | 2 +- jquery.mousewheel.js | 4 ++-- jquery.mousewheel.min.js | 4 ++-- mousewheel.jquery.json | 2 +- package.json | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bower.json b/bower.json index df3bbb870..4ce5741e7 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery-mousewheel", - "version": "3.1.12-pre", + "version": "3.1.12", "main": "./jquery.mousewheel.js", "ignore": [ "*.json", diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index b59e4d866..6756fa610 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -1,7 +1,7 @@ /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh) * Licensed under the MIT License (LICENSE.txt). * - * Version: 3.1.12-pre + * Version: 3.1.12 * * Requires: jQuery 1.2.2+ */ @@ -32,7 +32,7 @@ } var special = $.event.special.mousewheel = { - version: '3.1.12-pre', + version: '3.1.12', setup: function() { if ( this.addEventListener ) { diff --git a/jquery.mousewheel.min.js b/jquery.mousewheel.min.js index dd3de1e76..bb7f43fe5 100644 --- a/jquery.mousewheel.min.js +++ b/jquery.mousewheel.min.js @@ -1,8 +1,8 @@ /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh) * Licensed under the MIT License (LICENSE.txt). * - * Version: 3.1.12-pre + * Version: 3.1.12 * * Requires: jQuery 1.2.2+ */ -!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12-pre",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b)["offsetParent"in a.fn?"offsetParent":"parent"]();return c.length||(c=a("body")),parseInt(c.css("fontSize"),10)},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})}); \ No newline at end of file +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b),d=c["offsetParent"in a.fn?"offsetParent":"parent"]();return d.length||(d=a("body")),parseInt(d.css("fontSize"),10)||parseInt(c.css("fontSize"),10)||16},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})}); \ No newline at end of file diff --git a/mousewheel.jquery.json b/mousewheel.jquery.json index 47ac8fee8..4d8eadb2d 100644 --- a/mousewheel.jquery.json +++ b/mousewheel.jquery.json @@ -7,7 +7,7 @@ "mouse", "event" ], - "version": "3.1.12-pre", + "version": "3.1.12", "author": { "name": "Brandon Aaron", "url": "http://brandon.aaron.sh" diff --git a/package.json b/package.json index 42e5b949e..8fadb4b6b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jquery-mousewheel", - "version": "3.1.12-pre", + "version": "3.1.12", "author": "Brandon Aaron (http://brandon.aaron.sh)", "description": "A jQuery plugin that adds cross-browser mouse wheel support.", "license": "MIT", From d6a305cf0e42a140c65bc611e3954da80934261b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Wed, 22 Oct 2014 16:49:32 -0400 Subject: [PATCH 132/136] Transfer ownership to jQuery Foundation --- LICENSE.txt | 19 ++++++++++++++++++- README.md | 9 --------- jquery.mousewheel.js | 10 +++++----- package.json | 23 ++++++++++++++++------- 4 files changed, 39 insertions(+), 22 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index ad2020df4..b2cdb48e8 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,14 @@ -Copyright (c) 2013, Brandon Aaron (http://brandon.aaron.sh) +Copyright 2006, 2014 jQuery Foundation and other contributors, +https://jquery.org/ + +This software consists of voluntary contributions made by many +individuals. For exact contribution history, see the revision history +available at https://github.com/jquery/jquery-mousewheel + +The following license applies to all parts of this software except as +documented below: + +==== Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -18,3 +28,10 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +==== + +All files located in the node_modules and external directories are +externally maintained libraries used by this software which have their +own licenses; we recommend you read them, as their terms may differ from +the terms above. diff --git a/README.md b/README.md index e64cd5f65..a03fdde89 100644 --- a/README.md +++ b/README.md @@ -48,9 +48,6 @@ The `deltaFactor` property was added to the event object in 3.1.5 so that the ac extracted. This is a non-standard property. -## See it in action -[See the tests on Github](http://brandonaaron.github.io/jquery-mousewheel/test). - ## Using with [Browserify](http://browserify.org) Support for browserify is baked in. @@ -77,9 +74,3 @@ In your browser-side javascript: var $ = require('jquery-browserify'); require('jquery-mousewheel')($); ``` - -## License - -This plugin is licensed under the [MIT License](LICENSE.txt). - -Copyright (c) 2013 [Brandon Aaron](http://brandon.aaron.sh) diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index 6756fa610..bf61ad0e1 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -1,9 +1,9 @@ -/*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh) - * Licensed under the MIT License (LICENSE.txt). +/*! + * jQuery Mousewheel 3.1.12 * - * Version: 3.1.12 - * - * Requires: jQuery 1.2.2+ + * Copyright 2014 jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license */ (function (factory) { diff --git a/package.json b/package.json index 8fadb4b6b..bd9903d02 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,25 @@ { "name": "jquery-mousewheel", "version": "3.1.12", - "author": "Brandon Aaron (http://brandon.aaron.sh)", + "author": { + "name": "jQuery Foundation and other contributors", + "url": "https://github.com/jquery/jquery-mousewheel/blob/master/AUTHORS.txt" + }, "description": "A jQuery plugin that adds cross-browser mouse wheel support.", - "license": "MIT", - "homepage": "https://github.com/brandonaaron/jquery-mousewheel", + "licenses": [ + { + "type": "MIT", + "url": "https://github.com/jquery/jquery-mousewheel/blob/master/LICENSE.txt" + } + ], + "homepage": "https://github.com/jquery/jquery-mousewheel", "main": "./jquery.mousewheel.js", "repository": { "type": "git", - "url": "https://github.com/brandonaaron/jquery-mousewheel.git" + "url": "https://github.com/jquery/jquery-mousewheel.git" }, "bugs": { - "url": "https://github.com/brandonaaron/jquery-mousewheel/issues" + "url": "https://github.com/jquery/jquery-mousewheel/issues" }, "keywords": [ "jquery", @@ -19,13 +27,14 @@ "wheel", "event", "mousewheel", - "plugin", + "jquery-plugin", "browser" ], "files": [ "ChangeLog.md", "jquery.mousewheel.js", - "README.md" + "README.md", + "LICENSE.txt" ], "devDependencies": { "grunt": "~0.4.1", From 1299f364ca13460c19cd1b1db63bad04541f515a Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Fri, 19 Jun 2015 15:41:44 -0400 Subject: [PATCH 133/136] Update license and regenerate the correct compressed version --- LICENSE.txt | 2 +- jquery.mousewheel.js | 6 +++--- jquery.mousewheel.min.js | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index b2cdb48e8..919fe6a7e 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright 2006, 2014 jQuery Foundation and other contributors, +Copyright jQuery Foundation and other contributors https://jquery.org/ This software consists of voluntary contributions made by many diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index bf61ad0e1..3eadb7edf 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -1,8 +1,8 @@ /*! - * jQuery Mousewheel 3.1.12 + * jQuery Mousewheel 3.1.13 * - * Copyright 2014 jQuery Foundation and other contributors - * Released under the MIT license. + * Copyright jQuery Foundation and other contributors + * Released under the MIT license * http://jquery.org/license */ diff --git a/jquery.mousewheel.min.js b/jquery.mousewheel.min.js index bb7f43fe5..03bfd60c5 100644 --- a/jquery.mousewheel.min.js +++ b/jquery.mousewheel.min.js @@ -1,8 +1,8 @@ -/*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh) - * Licensed under the MIT License (LICENSE.txt). +/*! + * jQuery Mousewheel 3.1.13 * - * Version: 3.1.12 - * - * Requires: jQuery 1.2.2+ + * Copyright 2015 jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license */ !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b),d=c["offsetParent"in a.fn?"offsetParent":"parent"]();return d.length||(d=a("body")),parseInt(d.css("fontSize"),10)||parseInt(c.css("fontSize"),10)||16},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})}); \ No newline at end of file From 216acc52a1ac90dbde0208272908cd152168feb9 Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Fri, 19 Jun 2015 15:43:16 -0400 Subject: [PATCH 134/136] Remove the obsolete jQuery Plugin Registry file --- ChangeLog.md | 6 ++++++ mousewheel.jquery.json | 27 --------------------------- 2 files changed, 6 insertions(+), 27 deletions(-) delete mode 100644 mousewheel.jquery.json diff --git a/ChangeLog.md b/ChangeLog.md index 77cceacdd..76752a1a0 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,11 @@ # Mouse Wheel ChangeLog +## 3.1.13 + +* Update copyright notice and license to remove years +* Create the correct compressed version +* Remove the obsolete jQuery Plugin Registry file + ## 3.1.12 * Fix possible 0 value for line height when in delta mode 1 diff --git a/mousewheel.jquery.json b/mousewheel.jquery.json deleted file mode 100644 index 4d8eadb2d..000000000 --- a/mousewheel.jquery.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "mousewheel", - "title": "jQuery Mousewheel", - "description": "A jQuery plugin that adds cross-browser mouse wheel support.", - "keywords": [ - "mousewheel", - "mouse", - "event" - ], - "version": "3.1.12", - "author": { - "name": "Brandon Aaron", - "url": "http://brandon.aaron.sh" - }, - "licenses": [ - { - "type": "MIT", - "url": "https://raw.github.com/brandonaaron/jquery-mousewheel/master/LICENSE.txt" - } - ], - "bugs": "https://github.com/brandonaaron/jquery-mousewheel/issues", - "homepage": "https://github.com/brandonaaron/jquery-mousewheel", - "download": "https://github.com/brandonaaron/jquery-mousewheel/tags", - "dependencies": { - "jquery": ">=1.2.2" - } -} From 67289b6b2aa0066d7d78a5807f520387135ffb22 Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Fri, 19 Jun 2015 15:45:38 -0400 Subject: [PATCH 135/136] Version 3.1.13 --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 4ce5741e7..8bd2cc5e9 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery-mousewheel", - "version": "3.1.12", + "version": "3.1.13", "main": "./jquery.mousewheel.js", "ignore": [ "*.json", diff --git a/package.json b/package.json index bd9903d02..4848f6bc7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jquery-mousewheel", - "version": "3.1.12", + "version": "3.1.13", "author": { "name": "jQuery Foundation and other contributors", "url": "https://github.com/jquery/jquery-mousewheel/blob/master/AUTHORS.txt" From b1c062e93b44f473022297c386d57fa7e58b6aae Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Wed, 15 Jul 2015 14:18:15 -0400 Subject: [PATCH 136/136] Remove moot `version` property from bower.json See https://github.com/bower/bower.json-spec/commit/a325da3 Closes #140 Thanks for the heads-up @kkirsche! --- bower.json | 1 - 1 file changed, 1 deletion(-) diff --git a/bower.json b/bower.json index 8bd2cc5e9..8abe3bf67 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,5 @@ { "name": "jquery-mousewheel", - "version": "3.1.13", "main": "./jquery.mousewheel.js", "ignore": [ "*.json",