mouse-wheel
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "mouse-wheel", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Consistent cross browser mouse wheel movement", | ||
@@ -5,0 +5,0 @@ "main": "wheel.js", |
26
wheel.js
@@ -7,6 +7,8 @@ 'use strict' | ||
var SCROLL_CUTOFF = 100 | ||
module.exports = mouseWheelListen | ||
function filter(cur, prev, dt) { | ||
return sgn(cur) * Math.sqrt(Math.abs(cur)) | ||
} | ||
function mouseWheelListen(element, callback, noScroll) { | ||
@@ -46,15 +48,9 @@ if(typeof element === 'function') { | ||
dz *= scale | ||
if(dt < SCROLL_CUTOFF) { | ||
var cx = dx, cy = dy, cz = dz | ||
dx = sgn(dx) * Math.max(0, Math.abs(dx) - Math.abs(lastX)) | ||
dy = sgn(dy) * Math.max(0, Math.abs(dy) - Math.abs(lastY)) | ||
dz = sgn(dz) * Math.max(0, Math.abs(dz) - Math.abs(lastZ)) | ||
lastX = cx | ||
lastY = cy | ||
lastZ = cz | ||
} else { | ||
lastX = dx | ||
lastY = dy | ||
lastZ = dz | ||
} | ||
var cx = dx, cy = dy, cz = dz | ||
dx = filter(dx, lastX, dt) | ||
dy = filter(dy, lastY, dt) | ||
dz = filter(dz, lastZ, dt) | ||
lastX = cx | ||
lastY = cy | ||
lastZ = cz | ||
if(dx || dy || dz) { | ||
@@ -61,0 +57,0 @@ return callback(dx, dy, dz) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4753
75