From 9225275e6c8c8d965882123c40a71e2f1c28f4d2 Mon Sep 17 00:00:00 2001 From: Hyunje Alex Jun Date: Sun, 23 Mar 2014 05:51:27 +0900 Subject: [PATCH 1/2] Don't use 'wheelSpeed' value for keyboard scrolling. --- src/perfect-scrollbar.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/perfect-scrollbar.js b/src/perfect-scrollbar.js index 5a397d4..a2a217b 100644 --- a/src/perfect-scrollbar.js +++ b/src/perfect-scrollbar.js @@ -343,23 +343,23 @@ switch (e.which) { case 37: // left - deltaX = -3; + deltaX = -30; break; case 38: // up - deltaY = 3; + deltaY = 30; break; case 39: // right - deltaX = 3; + deltaX = 30; break; case 40: // down - deltaY = -3; + deltaY = -30; break; case 33: // page up - deltaY = 9; + deltaY = 90; break; case 32: // space bar case 34: // page down - deltaY = -9; + deltaY = -90; break; case 35: // end deltaY = -containerHeight; @@ -371,8 +371,8 @@ return; } - $this.scrollTop($this.scrollTop() - (deltaY * settings.wheelSpeed)); - $this.scrollLeft($this.scrollLeft() + (deltaX * settings.wheelSpeed)); + $this.scrollTop($this.scrollTop() - deltaY); + $this.scrollLeft($this.scrollLeft() + deltaX); shouldPrevent = shouldPreventDefault(deltaX, deltaY); if (shouldPrevent) { From fdcedcbbf58f1d7d1c74a52f3749c8484ef9557c Mon Sep 17 00:00:00 2001 From: Hyunje Alex Jun Date: Sun, 23 Mar 2014 06:03:52 +0900 Subject: [PATCH 2/2] Apply deltaFactor for the delta calculation of mousewheel. --- src/perfect-scrollbar.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/perfect-scrollbar.js b/src/perfect-scrollbar.js index a2a217b..dde72cc 100644 --- a/src/perfect-scrollbar.js +++ b/src/perfect-scrollbar.js @@ -277,10 +277,16 @@ // bind handlers 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; $this.bind('mousewheel' + eventClassName, function (e, deprecatedDelta, deprecatedDeltaX, deprecatedDeltaY) { - var deltaX = e.deltaX || deprecatedDeltaX, - deltaY = e.deltaY || deprecatedDeltaY; + var deltaX = e.deltaX * e.deltaFactor || deprecatedDeltaX, + deltaY = e.deltaY * e.deltaFactor || deprecatedDeltaY; if (!settings.useBothWheelAxes) { // deltaX will only be used for horizontal scrolling and deltaY will