Skip to content

Commit

Permalink
fix(core): scrollToIfNecessary not properly including rowHeight on do…
Browse files Browse the repository at this point in the history
…wnward scrolls
  • Loading branch information
Mikey McOrmond authored and mportuga committed Oct 7, 2019
1 parent c304655 commit 7a0e1dc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/core/src/js/factories/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -2332,8 +2332,8 @@ angular.module('ui.grid')

/*-- Get the top, left, right, and bottom "scrolled" edges of the grid --*/

// The top boundary is the current Y scroll position PLUS the header height, because the header can obscure rows when the grid is scrolled downwards
var topBound = self.renderContainers.body.prevScrollTop + self.headerHeight;
// The top boundary is the current Y scroll position
var topBound = self.renderContainers.body.prevScrollTop;

// Don't the let top boundary be less than 0
topBound = (topBound < 0) ? 0 : topBound;
Expand Down Expand Up @@ -2372,7 +2372,7 @@ angular.module('ui.grid')
// }

// This is the minimum amount of pixels we need to scroll vertical in order to see this row.
var pixelsToSeeRow = (seekRowIndex * self.options.rowHeight + self.headerHeight);
var pixelsToSeeRow = (seekRowIndex * self.options.rowHeight);

// Don't let the pixels required to see the row be less than zero
pixelsToSeeRow = (pixelsToSeeRow < 0) ? 0 : pixelsToSeeRow;
Expand All @@ -2399,7 +2399,8 @@ angular.module('ui.grid')
// to get the full position we need
scrollPixels = pixelsToSeeRow - bottomBound + self.renderContainers.body.prevScrollTop;

scrollEvent.y = getScrollY(scrollPixels, scrollLength,self.renderContainers.body.prevScrolltopPercentage);
// Scroll to full position plus the height of one row since scrollPixels points to the top pixel of the row
scrollEvent.y = getScrollY(scrollPixels + self.options.rowHeight, scrollLength, self.renderContainers.body.prevScrolltopPercentage);
}
}

Expand Down

0 comments on commit 7a0e1dc

Please sign in to comment.