Skip to content

Commit

Permalink
Merge pull request angular-ui#5142 from korolyovvalentin/master
Browse files Browse the repository at this point in the history
fix(core): Incorrect horizontal scroll percentage calculation
  • Loading branch information
swalters committed Feb 23, 2016
2 parents 5fac8ea + f075dcb commit e52aaaf
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/js/core/factories/GridRenderContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@ angular.module('ui.grid')
return this.getCanvasHeight() - this.getViewportHeight() + this.grid.scrollbarHeight;
};

GridRenderContainer.prototype.getHorizontalScrollLength = function getHorizontalScrollLength() {
return this.getCanvasWidth() - this.getViewportWidth() + this.grid.scrollbarWidth;
};

GridRenderContainer.prototype.getCanvasWidth = function getCanvasWidth() {
var self = this;

Expand Down Expand Up @@ -375,7 +379,7 @@ angular.module('ui.grid')
if (xDiff > 0) { this.grid.scrollDirection = uiGridConstants.scrollDirection.RIGHT; }
if (xDiff < 0) { this.grid.scrollDirection = uiGridConstants.scrollDirection.LEFT; }

var horizScrollLength = (this.canvasWidth - this.getViewportWidth());
var horizScrollLength = this.getHorizontalScrollLength();
if (horizScrollLength !== 0) {
horizScrollPercentage = newScrollLeft / horizScrollLength;
}
Expand Down Expand Up @@ -487,8 +491,7 @@ angular.module('ui.grid')

// Calculate the scroll percentage according to the scrollLeft location, if no percentage was provided
if ((typeof(scrollPercentage) === 'undefined' || scrollPercentage === null) && scrollLeft) {
var horizScrollLength = (self.getCanvasWidth() - self.getViewportWidth());
scrollPercentage = scrollLeft / horizScrollLength;
scrollPercentage = scrollLeft / self.getHorizontalScrollLength();
}

var colIndex = Math.ceil(Math.min(maxColumnIndex, maxColumnIndex * scrollPercentage));
Expand Down

0 comments on commit e52aaaf

Please sign in to comment.