From e9024292cdfce5906f37f6da71a7521d6ac86c60 Mon Sep 17 00:00:00 2001 From: DanielApt Date: Sun, 8 Nov 2015 22:03:35 +0000 Subject: [PATCH] Fix broken drag scrolling when top is out of viewport Addresses issue no. 390 #390 --- src/js/plugin/handler/drag-scrollbar.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/js/plugin/handler/drag-scrollbar.js b/src/js/plugin/handler/drag-scrollbar.js index 060b30a..8fcbe79 100644 --- a/src/js/plugin/handler/drag-scrollbar.js +++ b/src/js/plugin/handler/drag-scrollbar.js @@ -60,7 +60,12 @@ function bindMouseScrollYHandler(element, i) { function updateScrollTop(deltaY) { var newTop = currentTop + (deltaY * i.railYRatio); - var maxTop = i.scrollbarYRail.getBoundingClientRect().top + (i.railYRatio * (i.railYHeight - i.scrollbarYHeight)); + var scrollbarYTop = i.scrollbarYRail.getBoundingClientRect().top; + + if(scrollbarYTop < 0) { + scrollbarYTop = 0; + } + var maxTop = scrollbarYTop + (i.railYRatio * (i.railYHeight - i.scrollbarYHeight)); if (newTop < 0) { i.scrollbarYTop = 0;