From e582174a826bb232ddbb4fda8001b64c3273df0d Mon Sep 17 00:00:00 2001 From: Shane Walters Date: Thu, 18 Jun 2015 21:27:36 -0500 Subject: [PATCH] fix(core): fix #3666 #3531 #3340 thanks to @500tech-user and @Jacquelin for PR's that led to this fix --- src/js/core/directives/ui-grid-render-container.js | 6 ++++-- src/js/core/factories/ScrollEvent.js | 11 +++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/js/core/directives/ui-grid-render-container.js b/src/js/core/directives/ui-grid-render-container.js index b8ee5ed299..94db9db0c9 100644 --- a/src/js/core/directives/ui-grid-render-container.js +++ b/src/js/core/directives/ui-grid-render-container.js @@ -75,7 +75,8 @@ scrollTop = containerCtrl.viewport[0].scrollTop; // Get the scroll percentage - var scrollYPercentage = (scrollTop + scrollYAmount) / rowContainer.getVerticalScrollLength(); + scrollEvent.verticalScrollLength = rowContainer.getVerticalScrollLength(); + var scrollYPercentage = (scrollTop + scrollYAmount) / scrollEvent.verticalScrollLength; // Keep scrollPercentage within the range 0-1. if (scrollYPercentage < 0) { scrollYPercentage = 0; } @@ -88,7 +89,8 @@ // Get the scroll percentage scrollLeft = gridUtil.normalizeScrollLeft(containerCtrl.viewport, grid); - var scrollXPercentage = (scrollLeft + scrollXAmount) / (colContainer.getCanvasWidth() - colContainer.getViewportWidth()); + scrollEvent.horizontalScrollLength = (colContainer.getCanvasWidth() - colContainer.getViewportWidth()); + var scrollXPercentage = (scrollLeft + scrollXAmount) / scrollEvent.horizontalScrollLength; // Keep scrollPercentage within the range 0-1. if (scrollXPercentage < 0) { scrollXPercentage = 0; } diff --git a/src/js/core/factories/ScrollEvent.js b/src/js/core/factories/ScrollEvent.js index 68f692aa73..ad055c4996 100644 --- a/src/js/core/factories/ScrollEvent.js +++ b/src/js/core/factories/ScrollEvent.js @@ -53,6 +53,9 @@ self.x = null; self.y = null; + self.verticalScrollLength = -9999999; + self.horizontalScrollLength = -999999; + /** * @ngdoc function @@ -132,19 +135,19 @@ }; ScrollEvent.prototype.atTop = function(scrollTop) { - return (this.y && this.y.percentage === 0 && scrollTop === 0); + return (this.y && (this.y.percentage === 0 || this.verticalScrollLength < 0) && scrollTop === 0); }; ScrollEvent.prototype.atBottom = function(scrollTop) { - return (this.y && this.y.percentage === 1 && scrollTop > 0); + return (this.y && (this.y.percentage === 1 || this.verticalScrollLength === 0) && scrollTop > 0); }; ScrollEvent.prototype.atLeft = function(scrollLeft) { - return (this.x && this.x.percentage === 0 && scrollLeft === 0); + return (this.x && (this.x.percentage === 0 || this.horizontalScrollLength < 0) && scrollLeft === 0); }; ScrollEvent.prototype.atRight = function(scrollLeft) { - return (this.x && this.x.percentage === 1 && scrollLeft > 0); + return (this.x && (this.x.percentage === 1 || this.horizontalScrollLength ===0) && scrollLeft > 0); };