Merge pull request #119 from noraesae/mousewheel-speed
Change mousewheel delta calculation logic.
This commit is contained in:
commit
9a589639b0
@ -277,10 +277,16 @@
|
|||||||
|
|
||||||
// bind handlers
|
// bind handlers
|
||||||
var bindMouseWheelHandler = function () {
|
var bindMouseWheelHandler = function () {
|
||||||
|
// FIXME: Backward compatibility.
|
||||||
|
// After e.deltaFactor applied, wheelSpeed should have smaller value.
|
||||||
|
// Currently, there's no way to change the settings after the scrollbar initialized.
|
||||||
|
// But if the way is implemented in the future, wheelSpeed should be reset.
|
||||||
|
settings.wheelSpeed /= 10;
|
||||||
|
|
||||||
var shouldPrevent = false;
|
var shouldPrevent = false;
|
||||||
$this.bind('mousewheel' + eventClassName, function (e, deprecatedDelta, deprecatedDeltaX, deprecatedDeltaY) {
|
$this.bind('mousewheel' + eventClassName, function (e, deprecatedDelta, deprecatedDeltaX, deprecatedDeltaY) {
|
||||||
var deltaX = e.deltaX || deprecatedDeltaX,
|
var deltaX = e.deltaX * e.deltaFactor || deprecatedDeltaX,
|
||||||
deltaY = e.deltaY || deprecatedDeltaY;
|
deltaY = e.deltaY * e.deltaFactor || deprecatedDeltaY;
|
||||||
|
|
||||||
if (!settings.useBothWheelAxes) {
|
if (!settings.useBothWheelAxes) {
|
||||||
// deltaX will only be used for horizontal scrolling and deltaY will
|
// deltaX will only be used for horizontal scrolling and deltaY will
|
||||||
@ -343,23 +349,23 @@
|
|||||||
|
|
||||||
switch (e.which) {
|
switch (e.which) {
|
||||||
case 37: // left
|
case 37: // left
|
||||||
deltaX = -3;
|
deltaX = -30;
|
||||||
break;
|
break;
|
||||||
case 38: // up
|
case 38: // up
|
||||||
deltaY = 3;
|
deltaY = 30;
|
||||||
break;
|
break;
|
||||||
case 39: // right
|
case 39: // right
|
||||||
deltaX = 3;
|
deltaX = 30;
|
||||||
break;
|
break;
|
||||||
case 40: // down
|
case 40: // down
|
||||||
deltaY = -3;
|
deltaY = -30;
|
||||||
break;
|
break;
|
||||||
case 33: // page up
|
case 33: // page up
|
||||||
deltaY = 9;
|
deltaY = 90;
|
||||||
break;
|
break;
|
||||||
case 32: // space bar
|
case 32: // space bar
|
||||||
case 34: // page down
|
case 34: // page down
|
||||||
deltaY = -9;
|
deltaY = -90;
|
||||||
break;
|
break;
|
||||||
case 35: // end
|
case 35: // end
|
||||||
deltaY = -containerHeight;
|
deltaY = -containerHeight;
|
||||||
@ -371,8 +377,8 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this.scrollTop($this.scrollTop() - (deltaY * settings.wheelSpeed));
|
$this.scrollTop($this.scrollTop() - deltaY);
|
||||||
$this.scrollLeft($this.scrollLeft() + (deltaX * settings.wheelSpeed));
|
$this.scrollLeft($this.scrollLeft() + deltaX);
|
||||||
|
|
||||||
shouldPrevent = shouldPreventDefault(deltaX, deltaY);
|
shouldPrevent = shouldPreventDefault(deltaX, deltaY);
|
||||||
if (shouldPrevent) {
|
if (shouldPrevent) {
|
||||||
|
Loading…
Reference in New Issue
Block a user