Skip to content

Commit

Permalink
fix(infinite-scroll): load more data if needed
Browse files Browse the repository at this point in the history
detect if more data needs to be loaded after the initial load. Before if
not enough data was loaded to enable scrolling, no more data would be
loaded. Resolves issue
[4363](#4363)
  • Loading branch information
DmitryEfimenko committed Sep 18, 2015
1 parent 880ce19 commit 65a541f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/features/infinite-scroll/js/infinite-scroll.js
Expand Up @@ -368,6 +368,12 @@

newVisibleRows = grid.getVisibleRowCount();

// in case not enough data is loaded to enable scroller - load more data
var canvasHeight = rowHeight * newVisibleRows;
if (grid.infiniteScroll.scrollDown && (viewportHeight > canvasHeight)) {
grid.api.infiniteScroll.raise.needLoadMoreData();
}

if ( grid.infiniteScroll.direction === uiGridConstants.scrollDirection.UP ){
oldTop = grid.infiniteScroll.prevScrollTop || 0;
newTop = oldTop + (newVisibleRows - grid.infiniteScroll.previousVisibleRows)*rowHeight;
Expand Down

1 comment on commit 65a541f

@DerekDomino
Copy link

Choose a reason for hiding this comment

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

When the end of the data stack is reached or when the initial data stack is empty or not long enough to need infinite scrolling, these lines trigger an incredible amount of needLoadMoreData()calls.

The angular app then hangs.

Please sign in to comment.