Skip to content

Commit 7a0e1dc

Browse files
Mikey McOrmondmportuga
Mikey McOrmond
authored andcommitted
fix(core): scrollToIfNecessary not properly including rowHeight on downward scrolls
1 parent c304655 commit 7a0e1dc

File tree

1 file changed

+5
-4
lines changed
  • packages/core/src/js/factories

1 file changed

+5
-4
lines changed

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -2332,8 +2332,8 @@ angular.module('ui.grid')
23322332

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

2335-
// 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
2336-
var topBound = self.renderContainers.body.prevScrollTop + self.headerHeight;
2335+
// The top boundary is the current Y scroll position
2336+
var topBound = self.renderContainers.body.prevScrollTop;
23372337

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

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

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

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

0 commit comments

Comments
 (0)