Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
jquery-mousewheel
Advanced tools
The jquery-mousewheel package is a jQuery plugin that adds cross-browser mouse wheel support. It allows you to capture mouse wheel events and respond to them in a consistent manner across different browsers.
Basic Mouse Wheel Event Handling
This feature allows you to capture mouse wheel events on a specific element and log the delta value, which indicates the amount of scroll.
$(document).ready(function() {
$("#element").on("mousewheel", function(event) {
console.log("Mouse wheel event detected!");
console.log("Delta: " + event.deltaY);
});
});
Prevent Default Scrolling
This feature allows you to prevent the default scrolling behavior when a mouse wheel event is detected, which can be useful for custom scroll implementations.
$(document).ready(function() {
$("#element").on("mousewheel", function(event) {
event.preventDefault();
console.log("Default scrolling prevented.");
});
});
Custom Scroll Speed
This feature allows you to customize the scroll speed by multiplying the delta value with a custom speed factor and then adjusting the scroll position of the element.
$(document).ready(function() {
$("#element").on("mousewheel", function(event) {
var scrollSpeed = 10;
var scrollAmount = event.deltaY * scrollSpeed;
$(this).scrollTop($(this).scrollTop() - scrollAmount);
event.preventDefault();
});
});
The 'wheel' package is a lightweight JavaScript library for handling mouse wheel events. It provides a simple API for capturing and responding to mouse wheel events, similar to jquery-mousewheel, but without the dependency on jQuery.
The 'dom-helpers' package includes a variety of DOM utility functions, including mouse wheel event handling. It offers a more modular approach compared to jquery-mousewheel, allowing you to use only the specific utilities you need.
A jQuery plugin that adds cross-browser mouse wheel support with delta normalization.
In order to use the plugin, simply bind the mousewheel
event to an element.
It also provides two helper methods called mousewheel
and unmousewheel
that act just like other event helper methods in jQuery.
The event object is updated with the normalized deltaX
and deltaY
properties.
In addition there is a new property on the event object called deltaFactor
. Multiply
the deltaFactor
by deltaX
or deltaY
to get the scroll distance that the browser
has 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
, and deltaY
) to the
event handler is now deprecated and will be removed in later releases.
The combination of Browsers, Operating Systems, and Devices offer a huge range of possible delta values. In fact if the user uses a trackpad and then a physical mouse wheel the delta values can differ wildly. This plugin normalizes those values so you get a whole number starting at +-1 and going up in increments of +-1 according to the force or acceleration 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 users here.
In some use-cases we prefer to have the normalized delta but in others we want to know how far the browser should
scroll based on the users input. This can be done by multiplying the deltaFactor
by the deltaX
or deltaY
event property to find the scroll distance the browser reported.
The deltaFactor
property was added to the event object in 3.1.5 so that the actual reported delta value can be
extracted. This is a non-standard property.
Support for browserify is baked in.
npm install jquery-mousewheel
npm install jquery-browserify
In your server-side node.js code:
var express = require('express');
var app = express.createServer();
app.use(require('browserify')({
require : [ 'jquery-browserify', 'jquery-mousewheel' ]
}));
In your browser-side javascript:
var $ = require('jquery-browserify');
require('jquery-mousewheel')($);
FAQs
A jQuery plugin that adds cross-browser mouse wheel support.
The npm package jquery-mousewheel receives a total of 165,044 weekly downloads. As such, jquery-mousewheel popularity was classified as popular.
We found that jquery-mousewheel demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.