Merge remote-tracking branch 'XhmikosR/master'

This commit is contained in:
Brandon Aaron
2013-03-11 19:32:57 -05:00
8 changed files with 87 additions and 48 deletions
+1
View File
@@ -0,0 +1 @@
/npm-debug.log
+19
View File
@@ -0,0 +1,19 @@
{
"bitwise": true,
"browser" : true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"indent": 4,
"jquery" : true,
"latedef": true,
"maxerr": 50,
"noarg": true,
"node" : true,
"noempty": true,
"plusplus": false,
"regexp": true,
"strict": false,
"trailing": true,
"unused": true
}
+17 -17
View File
@@ -1,11 +1,11 @@
# Mouse Wheel ChangeLog
# 3.1.1
## 3.1.1
* Fix rounding issue with deltas less than zero
# 3.1.0
## 3.1.0
* Fix Firefox 17+ issues by using new wheel event
* Normalize delta values
@@ -13,68 +13,68 @@
* Support AMD loaders
# 3.0.6
## 3.0.6
* Fix issue with delta being 0 in Firefox
# 3.0.5
## 3.0.5
* jQuery 1.7 compatibility
# 3.0.4
## 3.0.4
* Fix IE issue
# 3.0.3
## 3.0.3
* Added deltaX and deltaY for horizontal scrolling support (Thanks to Seamus Leahy)
# 3.0.2
## 3.0.2
* Fixed delta being opposite value in latest Opera
* No longer fix pageX, pageY for older mozilla browsers
* No longer fix `pageX`, `pageY` for older Mozilla browsers
* Removed browser detection
* Cleaned up the code
# 3.0.1
## 3.0.1
* Bad release... creating a new release due to plugins.jquery.com issue :(
# 3.0
## 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
* You can now treat `mousewheel` as a normal event and use `.bind`, `.unbind` and `.trigger`
* Using jQuery.data API for expandos
# 2.2
## 2.2
* Fixed pageX, pageY, clientX and clientY event properties for Mozilla based browsers
* Fixed `pageX`, `pageY`, `clientX` and `clientY` event properties for Mozilla based browsers
# 2.1.1
## 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
## 2.1
* Fixed an issue with the unload handler
# 2.0
## 2.0
* Major reduction in code size and complexity (internals have change a whole lot)
# 1.0
## 1.0
* Fixed Opera issue
* Fixed an issue with children elements that also have a mousewheel handler
+4 -4
View File
@@ -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
+15 -10
View File
@@ -2,25 +2,30 @@
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.
// using bind
$('#my_elem').bind('mousewheel', function(event, delta, deltaX, deltaY) {
console.log(delta, deltaX, deltaY);
});
```js
// using bind
$('#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);
});
// using the event helper
$('#my_elem').mousewheel(function(event, delta, deltaX, deltaY) {
console.log(delta, deltaX, deltaY);
});
```
## See it in action
[See the tests on Github](http://brandonaaron.github.com/jquery-mousewheel/test) or navigate to `test/index.html` in your browser.
## License
This plugin is licensed under the MIT License (LICENSE.txt).
This plugin is licensed under the [MIT License](LICENSE.txt).
Copyright (c) 2013 [Brandon Aaron](http://brandonaaron.net)
+20 -13
View File
@@ -11,7 +11,7 @@
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
if ( typeof define === 'function' && define.amd ) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else {
@@ -24,8 +24,8 @@
var toBind = 'onwheel' in document || document.documentMode >= 9 ? ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'];
var lowestDelta, lowestDeltaXY;
if ($.event.fixHooks) {
for ( var i=toFix.length; i; ) {
if ( $.event.fixHooks ) {
for ( var i = toFix.length; i; ) {
$.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks;
}
}
@@ -33,7 +33,7 @@
$.event.special.mousewheel = {
setup: function() {
if ( this.addEventListener ) {
for ( var i=toBind.length; i; ) {
for ( var i = toBind.length; i; ) {
this.addEventListener( toBind[--i], handler, false );
}
} else {
@@ -43,7 +43,7 @@
teardown: function() {
if ( this.removeEventListener ) {
for ( var i=toBind.length; i; ) {
for ( var i = toBind.length; i; ) {
this.removeEventListener( toBind[--i], handler, false );
}
} else {
@@ -64,13 +64,20 @@
function handler(event) {
var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, deltaX = 0, deltaY = 0, absDelta = 0, absDeltaXY = 0, fn;
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";
// Old school scrollwheel delta
if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta; }
if ( orgEvent.detail ) { delta = orgEvent.detail * -1; }
if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta; }
if ( orgEvent.detail ) { delta = orgEvent.detail * -1; }
// New school wheel delta (wheel event)
if ( orgEvent.deltaY ) {
@@ -83,20 +90,20 @@
}
// Webkit
if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY; }
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) );
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);
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, delta, deltaX, deltaY);
+6
View File
@@ -0,0 +1,6 @@
{
"scripts": {
"check": "jshint .",
"lint": "jshint ."
}
}
+5 -4
View File
@@ -1,6 +1,7 @@
<!doctype html>
<html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="iso-8859-1">
<title>Testing mousewheel plugin</title>
<script>
@@ -15,7 +16,7 @@
document.write( '<script src="http://' + src + '.js"><\/script>' );
})();
</script>
<script type="text/javascript" src="../jquery.mousewheel.js"></script>
<script src="../jquery.mousewheel.js"></script>
<style>
#test1 {
@@ -107,7 +108,7 @@
border-bottom-color: #000;
}
</style>
<script type="text/javascript">
<script>
$(function() {
$('#userAgent').html(navigator.userAgent);