From c8405a704ad1f0546c290b572dd5b4899e25635f Mon Sep 17 00:00:00 2001 From: "Seeyko (tom.andrieu)" Date: Tue, 26 Sep 2023 11:50:38 +0200 Subject: [PATCH] fix(core): make scrollToIfNecessary bottom scroll work with bottom pixel of the row. --- packages/core/src/js/factories/Grid.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/core/src/js/factories/Grid.js b/packages/core/src/js/factories/Grid.js index e700f83d1..8676fa5b7 100644 --- a/packages/core/src/js/factories/Grid.js +++ b/packages/core/src/js/factories/Grid.js @@ -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); - + // Total vertical scroll length of the grid var scrollLength = (self.renderContainers.body.getCanvasHeight() - self.renderContainers.body.getViewportHeight()); @@ -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 + 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); } }