Permalink
Browse files

Calculate the loading node height when reaching the end such that we …

…preserve the scrolling height
  • Loading branch information...
1 parent 932b97e commit 37de2c54363c9511db7acb03337b64dba6182b9e @kriszyp committed Oct 15, 2012
Showing with 6 additions and 5 deletions.
  1. +6 −5 OnDemandList.js
View
11 OnDemandList.js
@@ -325,6 +325,7 @@ return declare([List, _StoreMixin], {
preload.count -= count;
var beforeNode = preloadNode,
keepScrollTo = false, queryRowsOverlap = grid.queryRowsOverlap,
+ originalScrollHeight = scrollNode.scrollHeight,
below = preloadNode.bottom && preload;
if(below){
// add new rows below
@@ -371,14 +372,14 @@ return declare([List, _StoreMixin], {
}
// create a loading node as a placeholder while the data is loaded
var loadingNode = put(beforeNode, "-div.dgrid-loading");
- loadingNode.style.height = (count * grid.rowHeight) + "px";
if(preload.count){
+ loadingNode.style.height = (count * grid.rowHeight) + "px";
preload.node.style.height = (preloadNode.offsetHeight + (preload.count - priorCount) * grid.rowHeight) + "px";
}else{
- if(keepScrollTo){
- // we are contiguous with the top, so make sure we replacing the loading with exactly the preload height
- loadingNode.style.height = preloadNode.offsetHeight + "px";
- }
+ // we are contiguous with the end, make sure we replacing the loading with a better estimate of the preload height
+ // since the preload node now represents zero rows, it should be zero height, and then we set the loading node to be the correct height that will retain the scroll height
+ loadingNode.style.height = "0px";
+ loadingNode.style.height = (originalScrollHeight - scrollNode.scrollHeight + preloadNode.offsetHeight) + "px";
preload.node.style.height = "0px";
}
put(loadingNode, "div.dgrid-" + (below ? "below" : "above"), grid.loadingMessage);

0 comments on commit 37de2c5

Please sign in to comment.