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

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.

It also provides two helper methods calledmousewheel andunmousewheelthat act just like other event helper methods in jQuery.

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:

// using on$('#my_elem').on('mousewheel',function(event){console.log(event.deltaX,event.deltaY,event.deltaFactor);});// using the event helper$('#my_elem').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.Check out some of the data collected from usershere.

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.

Using withBrowserify

Support for browserify is baked in.

npm install jquery-mousewheelnpm install jquery-browserify

In your server-side node.js code:

varexpress=require('express');varapp=express.createServer();app.use(require('browserify')({require :['jquery-browserify','jquery-mousewheel']}));

In your browser-side #"auto" data-snippet-clipboard-copy-content="var $ = require('jquery-browserify');require('jquery-mousewheel')($);">

var$=require('jquery-browserify');require('jquery-mousewheel')($);

About

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

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors14


[8]ページ先頭

©2009-2025 Movatter.jp