Skip to content

Commit 2204149

Browse files
committed
Merge remote-tracking branch 'XhmikosR/master'
2 parents 2b70922 + 383a1a3 commit 2204149

File tree

8 files changed

+87
-48
lines changed

8 files changed

+87
-48
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/npm-debug.log

.jshintrc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"bitwise": true,
3+
"browser" : true,
4+
"camelcase": true,
5+
"curly": true,
6+
"eqeqeq": true,
7+
"indent": 4,
8+
"jquery" : true,
9+
"latedef": true,
10+
"maxerr": 50,
11+
"noarg": true,
12+
"node" : true,
13+
"noempty": true,
14+
"plusplus": false,
15+
"regexp": true,
16+
"strict": false,
17+
"trailing": true,
18+
"unused": true
19+
}

ChangeLog.markdown

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,80 @@
11
# Mouse Wheel ChangeLog
22

3-
# 3.1.1
3+
## 3.1.1
44

55
* Fix rounding issue with deltas less than zero
66

77

8-
# 3.1.0
8+
## 3.1.0
99

1010
* Fix Firefox 17+ issues by using new wheel event
1111
* Normalize delta values
1212
* Adds horizontal support for IE 9+ by using new wheel event
1313
* Support AMD loaders
1414

1515

16-
# 3.0.6
16+
## 3.0.6
1717

1818
* Fix issue with delta being 0 in Firefox
1919

2020

21-
# 3.0.5
21+
## 3.0.5
2222

2323
* jQuery 1.7 compatibility
2424

2525

26-
# 3.0.4
26+
## 3.0.4
2727

2828
* Fix IE issue
2929

3030

31-
# 3.0.3
31+
## 3.0.3
3232

3333
* Added deltaX and deltaY for horizontal scrolling support (Thanks to Seamus Leahy)
3434

3535

36-
# 3.0.2
36+
## 3.0.2
3737

3838
* Fixed delta being opposite value in latest Opera
39-
* No longer fix pageX, pageY for older mozilla browsers
39+
* No longer fix `pageX`, `pageY` for older Mozilla browsers
4040
* Removed browser detection
4141
* Cleaned up the code
4242

4343

44-
# 3.0.1
44+
## 3.0.1
4545

