From 97c7d402611a89bcea5821836571634551bc99ab Mon Sep 17 00:00:00 2001 From: Jacquelin Date: Tue, 19 May 2015 11:57:35 +0200 Subject: [PATCH] Fix scroll on top : add a check if the scroll count and vertical scroll length are negative (Mean no scroll) --- src/js/core/directives/ui-grid-render-container.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/js/core/directives/ui-grid-render-container.js b/src/js/core/directives/ui-grid-render-container.js index b8ee5ed299..c807274ef0 100644 --- a/src/js/core/directives/ui-grid-render-container.js +++ b/src/js/core/directives/ui-grid-render-container.js @@ -74,10 +74,13 @@ var scrollYAmount = event.deltaY * -1 * event.deltaFactor; scrollTop = containerCtrl.viewport[0].scrollTop; + + var scrollCount = scrollTop + scrollYAmount; // Get the scroll percentage - var scrollYPercentage = (scrollTop + scrollYAmount) / rowContainer.getVerticalScrollLength(); + var scrollYPercentage = scrollCount / rowContainer.getVerticalScrollLength(); // Keep scrollPercentage within the range 0-1. + if (scrollCount < 0 && rowContainer.getVerticalScrollLength() < 0) { scrollYPercentage = 0; } if (scrollYPercentage < 0) { scrollYPercentage = 0; } else if (scrollYPercentage > 1) { scrollYPercentage = 1; }