Description
When the grid's function scrollToIfNecessary is called, it scrolls both horizontally and vertically to ensure the row/column is in view.
The issue is that if a grid has a column that is wider than the viewport of the grid, when it is asked to scroll to the selection, the horizontal scrolling will bounce from left to right due to the following logic:
if (columnLeftEdge < leftBound) {
// Get the different between the top boundary and the required scroll position and subtract it from the current scroll position\
// to get the full position we need
horizScrollPixels = grid.renderContainers.body.prevScrollLeft - (leftBound - columnLeftEdge);
// Turn the scroll position into a percentage and make it an argument for a scroll event
horizPercentage = horizScrollPixels / horizScrollLength;
horizPercentage = (horizPercentage > 1) ? 1 : horizPercentage;
scrollEvent.x = {percentage: horizPercentage};
}
// 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 grid...
else if (columnRightEdge > rightBound) {
// 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
horizScrollPixels = columnRightEdge - rightBound + grid.renderContainers.body.prevScrollLeft;
// Turn the scroll position into a percentage and make it an argument for a scroll event
horizPercentage = horizScrollPixels / horizScrollLength;
horizPercentage = (horizPercentage > 1) ? 1 : horizPercentage;
scrollEvent.x = {percentage: horizPercentage};
}
Basically if either side of a column is scrolled off, scroll so that it fits in that edge. I feel that logic ignores our case where the left edge of a column is already scrolled into view. I suggest adding the following lines of code to the beginning of this code snip.
if (columnLeftEdge == leftBound) {
// Do nothing. Already scrolled into view.
}
else
This will leave the scrolling where it is if the current left edge of the scroll is equivalent to the left edge of the grid EVEN if that column is wider than the grid.