UNPKG

553 BJavaScriptView Raw
1import normalizeWheel from 'normalize-wheel';
2
3const isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
4
5const mousewheel = function(element, callback) {
6 if (element && element.addEventListener) {
7 element.addEventListener(isFirefox ? 'DOMMouseScroll' : 'mousewheel', function(event) {
8 const normalized = normalizeWheel(event);
9 callback && callback.apply(this, [event, normalized]);
10 });
11 }
12};
13
14export default {
15 bind(el, binding) {
16 mousewheel(el, binding.value);
17 }
18};