Skip to content

Commit

Permalink
fix(Grid): Redraw needs scrollTop when adding rows
Browse files Browse the repository at this point in the history
Regression Fix for #2357 the scrollPercentage is not correct if there
are added rows, because then the scrollPercentage should be
recalculated.
  • Loading branch information
jcompagner authored and c0bra committed Feb 19, 2015
1 parent 3b24342 commit 509e007
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/js/core/directives/ui-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
self.grid.modifyRows(newData)
.then(function () {
// if (self.viewport) {
self.grid.redrawInPlace();
self.grid.redrawInPlace(true);
// }

$scope.$evalAsync(function() {
Expand Down
15 changes: 11 additions & 4 deletions src/js/core/factories/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -2001,9 +2001,10 @@ angular.module('ui.grid')
* @name redrawCanvas
* @methodOf ui.grid.class:Grid
* @description Redraw the rows and columns based on our current scroll position
* @param {boolean} [rowsAdded] Optional to indicate rows are added and the scroll percentage must be recalculated
*
*/
Grid.prototype.redrawInPlace = function redrawInPlace() {
Grid.prototype.redrawInPlace = function redrawInPlace(rowsAdded) {
// gridUtil.logDebug('redrawInPlace');

var self = this;
Expand All @@ -2012,9 +2013,15 @@ angular.module('ui.grid')
var container = self.renderContainers[i];

// gridUtil.logDebug('redrawing container', i);

container.adjustRows(null, container.prevScrolltopPercentage, true);
container.adjustColumns(null, container.prevScrollleftPercentage);

if (rowsAdded) {
container.adjustRows(container.prevScrollTop, null);
container.adjustColumns(container.prevScrollTop, null);
}
else {
container.adjustRows(null, container.prevScrolltopPercentage);
container.adjustColumns(null, container.prevScrollleftPercentage);
}
}
};

Expand Down

1 comment on commit 509e007

@cookednoodles
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't L2019 be :
container.adjustColumns(container.prevScrollLeft, null); ?

Please sign in to comment.