From b19c24c0cabfb8b25a16d816b806d1dc51069721 Mon Sep 17 00:00:00 2001 From: Marcello Stanisci Date: Wed, 6 Jun 2018 22:36:50 +0200 Subject: Scrolling feature. Disabling the scrolling feature after the page gets filled by /track/transaction results. Such results are not guaranteed to be sorted in any way, so there is little point in scrolling down towards "older" results. The scrolling feature will be re-enabled once the page will again be filled with results from /history - notably, on page refresh. --- js/backoffice.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/js/backoffice.js b/js/backoffice.js index 82b0ae6..35e5c88 100644 --- a/js/backoffice.js +++ b/js/backoffice.js @@ -31,6 +31,7 @@ var FRACTION = 100000000; var START = 0; var DELTA = 5 var LAST = 0; +var SCROLL = true; /** * This function *could* "type check" 'amount', @@ -161,6 +162,13 @@ var track_transfer = function(exchange, wtid, cb){ if(4 == req.readyState){ switch(req.status){ case 200: + /* Scroll is disabled after showing /track/transfer + * results on the page; that's because those results + * are not guaranteed to be sorted any how, so there + * is little to no point in scrolling towards "older" + * results: older than what? The scroll feature will + * be re-enabled from the /history callback. */ + SCROLL = false; var tracks = JSON.parse(req.responseText); cb(false, tracks.deposits_sums, @@ -538,6 +546,7 @@ function change_instance(){ * to 'fill_table()'. */ function get_history(scroll, cb){ + SCROLL = true; var qs = `/history?instance=${get_instance()}&delta=${DELTA}`; if(scroll){ START = LAST; @@ -579,8 +588,8 @@ document.addEventListener document.addEventListener ("scroll", function(){ /* If page bottom is hit */ - if(window.innerHeight + window.scrollY - >= document.body.offsetHeight) + if((window.innerHeight + window.scrollY + >= document.body.offsetHeight) && SCROLL) get_history(true, fill_table); }); -- cgit v1.2.3