Attempt to get rows in the direction of need, rather than centered on the missing rows

This commit is contained in:
Nathan Gray 2014-05-22 14:48:22 +00:00
parent 78a461b120
commit 84e20433b6

View File

@ -413,7 +413,7 @@ var et2_dataview_controller = Class.extend({
// Queue fetching that data range // Queue fetching that data range
if (needsData !== false) if (needsData !== false)
{ {
this._queueFetch(et2_bounds(needsData, _idxEnd + 1), false); this._queueFetch(et2_bounds(needsData, _idxEnd + 1), needsData == _idxStart ? 0 : needsData > _idxStart ? 1 : -1, false);
} }
}, },
@ -421,7 +421,7 @@ var et2_dataview_controller = Class.extend({
* The _queueFetch function is used to queue a fetch request. * The _queueFetch function is used to queue a fetch request.
* TODO: Refresh is currently not used * TODO: Refresh is currently not used
*/ */
_queueFetch: function (_range, _isUpdate) { _queueFetch: function (_range, _direction, _isUpdate) {
// Force immediate to be false // Force immediate to be false
_isUpdate = _isUpdate ? _isUpdate : false; _isUpdate = _isUpdate ? _isUpdate : false;
@ -433,7 +433,7 @@ var et2_dataview_controller = Class.extend({
{ {
if (typeof this._queue[i] === "undefined") if (typeof this._queue[i] === "undefined")
{ {
this._queue[i] = 1; // Stage 1 -- queued this._queue[i] = _direction; // Stage 1 - queue for after current, -1 -- queue for before current
} }
} }
@ -472,13 +472,13 @@ var et2_dataview_controller = Class.extend({
key = parseInt(key); key = parseInt(key);
var b = Math.max(0, key - r); var b = Math.max(0, key - r + (r * this._queue[key]));
var t = Math.min(key + r, total - 1); var t = Math.min(key + r + (r * this._queue[key]), total - 1);
var c = 0; var c = 0;
for (var i = b; i <= t && c < ET2_DATAVIEW_STEPSIZE; i ++) for (var i = b; i <= t && c < ET2_DATAVIEW_STEPSIZE; i ++)
{ {
if (typeof this._queue[i] == "undefined" if (typeof this._queue[i] == "undefined"
|| this._queue[i] === 1) || this._queue[i] <= 1)
{ {
this._queue[i] = 2; // Stage 2 -- pending or available this._queue[i] = 2; // Stage 2 -- pending or available
marked[i] = true; marked[i] = true;