Permalink
Browse files

Prevent row indexing over loading nodes.

Correct an error in preload count updating based on page offset.
Don't adjust scroll if a loading is not attached.
Add random delay to REST service to give out of order responses, for reproducing edge cases.
refs #323 refs #318
  • Loading branch information...
kriszyp committed Nov 16, 2012
1 parent 97696f4 commit 04f85170d8debf1f23848debe267b50bb0fc084a
Showing with 8 additions and 6 deletions.
  1. +1 −1 List.js
  2. +3 −2 OnDemandList.js
  3. +4 −3 test/data/rest.php
View
@@ -397,7 +397,7 @@ function(arrayUtil, kernel, declare, listen, has, miscUtil, TouchScroll, hasClas
}
next.rowIndex = rowIndex++;
}
- }while((next = next.nextSibling) && next.rowIndex != rowIndex);
+ }while((next = next.nextSibling) && next.rowIndex != rowIndex && !next.blockRowIndex);
}
}
},
View
@@ -320,12 +320,12 @@ return declare([List, _StoreMixin], {
offset = Math.min(preload.count, offset);
preload.previous.count += offset;
adjustHeight(preload.previous, true);
- preload.count -= offset;
preloadNode.rowIndex += offset;
queryRowsOverlap = 0;
}else{
count += offset;
}
+ preload.count -= offset;
}
options.start = preloadNode.rowIndex - queryRowsOverlap;
preloadNode.rowIndex += count;
@@ -360,6 +360,7 @@ return declare([List, _StoreMixin], {
innerNode = put(loadingNode, "div.dgrid-" + (below ? "below" : "above"));
innerNode.innerHTML = grid.loadingMessage;
loadingNode.count = count;
+ loadingNode.blockRowIndex = true;
// use the query associated with the preload node to get the next "page"
options.query = preload.query;
// Query now to fill in these rows.
@@ -377,7 +378,7 @@ return declare([List, _StoreMixin], {
// can remove the loading node now
beforeNode = loadingNode.nextSibling;
put(loadingNode, "!");
- if(keepScrollTo && beforeNode){ // beforeNode may have been removed if the query results loading node was a removed as a distant node before rendering
+ if(keepScrollTo && beforeNode && beforeNode.offsetWidth){ // beforeNode may have been removed if the query results loading node was a removed as a distant node before rendering
// if the preload area above the nodes is approximated based on average
// row height, we may need to adjust the scroll once they are filled in
// so we don't "jump" in the scrolling position
View
@@ -4,6 +4,7 @@
if(isset($_GET["parent"])){
$id_prefix = $_GET["parent"]."-";
}
+usleep(rand(0,500000));
$range = "";
if(isset($_SERVER["HTTP_RANGE"])){
$range = $_SERVER["HTTP_RANGE"];
@@ -15,14 +16,14 @@
$start = $matches[1];
$end = $matches[2];
- if($end > 120){
- $end = 120;
+ if($end > 1000){
+ $end = 1000;
}
}else{
$start = 0;
$end = 40;
}
-header("Content-Range: " . "items ".$start."-".$end."/120");
+header("Content-Range: " . "items ".$start."-".$end."/1000");
echo '[';
for ($i = $start; $i <= $end; $i++) {
if($i != $start){

0 comments on commit 04f8517

Please sign in to comment.