mousewheel.js 800 B

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. exports.__esModule = true;
  3. var _normalizeWheel = require('normalize-wheel');
  4. var _normalizeWheel2 = _interopRequireDefault(_normalizeWheel);
  5. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6. var isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
  7. var mousewheel = function mousewheel(element, callback) {
  8. if (element && element.addEventListener) {
  9. element.addEventListener(isFirefox ? 'DOMMouseScroll' : 'mousewheel', function (event) {
  10. var normalized = (0, _normalizeWheel2.default)(event);
  11. callback && callback.apply(this, [event, normalized]);
  12. });
  13. }
  14. };
  15. exports.default = {
  16. bind: function bind(el, binding) {
  17. mousewheel(el, binding.value);
  18. }
  19. };