mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 14:46:10 +03:00
Add job queue full event.
This commit is contained in:
parent
e0f442209b
commit
cdb89ff5ad
@ -198,6 +198,7 @@ $.ImageLoader.prototype = {
|
|||||||
* requests.
|
* requests.
|
||||||
* @param {Function} [options.callback] - Called once image has been downloaded.
|
* @param {Function} [options.callback] - Called once image has been downloaded.
|
||||||
* @param {Function} [options.abort] - Called when this image job is aborted.
|
* @param {Function} [options.abort] - Called when this image job is aborted.
|
||||||
|
* @returns {boolean} true if job was immediatelly started, false if queued
|
||||||
*/
|
*/
|
||||||
addJob: function(options) {
|
addJob: function(options) {
|
||||||
if (!options.source) {
|
if (!options.source) {
|
||||||
@ -229,10 +230,10 @@ $.ImageLoader.prototype = {
|
|||||||
if ( !this.jobLimit || this.jobsInProgress < this.jobLimit ) {
|
if ( !this.jobLimit || this.jobsInProgress < this.jobLimit ) {
|
||||||
newJob.start();
|
newJob.start();
|
||||||
this.jobsInProgress++;
|
this.jobsInProgress++;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
this.jobQueue.push( newJob );
|
this.jobQueue.push( newJob );
|
||||||
}
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2042,7 +2042,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
|
|||||||
var _this = this;
|
var _this = this;
|
||||||
tile.loading = true;
|
tile.loading = true;
|
||||||
tile.tiledImage = this;
|
tile.tiledImage = this;
|
||||||
this._imageLoader.addJob({
|
if (!this._imageLoader.addJob({
|
||||||
src: tile.getUrl(),
|
src: tile.getUrl(),
|
||||||
tile: tile,
|
tile: tile,
|
||||||
source: this.source,
|
source: this.source,
|
||||||
@ -2057,7 +2057,23 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
|
|||||||
abort: function() {
|
abort: function() {
|
||||||
tile.loading = false;
|
tile.loading = false;
|
||||||
}
|
}
|
||||||
|
})) {
|
||||||
|
/**
|
||||||
|
* Triggered if tile load job was added to a full queue.
|
||||||
|
* This allows to react upon e.g. network not being able to serve the tiles fast enough.
|
||||||
|
* @event job-queue-full
|
||||||
|
* @memberof OpenSeadragon.Viewer
|
||||||
|
* @type {object}
|
||||||
|
* @property {OpenSeadragon.Tile} tile - The tile that failed to load.
|
||||||
|
* @property {OpenSeadragon.TiledImage} tiledImage - The tiled image the tile belongs to.
|
||||||
|
* @property {number} time - The time in milliseconds when the tile load began.
|
||||||
|
*/
|
||||||
|
this.viewer.raiseEvent("job-queue-full", {
|
||||||
|
tile: tile,
|
||||||
|
tiledImage: this,
|
||||||
|
time: time,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user