From f9db75311d48e26ff005de64076313f7db0aaefd Mon Sep 17 00:00:00 2001 From: James Taylor Date: Sat, 2 Apr 2011 23:12:02 -0400 Subject: [PATCH] trackster: fix bug with fetching same data many times by putting deferred in data cache immediately, still problematic because many deferred callbacks are queued up and the tile is drawn multiple times, debug statement demonstrates this, needs more refactoring to get it right --- static/scripts/trackster.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/static/scripts/trackster.js b/static/scripts/trackster.js index ccdd7522d46..9ab02793215 100644 --- a/static/scripts/trackster.js +++ b/static/scripts/trackster.js @@ -314,10 +314,11 @@ extend(DataManager.prototype, Cache.prototype, { } */ - // - // Load data from server. - // - return this.load_data(chrom, low, high, mode, resolution, extra_params); + // Load data from server. The deferred is immediately saved until the + // data is ready, it then replaces itself with the actual data + entry = this.load_data(chrom, low, high, mode, resolution, extra_params); + this.set_data( low, high, mode, entry ); + return entry }, set_data: function(low, high, mode, result) { //console.log("set_data", low, high, mode, result); @@ -1717,6 +1718,8 @@ extend(TiledTrack.prototype, Track.prototype, { var track = this; // Put a 50ms delay on drawing so that if the user scrolls fast, we don't load extra data var draw_and_show_tile = function(id, result, resolution, tile_index, parent_element, w_scale, seq_data) { + // DEBUG: this is still called too many times when moving slowly, + // console.log( "draw_and_show_tile", resolution, tile_index, w_scale ); returned_tile = track.draw_tile(result, resolution, tile_index, parent_element, w_scale, seq_data) // Wrap element in div for background