mouse wheel util, custom sensitivity
depend on jQuery, I will remove the jQuery dependency in future.
target
jquery Dom objectopts
options objectopts.sensitivity
mouse wheel sensitivity, default is 4, the min value is 1(the highest sensitivity)opts.timeLimit
how long to trigger wheel event if user wheel mouse but not reach the sensitivity defined in opts, default is 500msopts.preventDefault
boolean, default is true, if the value is true, default page scroll will be preventopts.onWheel
when customer mouse wheel trigger, the method will be called, it accepts a direction param, value1
means scroll up, value2
means scroll dwon.
new MouseWheelUtil($('.wrapper'), {
sensitivity: 3,
timeLimit: 400,
onWheel: function (direction) {
if (direction === 1) {
console.log('scroll up');
} else {
console.log('scroll down');
}
}
});