|
1 YUI.add('event-mousewheel', function (Y, NAME) { |
|
2 |
|
3 /** |
|
4 * Adds mousewheel event support |
|
5 * @module event |
|
6 * @submodule event-mousewheel |
|
7 */ |
|
8 var DOM_MOUSE_SCROLL = 'DOMMouseScroll', |
|
9 fixArgs = function(args) { |
|
10 var a = Y.Array(args, 0, true), target; |
|
11 if (Y.UA.gecko) { |
|
12 a[0] = DOM_MOUSE_SCROLL; |
|
13 target = Y.config.win; |
|
14 } else { |
|
15 target = Y.config.doc; |
|
16 } |
|
17 |
|
18 if (a.length < 3) { |
|
19 a[2] = target; |
|
20 } else { |
|
21 a.splice(2, 0, target); |
|
22 } |
|
23 |
|
24 return a; |
|
25 }; |
|
26 |
|
27 /** |
|
28 * Mousewheel event. This listener is automatically attached to the |
|
29 * correct target, so one should not be supplied. Mouse wheel |
|
30 * direction and velocity is stored in the 'wheelDelta' field. |
|
31 * @event mousewheel |
|
32 * @param type {string} 'mousewheel' |
|
33 * @param fn {function} the callback to execute |
|
34 * @param context optional context object |
|
35 * @param args 0..n additional arguments to provide to the listener. |
|
36 * @return {EventHandle} the detach handle |
|
37 * @for YUI |
|
38 */ |
|
39 Y.Env.evt.plugins.mousewheel = { |
|
40 on: function() { |
|
41 return Y.Event._attach(fixArgs(arguments)); |
|
42 }, |
|
43 |
|
44 detach: function() { |
|
45 return Y.Event.detach.apply(Y.Event, fixArgs(arguments)); |
|
46 } |
|
47 }; |
|
48 |
|
49 |
|
50 }, '@VERSION@', {"requires": ["node-base"]}); |