diff --git a/Gruntfile.js b/Gruntfile.js index f774df6f..828f37a1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -46,7 +46,7 @@ module.exports = function(grunt) { "src/referencestrip.js", "src/displayrectangle.js", "src/spring.js", - "src/imageLoader.js", + "src/imageloader.js", "src/tile.js", "src/overlay.js", "src/drawer.js", diff --git a/src/imageLoader.js b/src/imageloader.js similarity index 93% rename from src/imageLoader.js rename to src/imageloader.js index f1d5265d..d1f9e785 100644 --- a/src/imageLoader.js +++ b/src/imageloader.js @@ -94,14 +94,16 @@ ImageJob.prototype = { * @memberof OpenSeadragon * @classdesc Handles downloading of a set of images using asynchronous queue pattern. * You generally won't have to interact with the ImageLoader directly. + * @param {Object} options - Options for this ImageLoader. + * @param {Number} [options.jobLimit] - The number of concurrent image requests. See imageLoaderLimit in {@link OpenSeadragon.Options} for details. */ -$.ImageLoader = function() { +$.ImageLoader = function( options ) { $.extend( true, this, { jobLimit: $.DEFAULT_SETTINGS.imageLoaderLimit, jobQueue: [], jobsInProgress: 0 - }); + }, options ); }; @@ -131,7 +133,7 @@ $.ImageLoader.prototype = /** @lends OpenSeadragon.ImageLoader.prototype */{ this.jobsInProgress++; } else { - this.jobQueue.push( newJob ); + this.jobQueue.push( newJob ); } }, @@ -160,10 +162,10 @@ function completeJob( loader, job, callback ) { if ( (!loader.jobLimit || loader.jobsInProgress < loader.jobLimit) && loader.jobQueue.length > 0) { nextJob = loader.jobQueue.shift(); nextJob.start(); + loader.jobsInProgress++; } callback( job.image ); } }( OpenSeadragon )); - diff --git a/src/viewer.js b/src/viewer.js index 00108538..f6650203 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -436,7 +436,9 @@ $.Viewer = function( options ) { this.viewport.setHomeBounds(this.world.getHomeBounds(), this.world.getContentFactor()); // Create the image loader - this.imageLoader = new $.ImageLoader(); + this.imageLoader = new $.ImageLoader({ + jobLimit: this.imageLoaderLimit + }); // Create the tile cache this.tileCache = new $.TileCache({