Skip to content

xiaolin3303/MouseWheelUtil

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MouseWheelUtil

mouse wheel util, custom sensitivity

Dependency

depend on jQuery, I will remove the jQuery dependency in future.

parameters

  • target jquery Dom object
  • opts options object
  • opts.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 500ms
  • opts.preventDefault boolean, default is true, if the value is true, default page scroll will be prevent
  • opts.onWheel when customer mouse wheel trigger, the method will be called, it accepts a direction param, value 1 means scroll up, value 2 means scroll dwon.

demo

new MouseWheelUtil($('.wrapper'), {
  sensitivity: 3,
  timeLimit: 400,
  onWheel: function (direction) {
    if (direction === 1) {
      console.log('scroll up');
    } else {
      console.log('scroll down');
    }
  }
});

About

mouse wheel util, custom sensitivity

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published