From 55ea2c3b5179708c1e6ff4244fd39669e7099996 Mon Sep 17 00:00:00 2001 From: Philip Giuliani Date: Tue, 3 Mar 2015 09:29:23 +0100 Subject: [PATCH 1/4] Call abort on all jobs before the queue gets cleared --- src/imageloader.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/imageloader.js b/src/imageloader.js index d1f9e785..7fcf98fd 100644 --- a/src/imageloader.js +++ b/src/imageloader.js @@ -124,7 +124,8 @@ $.ImageLoader.prototype = /** @lends OpenSeadragon.ImageLoader.prototype */{ jobOptions = { src: options.src, crossOriginPolicy: options.crossOriginPolicy, - callback: complete + callback: complete, + abort: options.abort }, newJob = new ImageJob( jobOptions ); @@ -142,6 +143,13 @@ $.ImageLoader.prototype = /** @lends OpenSeadragon.ImageLoader.prototype */{ * @method */ clear: function() { + for( var i = 0; i < this.jobQueue.length; i++ ) { + job = this.jobQueue[i]; + if ( typeof job.abort === "function" ) { + job.abort(); + } + } + this.jobQueue = []; } }; From 6bf3b8d7d40e915b35a8d67f5802245bcd0b0303 Mon Sep 17 00:00:00 2001 From: Philip Giuliani Date: Tue, 3 Mar 2015 09:29:31 +0100 Subject: [PATCH 2/4] Set loading to false when job is aborted --- src/tiledimage.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tiledimage.js b/src/tiledimage.js index ba587d07..9431502a 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -883,6 +883,9 @@ function loadTile( tiledImage, tile, time ) { crossOriginPolicy: tiledImage.crossOriginPolicy, callback: function( image ){ onTileLoad( tiledImage, tile, time, image ); + }, + abort: function() { + tile.loading = false; } }); } From 8dc8779fee15cd79e137963cf0c5d6790489c4a4 Mon Sep 17 00:00:00 2001 From: Philip Giuliani Date: Tue, 3 Mar 2015 09:29:44 +0100 Subject: [PATCH 3/4] Clear the imageLoader when re-drawing --- src/viewer.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/viewer.js b/src/viewer.js index 11b33e6d..155174d4 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -673,7 +673,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, THIS[ this.hash ].animating = false; this.world.removeAll(); this.imageLoader.clear(); - + /** * Raised when the viewer is closed (see {@link OpenSeadragon.Viewer#close}). * @@ -2926,6 +2926,7 @@ function resizeViewportAndRecenter( viewer, containerSize, oldBounds, oldCenter } function drawWorld( viewer ) { + viewer.imageLoader.clear(); viewer.drawer.clear(); viewer.world.draw(); From 75b0d316f85ebbbf7cb2d44b56306dff35ef9320 Mon Sep 17 00:00:00 2001 From: Philip Giuliani Date: Tue, 3 Mar 2015 09:36:04 +0100 Subject: [PATCH 4/4] Forgot var --- src/imageloader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/imageloader.js b/src/imageloader.js index 7fcf98fd..a61c8936 100644 --- a/src/imageloader.js +++ b/src/imageloader.js @@ -144,7 +144,7 @@ $.ImageLoader.prototype = /** @lends OpenSeadragon.ImageLoader.prototype */{ */ clear: function() { for( var i = 0; i < this.jobQueue.length; i++ ) { - job = this.jobQueue[i]; + var job = this.jobQueue[i]; if ( typeof job.abort === "function" ) { job.abort(); }