Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

event-mousewheel.js 1.4KB

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