4646
* Bad release... creating a new release due to plugins.jquery.com issue :(
4747

4848

49-
# 3.0
49+
## 3.0
5050

5151
* Uses new special events API in jQuery 1.2.2+
52-
* You can now treat "mousewheel" as a normal event and use .bind, .unbind and .trigger
52+
* You can now treat `mousewheel` as a normal event and use `.bind`, `.unbind` and `.trigger`
5353
* Using jQuery.data API for expandos
5454

5555

56-
# 2.2
56+
## 2.2
5757

58-
* Fixed pageX, pageY, clientX and clientY event properties for Mozilla based browsers
58+
* Fixed `pageX`, `pageY`, `clientX` and `clientY` event properties for Mozilla based browsers
5959

6060

61-
# 2.1.1
61+
## 2.1.1
6262

6363
* Updated to work with jQuery 1.1.3
6464
* Used one instead of bind to do unload event for clean up.
6565

6666

67-
# 2.1
67+
## 2.1
6868

6969
* Fixed an issue with the unload handler
7070

7171

72-
# 2.0
72+
## 2.0
7373

7474
* Major reduction in code size and complexity (internals have change a whole lot)
7575

7676

77-
# 1.0
77+
## 1.0
7878

7979
* Fixed Opera issue
8080
* Fixed an issue with children elements that also have a mousewheel handler

LICENSE.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
Copyright 2011, Brandon Aaron (http://brandonaaron.net/)
2-
1+
Copyright (c) 2013, Brandon Aaron (http://brandonaaron.net/)
2+
33
Permission is hereby granted, free of charge, to any person obtaining
44
a copy of this software and associated documentation files (the
55
"Software"), to deal in the Software without restriction, including
66
without limitation the rights to use, copy, modify, merge, publish,
77
distribute, sublicense, and/or sell copies of the Software, and to
88
permit persons to whom the Software is furnished to do so, subject to
99
the following conditions:
10-
10+
1111
The above copyright notice and this permission notice shall be
1212
included in all copies or substantial portions of the Software.
13-
13+
1414
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1515
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1616
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND

README.markdown

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,30 @@
22

33
A jQuery plugin that adds cross-browser mouse wheel support.
44

5-
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.
5+
In order to use the plugin, simply bind the `mousewheel` event to an element.
6+
It also provides two helper methods called `mousewheel` and `unmousewheel`
7+
that act just like other event helper methods in jQuery. The event callback
8+
receives three extra arguments which are the normalized "deltas" of the mouse wheel.
69

710
Here is an example of using both the bind and helper method syntax.
811

9-
// using bind
10-
$('#my_elem').bind('mousewheel', function(event, delta, deltaX, deltaY) {
11-
console.log(delta, deltaX, deltaY);
12-
});
12+
```js
13+
// using bind
14+
$('#my_elem').bind('mousewheel', function(event, delta, deltaX, deltaY) {
15+
console.log(delta, deltaX, deltaY);
16+
});
1317

14-
// using the event helper
15-
$('#my_elem').mousewheel(function(event, delta, deltaX, deltaY) {
16-
console.log(delta, deltaX, deltaY);
17-
});
18+
// using the event helper
19+
$('#my_elem').mousewheel(function(event, delta, deltaX, deltaY) {
20+
console.log(delta, deltaX, deltaY);
21+
});
22+
```
1823

1924
## See it in action
2025
[See the tests on Github](http://brandonaaron.github.com/jquery-mousewheel/test) or navigate to `test/index.html` in your browser.
2126

2227
## License
2328

24-
This plugin is licensed under the MIT License (LICENSE.txt).
29+
This plugin is licensed under the [MIT License](LICENSE.txt).
2530

2631
Copyright (c) 2013 [Brandon Aaron](http://brandonaaron.net)

jquery.mousewheel.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212

1313
(function (factory) {
14-
if (typeof define === 'function' && define.amd) {
14+
if ( typeof define === 'function' && define.amd ) {
1515
// AMD. Register as an anonymous module.
1616
define(['jquery'], factory);
1717
} else {
@@ -24,16 +24,16 @@
2424
var toBind = 'onwheel' in document || document.documentMode >= 9 ? ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'];
2525
var lowestDelta, lowestDeltaXY;
2626

27-
if ($.event.fixHooks) {
28-
for ( var i=toFix.length; i; ) {
27+
if ( $.event.fixHooks ) {
28+
for ( var i = toFix.length; i; ) {
2929
$.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks;
3030
}
3131
}
3232

3333
$.event.special.mousewheel = {
3434
setup: function() {
3535
if ( this.addEventListener ) {
36-
for ( var i=toBind.length; i; ) {
36+
for ( var i = toBind.length; i; ) {
3737
this.addEventListener( toBind[--i], handler, false );
3838
}
3939
} else {
@@ -43,7 +43,7 @@
4343

4444
teardown: function() {
4545
if ( this.removeEventListener ) {
46-
for ( var i=toBind.length; i; ) {
46+
for ( var i = toBind.length; i; ) {
4747
this.removeEventListener( toBind[--i], handler, false );
4848
}
4949
} else {
@@ -64,13 +64,20 @@
6464

6565

6666
function handler(event) {
67-
var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, deltaX = 0, deltaY = 0, absDelta = 0, absDeltaXY = 0, fn;
67+
var orgEvent = event || window.event,
68+
args = [].slice.call(arguments, 1),
69+
delta = 0,
70+
deltaX = 0,
71+
deltaY = 0,
72+
absDelta = 0,
73+
absDeltaXY = 0,
74+
fn;
6875
event = $.event.fix(orgEvent);
6976
event.type = "mousewheel";
7077

7178
// Old school scrollwheel delta
72-
if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta; }
73-
if ( orgEvent.detail ) { delta = orgEvent.detail * -1; }
79+
if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta; }
80+
if ( orgEvent.detail ) { delta = orgEvent.detail * -1; }
7481

7582
// New school wheel delta (wheel event)
7683
if ( orgEvent.deltaY ) {
@@ -83,20 +90,20 @@
8390
}
8491

8592
// Webkit
86-
if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY; }
93+
if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY; }
8794
if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = orgEvent.wheelDeltaX * -1; }
8895

8996
// Look for lowest delta to normalize the delta values
9097
absDelta = Math.abs(delta);
9198
if ( !lowestDelta || absDelta < lowestDelta ) { lowestDelta = absDelta; }
92-
absDeltaXY = Math.max( Math.abs(deltaY), Math.abs(deltaX) );
99+
absDeltaXY = Math.max(Math.abs(deltaY), Math.abs(deltaX));
93100
if ( !lowestDeltaXY || absDeltaXY < lowestDeltaXY ) { lowestDeltaXY = absDeltaXY; }
94101

95102
// Get a whole value for the deltas
96103
fn = delta > 0 ? 'floor' : 'ceil';
97-
delta = Math[fn](delta/lowestDelta);
98-
deltaX = Math[fn](deltaX/lowestDeltaXY);
99-
deltaY = Math[fn](deltaY/lowestDeltaXY);
104+
delta = Math[fn](delta / lowestDelta);
105+
deltaX = Math[fn](deltaX / lowestDeltaXY);
106+
deltaY = Math[fn](deltaY / lowestDeltaXY);
100107

101108
// Add event and delta to the front of the arguments
102109
args.unshift(event, delta, deltaX, deltaY);

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"scripts": {
3+
"check": "jshint .",
4+
"lint": "jshint ."
5+
}
6+
}

test/index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
<!doctype html>
2-
<html>
1+
<!DOCTYPE html>
2+
<html lang="en">
33
<head>
4+
<meta charset="iso-8859-1">
45
<title>Testing mousewheel plugin</title>
56

67
<script>
@@ -15,7 +16,7 @@
1516
document.write( '<script src="http://' + src + '.js"><\/script>' );
1617
})();
1718
</script>
18-
<script type="text/javascript" src="../jquery.mousewheel.js"></script>
19+
<script src="../jquery.mousewheel.js"></script>
1920

2021
<style>
2122
#test1 {
@@ -107,7 +108,7 @@
107108
border-bottom-color: #000;
108109
}
109110
</style>
110-
<script type="text/javascript">
111+
<script>
111112
$(function() {
112113
$('#userAgent').html(navigator.userAgent);
113114

0 commit comments

Comments
 (0)