[Pkg-javascript-commits] [jquery-goodies] 01/11: Updated mousewheel to 3.1.13

Marcelo Jorge Vieira metal at moszumanska.debian.org
Sat Mar 26 15:02:34 UTC 2016


This is an automated email from the git hooks/post-receive script.

metal pushed a commit to branch master
in repository jquery-goodies.

commit ac8887f25ca10a51cdfd47181ab62cfa37cb762f
Author: Marcelo Jorge Vieira <metal at alucinados.com>
Date:   Sat Mar 26 10:05:49 2016 -0300

    Updated mousewheel to 3.1.13
---
 mousewheel/ChangeLog.markdown   |  49 -----
 mousewheel/ChangeLog.md         | 147 ++++++++++++++
 mousewheel/README.markdown      |  11 -
 mousewheel/README.md            |  76 +++++++
 mousewheel/jquery.mousewheel.js | 275 +++++++++++++++++++------
 mousewheel/package.json         |  53 +++++
 mousewheel/test/index.html      | 441 ++++++++++++++++++++++------------------
 7 files changed, 732 insertions(+), 320 deletions(-)

diff --git a/mousewheel/ChangeLog.markdown b/mousewheel/ChangeLog.markdown
deleted file mode 100644
index 8dd106b..0000000
--- a/mousewheel/ChangeLog.markdown
+++ /dev/null
@@ -1,49 +0,0 @@
-# Mouse Wheel ChangeLog
-
-
-# 3.0.2
-
-* Fixed delta being opposite value in latest Opera
-* No longer fix pageX, pageY for older mozilla browsers
-* Removed browser detection
-* Cleaned up the code
-
-
-# 3.0.1
-
-* Bad release... creating a new release due to plugins.jquery.com issue :(
-
-
-# 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/mousewheel/ChangeLog.md b/mousewheel/ChangeLog.md
new file mode 100644
index 0000000..76752a1
--- /dev/null
+++ b/mousewheel/ChangeLog.md
@@ -0,0 +1,147 @@
+# 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
+
+## 3.1.11
+
+* Fix version number for package managers...
+
+## 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
+
+* 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
+* And fix version reported by `$.event.special.mousewheel`
+
+## 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
+
+## 3.1.6
+
+* Deprecating `delta`, `deltaX`, and `deltaY` event handler arguments
+* Update actual event object with normalized `deltaX `and `deltaY` values (`event.deltaX`, `event.deltaY`)
+* Add `deltaFactor` to the event object (`event.deltaFactor`)
+* Handle `> 0` but `< 1` deltas better
+* Do not fire the event if `deltaX` and `deltaY` are `0`
+* Better handle different devices that give different `lowestDelta` values
+* Add `$.event.special.mousewheel.version`
+* Some clean up
+
+## 3.1.5
+
+* Bad release because I did not update the new `$.event.special.mousewheel.version`
+
+## 3.1.4
+
+* Always set the `deltaY`
+* Add back in the `deltaX` and `deltaY` support for older Firefox versions
+
+## 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)
+* Include support for browserify
+* Some basic cleaning up
+
+## 3.1.1
+
+* Fix rounding issue with deltas less than zero
+
+
+## 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
+
+
+## 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
+* No longer fix `pageX`, `pageY` for older Mozilla browsers
+* Removed browser detection
+* Cleaned up the code
+
+
+## 3.0.1
+
+* Bad release... creating a new release due to plugins.jquery.com issue :(
+
+
+## 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
diff --git a/mousewheel/README.markdown b/mousewheel/README.markdown
deleted file mode 100644
index 7ec6d03..0000000
--- a/mousewheel/README.markdown
+++ /dev/null
@@ -1,11 +0,0 @@
-# jQuery Mouse Wheel Plugin
-
-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)
-
-## 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.
-
-Copyright (c) 2009 [Brandon Aaron](http://brandonaaron.net)
\ No newline at end of file
diff --git a/mousewheel/README.md b/mousewheel/README.md
new file mode 100644
index 0000000..a03fdde
--- /dev/null
+++ b/mousewheel/README.md
@@ -0,0 +1,76 @@
+# jQuery Mouse Wheel Plugin
+
+A [jQuery](http://jquery.com/) plugin that adds cross-browser mouse wheel support with delta normalization.
+
+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 object is updated with the normalized `deltaX` and `deltaY` properties.
+In addition there is a new property on the event object called `deltaFactor`. Multiply
+the `deltaFactor` by `deltaX` or `deltaY` to get the scroll distance that the browser
+has reported.
+
+Here is an example of using both the bind and helper method syntax:
+
+```js
+// using on
+$('#my_elem').on('mousewheel', function(event) {
+    console.log(event.deltaX, event.deltaY, event.deltaFactor);
+});
+
+// using the event helper
+$('#my_elem').mousewheel(function(event) {
+    console.log(event.deltaX, event.deltaY, event.deltaFactor);
+});
+```
+
+The old behavior of adding three arguments (`delta`, `deltaX`, and `deltaY`) to the
+event handler is now deprecated and will be removed in later releases.
+
+
+## The Deltas...
+
+The combination of Browsers, Operating Systems, and Devices offer a huge range of possible delta values. In fact if the user
+uses a trackpad and then a physical mouse wheel the delta values can differ wildly. This plugin normalizes those
+values so you get a whole number starting at +-1 and going up in increments of +-1 according to the force or
+acceleration that is used. This number has the potential to be in the thousands depending on the device.
+Check out some of the data collected from users [here](http://mousewheeldatacollector.herokuapp.com/).
+
+### Getting the scroll distance
+
+In some use-cases we prefer to have the normalized delta but in others we want to know how far the browser should
+scroll based on the users input. This can be done by multiplying the `deltaFactor` by the `deltaX` or `deltaY`
+event property to find the scroll distance the browser reported.
+
+The `deltaFactor` property was added to the event object in 3.1.5 so that the actual reported delta value can be
+extracted. This is a non-standard property.
+
+
+## Using with [Browserify](http://browserify.org)
+
+Support for browserify is baked in.
+
+```bash
+npm install jquery-mousewheel
+npm install jquery-browserify
+```
+
+In your server-side node.js code:
+
+```js
+var express = require('express');
+var app = express.createServer();
+
+app.use(require('browserify')({
+    require : [ 'jquery-browserify', 'jquery-mousewheel' ]
+}));
+```
+
+In your browser-side javascript:
+
+```js
+var $ = require('jquery-browserify');
+require('jquery-mousewheel')($);
+```
diff --git a/mousewheel/jquery.mousewheel.js b/mousewheel/jquery.mousewheel.js
index b6b89ba..3eadb7e 100644
--- a/mousewheel/jquery.mousewheel.js
+++ b/mousewheel/jquery.mousewheel.js
@@ -1,60 +1,221 @@
-/*! 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.
- * 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.
+/*!
+ * jQuery Mousewheel 3.1.13
  *
- * Version: 3.0.2
- * 
- * Requires: 1.2.2+
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license
+ * http://jquery.org/license
  */
 
-(function($) {
-
-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;
-	}
-};
-
-$.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 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);
-
-	return $.event.handle.apply(this, args);
-}
-
-})(jQuery);
\ No newline at end of file
+(function (factory) {
+    if ( typeof define === 'function' && define.amd ) {
+        // AMD. Register as an anonymous module.
+        define(['jquery'], factory);
+    } else if (typeof exports === 'object') {
+        // Node/CommonJS style for Browserify
+        module.exports = factory;
+    } else {
+        // Browser globals
+        factory(jQuery);
+    }
+}(function ($) {
+
+    var toFix  = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
+        toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?
+                    ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
+        slice  = Array.prototype.slice,
+        nullLowestDeltaTimeout, lowestDelta;
+
+    if ( $.event.fixHooks ) {
+        for ( var i = toFix.length; i; ) {
+            $.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks;
+        }
+    }
+
+    var special = $.event.special.mousewheel = {
+        version: '3.1.12',
+
+        setup: function() {
+            if ( this.addEventListener ) {
+                for ( var i = toBind.length; i; ) {
+                    this.addEventListener( toBind[--i], handler, false );
+                }
+            } 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() {
+            if ( this.removeEventListener ) {
+                for ( var i = toBind.length; i; ) {
+                    this.removeEventListener( toBind[--i], handler, false );
+                }
+            } 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) {
+            var $elem = $(elem),
+                $parent = $elem['offsetParent' in $.fn ? 'offsetParent' : 'parent']();
+            if (!$parent.length) {
+                $parent = $('body');
+            }
+            return parseInt($parent.css('fontSize'), 10) || parseInt($elem.css('fontSize'), 10) || 16;
+        },
+
+        getPageHeight: function(elem) {
+            return $(elem).height();
+        },
+
+        settings: {
+            adjustOldDeltas: true, // see shouldAdjustOldDeltas() below
+            normalizeOffset: true  // calls getBoundingClientRect for each event
+        }
+    };
+
+    $.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,
+            offsetX    = 0,
+            offsetY    = 0;
+        event = $.event.fix(orgEvent);
+        event.type = 'mousewheel';
+
+        // Old school scrollwheel delta
+        if ( 'detail'      in orgEvent ) { deltaY = orgEvent.detail * -1;      }
+        if ( 'wheelDelta'  in orgEvent ) { deltaY = orgEvent.wheelDelta;       }
+        if ( 'wheelDeltaY' in orgEvent ) { deltaY = orgEvent.wheelDeltaY;      }
+        if ( 'wheelDeltaX' in orgEvent ) { deltaX = orgEvent.wheelDeltaX * -1; }
+
+        // Firefox < 17 horizontal scrolling related to DOMMouseScroll event
+        if ( 'axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
+            deltaX = deltaY * -1;
+            deltaY = 0;
+        }
+
+        // Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy
+        delta = deltaY === 0 ? deltaX : deltaY;
+
+        // New school wheel delta (wheel event)
+        if ( 'deltaY' in orgEvent ) {
+            deltaY = orgEvent.deltaY * -1;
+            delta  = deltaY;
+        }
+        if ( 'deltaX' in orgEvent ) {
+            deltaX = orgEvent.deltaX;
+            if ( deltaY === 0 ) { delta  = deltaX * -1; }
+        }
+
+        // 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;
+
+            // Adjust older deltas if necessary
+            if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
+                lowestDelta /= 40;
+            }
+        }
+
+        // Adjust older deltas if necessary
+        if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
+            // Divide all the things by 40!
+            delta  /= 40;
+            deltaX /= 40;
+            deltaY /= 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);
+        deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta);
+
+        // Normalise offsetX and offsetY properties
+        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;
+        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.
+        event.deltaMode = 0;
+
+        // Add event and delta to the front of the arguments
+        args.unshift(event, delta, deltaX, deltaY);
+
+        // Clearout lowestDelta after sometime to better
+        // handle multiple device types that give different
+        // a different lowestDelta
+        // Ex: trackpad = 3 and mouse wheel = 120
+        if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); }
+        nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);
+
+        return ($.event.dispatch || $.event.handle).apply(this, args);
+    }
+
+    function nullLowestDelta() {
+        lowestDelta = 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/package.json b/mousewheel/package.json
new file mode 100644
index 0000000..4848f6b
--- /dev/null
+++ b/mousewheel/package.json
@@ -0,0 +1,53 @@
+{
+  "name": "jquery-mousewheel",
+  "version": "3.1.13",
+  "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.",
+  "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/jquery/jquery-mousewheel.git"
+  },
+  "bugs": {
+    "url": "https://github.com/jquery/jquery-mousewheel/issues"
+  },
+  "keywords": [
+    "jquery",
+    "mouse",
+    "wheel",
+    "event",
+    "mousewheel",
+    "jquery-plugin",
+    "browser"
+  ],
+  "files": [
+    "ChangeLog.md",
+    "jquery.mousewheel.js",
+    "README.md",
+    "LICENSE.txt"
+  ],
+  "devDependencies": {
+    "grunt": "~0.4.1",
+    "grunt-contrib-connect": "~0.5.0",
+    "grunt-contrib-jshint": "~0.7.1",
+    "grunt-contrib-uglify": "~0.2.7"
+  },
+  "directories": {
+    "test": "test"
+  },
+  "jam": {
+    "dependencies": {
+      "jquery": ">=1.2.2"
+    }
+  }
+}
diff --git a/mousewheel/test/index.html b/mousewheel/test/index.html
index ce716a4..0c683cf 100644
--- a/mousewheel/test/index.html
+++ b/mousewheel/test/index.html
@@ -1,204 +1,239 @@
-<!doctype html>
-<html>
-	<head>
-		<title>Testing mousewheel plugin</title>
-		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script>
-		<script type="text/javascript" src="../jquery.mousewheel.js"></script>
-		
-		<style>
-			#test1 {
-				background-color: #000;
-				width: 100px;
-				height: 100px;
-				color: #fff;
-				float: left;
-			}
-			
-			#test2 {
-				background-color: #333;
-				width: 100px;
-				height: 100px;
-				color: #fff;
-				float: left;
-			}
-			
-			#test3 {
-				background-color: #666;
-				width: 100px;
-				height: 100px;
-				color: #fff;
-				float: left;
-			}
-			
-			#test4 {
-				background-color: #000;
-				width: 100px;
-				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: 380px;
-				height: 290px;
-				overflow: auto;
-			}
-		</style>
-		<script type="text/javascript">
-			$(function() {
-				$('#userAgent').html(navigator.userAgent);
-				
-				
-				$('#test1')
-					.mousewheel(function(event, delta) {
-						if (delta > 0)
-							log('#test1: up ('+delta+')');
-						else if (delta < 0)
-							log('#test1: down ('+delta+')');
-						
-						log('pageX: ' + event.pageX + ' pageY: ' + event.pageY );
-					});
-				
-				$('#test2')
-					.mousewheel(function(event, delta) {
-						if (delta > 0)
-							log('#test2: up ('+delta+')');
-						else if (delta < 0)
-							log('#test2: down ('+delta+')');
-						return false; // prevent default
-					});
-				
-				$('#test3')
-					.hover(function() { log('#test3: mouseover'); }, function() { log('#test3: mouseout'); })
-					.mousewheel(function(event, delta) {
-						log('#test3: I should not have been logged');
-					})
-					.unmousewheel();
-				
-				var testRemoval = function(event, delta) {
-					log('#test4: I should not have been logged');
-				};
-				
-				$('#test4')
-					.mousewheel(function(event, delta) {
-						if (delta > 0)
-							log('#test4: up ('+delta+')');
-						else if (delta < 0)
-							log('#test4: down ('+delta+')');
-						return false;
-					})
-					.mousewheel(testRemoval)
-					.mousewheel(function(event, delta) {
-						if (delta > 0)
-							log('#test4: up ('+delta+') from 2nd handler');
-						else if (delta < 0)
-							log('#test4: down ('+delta+') from 2nd handler');
-						return false;
-					})
-					.unmousewheel(testRemoval);
-				
-				$('#test5')
-					.mousewheel(function(event, delta) {
-						if (delta > 0)
-							log('#test5: up ('+delta+')');
-						else if (delta < 0)
-							log('#test5: down ('+delta+')');
-						
-						event.stopPropagation();
-						event.preventDefault();
-					});
-				
-				$('#test6')
-					.mousewheel(function(event, delta) {
-						if (delta > 0)
-							log('#test6: up ('+delta+')');
-						else if (delta < 0)
-							log('#test6: down ('+delta+')');
-						
-						event.stopPropagation();
-						event.preventDefault();
-					});
-
-				$('#test7')
-					.mousewheel(function(event, delta) {
-						if (delta > 0)
-							log('#test7: up ('+delta+')');
-						else if (delta < 0)
-							log('#test7 down ('+delta+')');
-						
-						event.preventDefault();
-					});
-				
-				function log(msg) {
-					$('#logger').append(msg+'<br>').scrollTop(999999);
-				};
-			});
-		</script>
-	</head>
-	<body>
-		<h1 id="banner">jQuery mousewheel.js - Test</h1>
-		<h2 id="userAgent"></h2>
-		
-		<ul>
-			<li><strong>Test1</strong> 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.)</li>
-			<li><strong>Test2</strong> should prevent the default action.</li>
-			<li><strong>Test3</strong> should only log a mouseover and mouseout event. Testing unmousewheel().</li>
-			<li><strong>Test4</strong> has two handlers.</li>
-			<li><strong>Test5</strong> is like Test2 but has children. The children should not scroll until mousing over them.</li>
-			<li><strong>Test6</strong> is like Test5 but should not scroll children or parents.</li>
-			<li><strong>Test7</strong> is like Test6 but has no children. It will propagate the event and scroll test 6 as well.</li>
-		</ul>
-		
-		
-		<div id="test1"><p>Test1</p></div>
-		<div id="test2"><p>Test2</p></div>
-		<div id="test3"><p>Test3</p></div>
-		<div id="test4"><p>Test4</p></div>
-		<div id="test5">
-			<p>Test5</p>
-			<div id="test6">
-				<p>Test6</p>
-				<div id="test7"><p>Test7</p></div>
-			</div>
-		</div>
-		
-		<div id="logger"></div>
-		
-		<div id="forceScroll"></div>
-	</body>
+<!DOCTYPE html>
+<html lang="en">
+    <head>
+        <meta charset="iso-8859-1">
+        <title>Testing mousewheel plugin</title>
+
+        <style>
+            html {
+                font: 13px Arial, sans-serif;
+            }
+
+            #stage {
+                color: #fff;
+                position: relative;
+                zoom: 1;
+            }
+
+            #test1, #test2, #test3, #test4, #test5, #test6, #test7 {
+                float: left;
+            }
+
+            #test1 {
+                background-color: #000;
+                width: 120px;
+                height: 100px;
+            }
+
+            #test2 {
+                background-color: #333;
+                width: 120px;
+                height: 100px;
+            }
+
+            #test3 {
+                background-color: #666;
+                width: 120px;
+                height: 100px;
+            }
+
+            #test4 {
+                background-color: #000;
+                width: 120px;
+                height: 100px;
+            }
+
+            #test5 {
+                background-color: #333;
+                padding: 5px;
+                width: 400px;
+                height: 400px;
+            }
+
+            #test6 {
+                background-color: #666;
+                padding: 5px;
+                width: 250px;
+                height: 250px;
+            }
+
+            #test7 {
+                background-color: #000;
+                padding: 5px;
+                width: 100px;
+                height: 100px;
+            }
+
+            #forceScroll {
+                clear: both;
+                height: 1000px;
+            }
+
+            #logger {
+                position: absolute;
+                top: 100px;
+                left: 0;
+                width: 480px;
+                height: 310px;
+                overflow: auto;
+                z-index: 100;
+            }
+
+            #logger p {
+                color: #000;
+                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;
+            }
+        </style>
+
+        <script>
+            (function() {
+                var verMatch = /v=([\w\.]+)/.exec(location.search),
+                    version = verMatch && verMatch[1],
+                    src;
+                if (version)
+                    src = 'code.jquery.com/jquery-' + version;
+                else
+                    src = 'code.jquery.com/jquery-git';
+                document.write('<script src="http://' + src + '.js"><\/script>');
+            })();
+        </script>
+        <script>
+            $(function() {
+                $('#userAgent').html(navigator.userAgent);
+                $('#jqueryVersion').html($.fn.jquery);
+
+                var loghandle = function(event, delta) {
+                    var o = '', id = event.currentTarget.id || event.currentTarget.nodeName;
+
+                    o = '#' + id + ':';
+
+                    if (delta > 0)
+                        o += ' up (' + delta + ')';
+                    else if (delta < 0)
+                        o += ' down (' + delta + ')';
+
+                    if (event.deltaY > 0)
+                        o += ' north (' + event.deltaY + ')';
+                    else if (event.deltaY < 0)
+                        o += ' south (' + event.deltaY + ')';
+
+                    if (event.deltaX > 0)
+                        o += ' east (' + event.deltaX + ')';
+                    else if (event.deltaX < 0)
+                        o += ' west (' + event.deltaX + ')';
+
+                    o += ' deltaFactor (' + event.deltaFactor + ')';
+
+                    log( o );
+                };
+
+                $(document)
+                    .mousewheel(function(event, delta) {
+                        loghandle(event, delta);
+                    });
+
+                $('#test1')
+                    .mousewheel(function(event, delta) {
+                        loghandle(event, delta);
+                        log('pageX: ' + event.pageX + ' pageY: ' + event.pageY );
+                    });
+
+                $('#test2')
+                    .mousewheel(function(event, delta) {
+                        loghandle(event, delta);
+                        return false; // prevent default
+                    });
+
+                $('#test3')
+                    .hover(function() { log('#test3: mouseover'); }, function() { log('#test3: mouseout'); })
+                    .mousewheel(function() {
+                        log('#test3: I should not have been logged');
+                    })
+                    .unmousewheel();
+
+                var testRemoval = function() {
+                    log('#test4: I should not have been logged');
+                };
+
+                $('#test4')
+                    .mousewheel(function(event, delta) {
+                        loghandle(event, delta);
+                        return false;
+                    })
+                    .mousewheel(testRemoval)
+                    .mousewheel(function(event, delta) {
+                        loghandle(event, delta);
+                        return false;
+                    })
+                    .unmousewheel(testRemoval);
+
+                $('#test5')
+                    .mousewheel(function(event, delta) {
+                        loghandle(event, delta);
+                        event.stopPropagation();
+                        event.preventDefault();
+                    });
+
+                $('#test6')
+                    .mousewheel(function(event, delta) {
+                        loghandle(event, delta);
+                        event.stopPropagation();
+                        event.preventDefault();
+                    });
+
+                $('#test7')
+                    .mousewheel(function(event, delta) {
+                        loghandle(event, delta);
+                        event.preventDefault();
+                    });
+
+                function log(msg) {
+                    $('#logger').append('<p>' + msg + '<\/p>')[0].scrollTop = 999999;
+                }
+            });
+        </script>
+        <script src="../jquery.mousewheel.js"></script>
+    </head>
+    <body>
+        <h1 id="banner">jQuery mousewheel.js Test with jQuery <span id="jqueryVersion"></span></h1>
+        <h2 id="userAgent"></h2>
+
+        <ul>
+            <li><strong>Test1</strong> is just using the plain on <code>mousewheel()</code> with a function passed in and does not prevent default. (Also logs the value of <code>pageX</code> and <code>pageY</code> event properties.)</li>
+            <li><strong>Test2</strong> should prevent the default action.</li>
+            <li><strong>Test3</strong> should only log a <code>mouseover</code> and <code>mouseout</code> event. Testing <code>unmousewheel()</code>.</li>
+            <li><strong>Test4</strong> has two handlers.</li>
+            <li><strong>Test5</strong> is like Test2 but has children. The children should not scroll until mousing over them.</li>
+            <li><strong>Test6</strong> is like Test5 but should not scroll children or parents.</li>
+            <li><strong>Test7</strong> is like Test6 but has no children. It will propagate the event and scroll test 6 as well.</li>
+        </ul>
+
+
+        <div id="stage">
+            <div id="test1"><p>Test1</p></div>
+            <div id="test2"><p>Test2</p></div>
+            <div id="test3"><p>Test3</p></div>
+            <div id="test4"><p>Test4</p></div>
+            <div id="test5">
+                <p>Test5</p>
+                <div id="test6">
+                    <p>Test6</p>
+                    <div id="test7"><p>Test7</p></div>
+                </div>
+            </div>
+            <div id="logger"></div>
+        </div>
+
+        <div id="forceScroll"></div>
+    </body>
 </html>

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/jquery-goodies.git



More information about the Pkg-javascript-commits mailing list