From 321aa05eab1e68011177f131c5d762ec133ab470 Mon Sep 17 00:00:00 2001 From: s1341 Date: Sun, 22 Dec 2013 18:41:39 +0200 Subject: [PATCH] Fix transition bug; add scrollIntoView. --- src/static/js/revisioncache.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/static/js/revisioncache.js b/src/static/js/revisioncache.js index d0655d823..7eb001404 100644 --- a/src/static/js/revisioncache.js +++ b/src/static/js/revisioncache.js @@ -348,35 +348,29 @@ $.Class("RevisionCache", changesetsProcessed_callback(data.start); } - var rounddown = function (a, b) { return Math.floor(a / b) * b; }; var roundup = function (a, b) { return (Math.floor(a / b)+1) * b; }; - //TODO: it might be better to be stricter about start addresses. - //At the moment if you request changesets from 2 -> 12, it will request at granularity 10. - //Not sure if we shouldn't only request granularities > 1 when we have a strict multiple of 10,100 etc. - //This is compounded by the fact that revisions are 1 based! - //TODO: we need to deal with the case where we need MORE THAN 100 of a particular granularity //console.log("[requestChangesets] start: %d, end: %d, delta: %d, adelta: %d", start, end, delta, adelta); for (var g in Revision.granularities) { var granularity = Revision.granularities[g]; var remainder = Math.floor(adelta / granularity); //console.log("\t[requestChangesets] start: %d, granularity: %d, adelta: %d, //: %d", start, granularity, adelta, remainder); //console.log("\t rounddown delta: %d, start: %d", rounddown(adelta, granularity), rounddown(start, granularity)); - //console.log("\t new start:", newstart); if (remainder) { //this.loader.enqueue(start, granularity, process_received_changesets); - console.log("\t[requestChangesets] REQUEST start: %d, end: %d, granularity: %d", rounddown(start, granularity), roundup(adelta, granularity), granularity); + //console.log("\t[requestChangesets] REQUEST start: %d, end: %d, granularity: %d", rounddown(start, granularity), roundup(adelta, granularity), granularity); this.loader.enqueue(rounddown(start, granularity), granularity, process_received_changesets); + // for the next granularity, we assume that we have now successfully navigated + // as far as required for this granularity. We should also make sure that only + // the significant part of the adelta is used in the next granularity. + start = rounddown(start, granularity) + rounddown(adelta, granularity); + adelta = adelta - rounddown(adelta, granularity); + //console.log("\t new start: %d, delta: %d", start, adelta); } - // for the next granularity, we assume that we have now successfully navigated - // as far as required for this granularity. We should also make sure that only - // the significant part of the adelta is used in the next granularity. - start = rounddown(start, granularity) + rounddown(adelta, granularity); - adelta = adelta - rounddown(adelta, granularity); } }, } @@ -808,6 +802,8 @@ $.Class("PadClient", // otherwise just add the new divs after the index-th div else this.divs[index - 1].after(newdivs); + // super primitive scrollIntoView + newdivs[0][0].scrollIntoView(false); // perform the splice on our array itself // TODO: monkey patching divs.splice, so use divs.original_splice or something