Skip to content

Commit

Permalink
fix(core): fix #3666 #3531 #3340
Browse files Browse the repository at this point in the history
thanks to @500tech-user and @Jacquelin for PR's that led to this fix
  • Loading branch information
swalters committed Jun 19, 2015
1 parent 1338b6c commit e582174
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/js/core/directives/ui-grid-render-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -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; }
Expand Down
11 changes: 7 additions & 4 deletions src/js/core/factories/ScrollEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
self.x = null;
self.y = null;

self.verticalScrollLength = -9999999;
self.horizontalScrollLength = -999999;


/**
* @ngdoc function
Expand Down Expand Up @@ -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);
};


Expand Down

0 comments on commit e582174

Please sign in to comment.