Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A jQuery plugin that adds cross-browser mouse wheel support.

License

NotificationsYou must be signed in to change notification settings

jquery/jquery-mousewheel

Repository files navigation

AjQuery plugin that adds cross-browser mouse wheel support with delta normalization.

In order to use the plugin, simply bind themousewheel event to an element.

The event object is updated with the normalizeddeltaX anddeltaY properties.In addition, there is a new property on the event object calleddeltaFactor. MultiplythedeltaFactor bydeltaX ordeltaY to get the scroll distance that the browserhas reported.

Here is an example of using both the bind and helper method syntax:

$("#my_elem").on("mousewheel",function(event){console.log(event.deltaX,event.deltaY,event.deltaFactor);});

The old behavior of adding three arguments (delta,deltaX, anddeltaY) to theevent handler is now deprecated and will be removed in later releases.

The Deltas...

The combination of browsers, operating systems, and devices offer a huge range of possible delta values. In fact if the useruses a trackpad and then a physical mouse wheel the delta values can differ wildly. This plugin normalizes thosevalues so you get a whole number starting at +-1 and going up in increments of +-1 according to the force oracceleration that is used. This number has the potential to be in the thousands depending on the device.

Getting the scroll distance

In some use-cases we prefer to have the normalized delta but in others we want to know how far the browser shouldscroll based on the users input. This can be done by multiplying thedeltaFactor by thedeltaX ordeltaYevent property to find the scroll distance the browser reported.

ThedeltaFactor property was added to the event object in 3.1.5 so that the actual reported delta value can beextracted. This is a non-standard property.

Building the code in the repo & running tests

git clone git@github.com:jquery/jquery-mousewheel.gitcd jquery-mousewheel/npm installnpmtest

The unit tests arevery basic sanity checks; improvements welcome.To fully test the plugin, loadtest/index.html in each supportedbrowser and follow the instructions at the top of the file after the unit tests finish.

About

A jQuery plugin that adds cross-browser mouse wheel support.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp