From 5c74c7b415f3077528290a4a35b660db932072a6 Mon Sep 17 00:00:00 2001 From: Ventero Date: Sat, 29 Sep 2012 12:29:43 +0200 Subject: [PATCH 1/3] Always clear the image load timeout job. --- openseadragon.js | 4 ++-- src/drawer.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openseadragon.js b/openseadragon.js index b002a24f..7a89136d 100644 --- a/openseadragon.js +++ b/openseadragon.js @@ -7995,11 +7995,11 @@ $.Drawer.prototype = { }; image.onload = function(){ - finishLoadingImage( image, complete, true ); + finishLoadingImage( image, complete, true, jobid ); }; image.onabort = image.onerror = function(){ - finishLoadingImage( image, complete, false ); + finishLoadingImage( image, complete, false, jobid ); }; jobid = window.setTimeout( function(){ diff --git a/src/drawer.js b/src/drawer.js index 1cc5082a..c64ae86d 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -311,11 +311,11 @@ $.Drawer.prototype = { }; image.onload = function(){ - finishLoadingImage( image, complete, true ); + finishLoadingImage( image, complete, true, jobid ); }; image.onabort = image.onerror = function(){ - finishLoadingImage( image, complete, false ); + finishLoadingImage( image, complete, false, jobid ); }; jobid = window.setTimeout( function(){ From bb0ac1f9d1e8401b19900973ea001d2d7cc0dacc Mon Sep 17 00:00:00 2001 From: Ventero Date: Sat, 29 Sep 2012 12:14:27 +0200 Subject: [PATCH 2/3] Pass the correct object to image load callbacks. Previously, the image object was passed on to onTileLoad regardless if it loaded successfully or not. In case an image failed to load, this would result in trying to draw a non-existing image onto the canvas, which (at least in Firefox) throws a DOM exception and results in the drawer being stuck mid-update. --- openseadragon.js | 4 ++-- src/drawer.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openseadragon.js b/openseadragon.js index 7a89136d..8a792d54 100644 --- a/openseadragon.js +++ b/openseadragon.js @@ -7977,11 +7977,11 @@ $.Drawer.prototype = { image = new Image(); - complete = function( imagesrc ){ + complete = function( imagesrc, img ){ _this.downloading--; if (typeof ( callback ) == "function") { try { - callback( image ); + callback( img ); } catch ( e ) { $.console.error( "%s while executing %s callback: %s", diff --git a/src/drawer.js b/src/drawer.js index c64ae86d..d04c287e 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -293,11 +293,11 @@ $.Drawer.prototype = { image = new Image(); - complete = function( imagesrc ){ + complete = function( imagesrc, img ){ _this.downloading--; if (typeof ( callback ) == "function") { try { - callback( image ); + callback( img ); } catch ( e ) { $.console.error( "%s while executing %s callback: %s", From 8f085c83ca6be8b54bb2db66023450fc8020c3c2 Mon Sep 17 00:00:00 2001 From: Ventero Date: Fri, 25 Jan 2013 20:36:41 +0100 Subject: [PATCH 3/3] Update documentation for Drawer#loadImage. Additionally, improve name of the parameter passed to the complete listener. --- openseadragon.js | 12 ++++++------ src/drawer.js | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/openseadragon.js b/openseadragon.js index 8a792d54..7db28fa4 100644 --- a/openseadragon.js +++ b/openseadragon.js @@ -7957,10 +7957,10 @@ $.Drawer.prototype = { * @method * @param {String} src - The url of the image to load. * @param {Function} callback - The function that will be called with the - * Image object as the only parameter, whether on 'load' or on 'abort'. - * For now this means the callback is expected to distinguish between - * error and success conditions by inspecting the Image object. - * @return {Boolean} loading - Wheter the request was submitted or ignored + * Image object as the only parameter if it was loaded successfully. + * If an error occured, or the request timed out or was aborted, + * the parameter is null instead. + * @return {Boolean} loading - Wheter the request was submitted or ignored * based on OpenSeadragon.DEFAULT_SETTINGS.imageLoaderLimit. */ loadImage: function( src, callback ) { @@ -7977,11 +7977,11 @@ $.Drawer.prototype = { image = new Image(); - complete = function( imagesrc, img ){ + complete = function( imagesrc, resultingImage ){ _this.downloading--; if (typeof ( callback ) == "function") { try { - callback( img ); + callback( resultingImage ); } catch ( e ) { $.console.error( "%s while executing %s callback: %s", diff --git a/src/drawer.js b/src/drawer.js index d04c287e..6c0fa02e 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -273,10 +273,10 @@ $.Drawer.prototype = { * @method * @param {String} src - The url of the image to load. * @param {Function} callback - The function that will be called with the - * Image object as the only parameter, whether on 'load' or on 'abort'. - * For now this means the callback is expected to distinguish between - * error and success conditions by inspecting the Image object. - * @return {Boolean} loading - Wheter the request was submitted or ignored + * Image object as the only parameter if it was loaded successfully. + * If an error occured, or the request timed out or was aborted, + * the parameter is null instead. + * @return {Boolean} loading - Wheter the request was submitted or ignored * based on OpenSeadragon.DEFAULT_SETTINGS.imageLoaderLimit. */ loadImage: function( src, callback ) { @@ -293,11 +293,11 @@ $.Drawer.prototype = { image = new Image(); - complete = function( imagesrc, img ){ + complete = function( imagesrc, resultingImage ){ _this.downloading--; if (typeof ( callback ) == "function") { try { - callback( img ); + callback( resultingImage ); } catch ( e ) { $.console.error( "%s while executing %s callback: %s",