mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-24 22:26:10 +03:00
Items added with addTiledImage are now added in correct sequence
This commit is contained in:
parent
7359dbe8ae
commit
b7c78812c5
@ -207,6 +207,7 @@ $.Viewer = function( options ) {
|
||||
this._sequenceIndex = 0;
|
||||
this._firstOpen = true;
|
||||
this._updateRequestId = null;
|
||||
this._loadQueue = [];
|
||||
this.currentOverlays = [];
|
||||
|
||||
//Inherit some behaviors and properties
|
||||
@ -1260,12 +1261,22 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
||||
$.console.assert(options, "[Viewer.addTiledImage] options is required");
|
||||
$.console.assert(options.tileSource, "[Viewer.addTiledImage] options.tileSource is required");
|
||||
|
||||
var _this = this,
|
||||
tileSource = options.tileSource;
|
||||
var _this = this;
|
||||
|
||||
this._hideMessage();
|
||||
|
||||
var myQueueItem = {
|
||||
options: options
|
||||
};
|
||||
|
||||
function raiseAddItemFailed( event ) {
|
||||
for (var i = 0; i < _this._loadQueue; i++) {
|
||||
if (_this._loadQueue[i] === myQueueItem) {
|
||||
_this._loadQueue.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Raised when an error occurs while adding a item.
|
||||
* @event add-item-failed
|
||||
@ -1284,7 +1295,9 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
||||
}
|
||||
}
|
||||
|
||||
getTileSourceImplementation( this, tileSource, function( tileSource ) {
|
||||
this._loadQueue.push(myQueueItem);
|
||||
|
||||
getTileSourceImplementation( this, options.tileSource, function( tileSource ) {
|
||||
|
||||
if ( tileSource instanceof Array ) {
|
||||
raiseAddItemFailed({
|
||||
@ -1295,17 +1308,29 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
||||
return;
|
||||
}
|
||||
|
||||
var tiledImage = new $.TiledImage({
|
||||
myQueueItem.tileSource = tileSource;
|
||||
|
||||
// add everybody at the front of the queue that's ready to go
|
||||
var queueItem, tiledImage, optionsClone;
|
||||
while (_this._loadQueue.length) {
|
||||
queueItem = _this._loadQueue[0];
|
||||
if (!queueItem.tileSource) {
|
||||
break;
|
||||
}
|
||||
|
||||
_this._loadQueue.splice(0, 1);
|
||||
|
||||
tiledImage = new $.TiledImage({
|
||||
viewer: _this,
|
||||
source: tileSource,
|
||||
source: queueItem.tileSource,
|
||||
viewport: _this.viewport,
|
||||
drawer: _this.drawer,
|
||||
tileCache: _this.tileCache,
|
||||
imageLoader: _this.imageLoader,
|
||||
x: options.x,
|
||||
y: options.y,
|
||||
width: options.width,
|
||||
height: options.height,
|
||||
x: queueItem.options.x,
|
||||
y: queueItem.options.y,
|
||||
width: queueItem.options.width,
|
||||
height: queueItem.options.height,
|
||||
imageLoaderLimit: _this.imageLoaderLimit,
|
||||
minZoomImageRatio: _this.minZoomImageRatio,
|
||||
wrapHorizontal: _this.wrapHorizontal,
|
||||
@ -1319,7 +1344,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
||||
});
|
||||
|
||||
_this.world.addItem( tiledImage, {
|
||||
index: options.index
|
||||
index: queueItem.options.index
|
||||
});
|
||||
|
||||
if (_this.collectionMode) {
|
||||
@ -1336,19 +1361,20 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
||||
}
|
||||
|
||||
if (_this.navigator) {
|
||||
var optionsClone = $.extend({}, options, {
|
||||
optionsClone = $.extend({}, queueItem.options, {
|
||||
originalTiledImage: tiledImage,
|
||||
tileSource: tileSource
|
||||
tileSource: queueItem.tileSource
|
||||
});
|
||||
|
||||
_this.navigator.addTiledImage(optionsClone);
|
||||
}
|
||||
|
||||
if (options.success) {
|
||||
options.success({
|
||||
if (queueItem.options.success) {
|
||||
queueItem.options.success({
|
||||
item: tiledImage
|
||||
});
|
||||
}
|
||||
}
|
||||
}, function( event ) {
|
||||
event.options = options;
|
||||
raiseAddItemFailed(event);
|
||||
|
Loading…
Reference in New Issue
Block a user