Skip to content

Commit

Permalink
fix(core): make scrollToIfNecessary bottom scroll work with bottom pi…
Browse files Browse the repository at this point in the history
…xel of the row.
  • Loading branch information
Seeyko authored and mportuga committed Mar 27, 2024
1 parent d3c3580 commit c8405a7
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/core/src/js/factories/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -2440,7 +2440,7 @@ angular.module('ui.grid')
if (gridRow !== null) {
// This is the index of the row we want to scroll to, within the list of rows that can be visible
var seekRowIndex = visRowCache.indexOf(gridRow);

Check failure on line 2443 in packages/core/src/js/factories/Grid.js

View workflow job for this annotation

GitHub Actions / test-windows (14.x)

Trailing spaces not allowed
// Total vertical scroll length of the grid
var scrollLength = (self.renderContainers.body.getCanvasHeight() - self.renderContainers.body.getViewportHeight());

Expand Down Expand Up @@ -2472,13 +2472,15 @@ angular.module('ui.grid')
scrollEvent.y = getScrollY(scrollPixels, scrollLength, self.renderContainers.body.prevScrolltopPercentage);
}
// 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...
else if (pixelsToSeeRow > Math.ceil(bottomBound)) {
// add the height of one row since scrollPixels points to the top pixel of the row
else if ((pixelsToSeeRow + self.options.rowHeight) > Math.ceil(bottomBound)) {
// Get the different between the bottom boundary and the required scroll position and add it to the current scroll position
// to get the full position we need
scrollPixels = pixelsToSeeRow - bottomBound + self.renderContainers.body.prevScrollTop;
// plus the height of one row since scrollPixels points to the top pixel of the row
// to get the full position we need

Check failure on line 2479 in packages/core/src/js/factories/Grid.js

View workflow job for this annotation

GitHub Actions / test-windows (14.x)

Trailing spaces not allowed
scrollPixels = (pixelsToSeeRow + self.options.rowHeight) - bottomBound + self.renderContainers.body.prevScrollTop;

// 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);
// Scroll to full position
scrollEvent.y = getScrollY(scrollPixels, scrollLength, self.renderContainers.body.prevScrolltopPercentage);
}
}

Expand Down

0 comments on commit c8405a7

Please sign in to comment.