Skip to content

Commit f928bbe

Browse files
committed
Update the readme
1 parent c4ee6f5 commit f928bbe

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

README.markdown renamed to README.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
11
# jQuery Mouse Wheel Plugin
22

3-
A [jQuery](http://jquery.com/) plugin that adds cross-browser mouse wheel support.
3+
A [jQuery](http://jquery.com/) plugin that adds cross-browser mouse wheel support with delta normalization.
44

55
In order to use the plugin, simply bind the `mousewheel` event to an element.
6+
67
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.
8+
that act just like other event helper methods in jQuery.
9+
10+
The event object is updated with the normalized `deltaX` and `deltaY` properties.
11+
In addition there is a new property on the event object called `deltaFactor`. Multiply
12+
the `deltaFactor` by `deltaX` or `deltaY` to get the scroll distance that the browser
13+
has reported.
914

1015
Here is an example of using both the bind and helper method syntax:
1116

1217
```js
13-
// using bind
14-
$('#my_elem').on('mousewheel', function(event, delta, deltaX, deltaY) {
15-
console.log(delta, deltaX, deltaY);
18+
// using on
19+
$('#my_elem').on('mousewheel', function(event) {
20+
console.log(event.deltaX, event.deltaY, event.deltaFactor);
1621
});
1722

1823
// using the event helper
19-
$('#my_elem').mousewheel(function(event, delta, deltaX, deltaY) {
20-
console.log(delta, deltaX, deltaY);
24+
$('#my_elem').mousewheel(function(event) {
25+
console.log(event.deltaX, event.deltaY, event.deltaFactor);
2126
});
2227
```
2328

29+
The old behavior of adding three arguments (`delta`, `deltaX`, and `deltaY`) to the
30+
event handler is now deprecated and will be removed in later releases.
31+
32+
2433
## See it in action
2534
[See the tests on Github](http://brandonaaron.github.io/jquery-mousewheel/test).
2635

0 commit comments

Comments
 (0)