Skip to content

Commit c8405a7

Browse files
Seeykomportuga
authored andcommitted
fix(core): make scrollToIfNecessary bottom scroll work with bottom pixel of the row.
1 parent d3c3580 commit c8405a7

File tree

1 file changed

+8
-6
lines changed
  • packages/core/src/js/factories

1 file changed

+8
-6
lines changed

packages/core/src/js/factories/Grid.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2440,7 +2440,7 @@ angular.module('ui.grid')
24402440
if (gridRow !== null) {
24412441
// This is the index of the row we want to scroll to, within the list of rows that can be visible
24422442
var seekRowIndex = visRowCache.indexOf(gridRow);
2443-
2443+
24442444
// Total vertical scroll length of the grid
24452445
var scrollLength = (self.renderContainers.body.getCanvasHeight() - self.renderContainers.body.getViewportHeight());
24462446

@@ -2472,13 +2472,15 @@ angular.module('ui.grid')
24722472
scrollEvent.y = getScrollY(scrollPixels, scrollLength, self.renderContainers.body.prevScrolltopPercentage);
24732473
}
24742474
// Otherwise if the scroll position we need to see the row is MORE than the bottom boundary, i.e. obscured below the bottom of the self...
2475-
else if (pixelsToSeeRow > Math.ceil(bottomBound)) {
2475+
// add the height of one row since scrollPixels points to the top pixel of the row
2476+
else if ((pixelsToSeeRow + self.options.rowHeight) > Math.ceil(bottomBound)) {
24762477
// Get the different between the bottom boundary and the required scroll position and add it to the current scroll position
2477-
// to get the full position we need
2478-
scrollPixels = pixelsToSeeRow - bottomBound + self.renderContainers.body.prevScrollTop;
2478+
// plus the height of one row since scrollPixels points to the top pixel of the row
2479+
// to get the full position we need
2480+
scrollPixels = (pixelsToSeeRow + self.options.rowHeight) - bottomBound + self.renderContainers.body.prevScrollTop;
24792481

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

0 commit comments

Comments
 (0)