From 3b134d6193c91a493c46363b86458a6e5eace518 Mon Sep 17 00:00:00 2001 From: DanielApt Date: Mon, 9 Nov 2015 23:11:33 +0000 Subject: [PATCH] Fix broken drag scrolling when left is out of viewport Related to #390 --- src/js/plugin/handler/drag-scrollbar.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/js/plugin/handler/drag-scrollbar.js b/src/js/plugin/handler/drag-scrollbar.js index 8fcbe79..5ebe06f 100644 --- a/src/js/plugin/handler/drag-scrollbar.js +++ b/src/js/plugin/handler/drag-scrollbar.js @@ -15,7 +15,11 @@ function bindMouseScrollXHandler(element, i) { function updateScrollLeft(deltaX) { var newLeft = currentLeft + (deltaX * i.railXRatio); - var maxLeft = i.scrollbarXRail.getBoundingClientRect().left + (i.railXRatio * (i.railXWidth - i.scrollbarXWidth)); + var scrollbarXLeft = i.scrollbarXRail.getBoundingClientRect().left; + if (scrollbarXLeft < 0) { + scrollbarXLeft = 0; + } + var maxLeft = scrollbarXLeft + (i.railXRatio * (i.railXWidth - i.scrollbarXWidth)); if (newLeft < 0) { i.scrollbarXLeft = 0;