mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-28 16:16:08 +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._sequenceIndex = 0;
|
||||||
this._firstOpen = true;
|
this._firstOpen = true;
|
||||||
this._updateRequestId = null;
|
this._updateRequestId = null;
|
||||||
|
this._loadQueue = [];
|
||||||
this.currentOverlays = [];
|
this.currentOverlays = [];
|
||||||
|
|
||||||
//Inherit some behaviors and properties
|
//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, "[Viewer.addTiledImage] options is required");
|
||||||
$.console.assert(options.tileSource, "[Viewer.addTiledImage] options.tileSource is required");
|
$.console.assert(options.tileSource, "[Viewer.addTiledImage] options.tileSource is required");
|
||||||
|
|
||||||
var _this = this,
|
var _this = this;
|
||||||
tileSource = options.tileSource;
|
|
||||||
|
|
||||||
this._hideMessage();
|
this._hideMessage();
|
||||||
|
|
||||||
|
var myQueueItem = {
|
||||||
|
options: options
|
||||||
|
};
|
||||||
|
|
||||||
function raiseAddItemFailed( event ) {
|
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.
|
* Raised when an error occurs while adding a item.
|
||||||
* @event add-item-failed
|
* @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 ) {
|
if ( tileSource instanceof Array ) {
|
||||||
raiseAddItemFailed({
|
raiseAddItemFailed({
|
||||||
@ -1295,17 +1308,29 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
return;
|
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,
|
viewer: _this,
|
||||||
source: tileSource,
|
source: queueItem.tileSource,
|
||||||
viewport: _this.viewport,
|
viewport: _this.viewport,
|
||||||
drawer: _this.drawer,
|
drawer: _this.drawer,
|
||||||
tileCache: _this.tileCache,
|
tileCache: _this.tileCache,
|
||||||
imageLoader: _this.imageLoader,
|
imageLoader: _this.imageLoader,
|
||||||
x: options.x,
|
x: queueItem.options.x,
|
||||||
y: options.y,
|
y: queueItem.options.y,
|
||||||
width: options.width,
|
width: queueItem.options.width,
|
||||||
height: options.height,
|
height: queueItem.options.height,
|
||||||
imageLoaderLimit: _this.imageLoaderLimit,
|
imageLoaderLimit: _this.imageLoaderLimit,
|
||||||
minZoomImageRatio: _this.minZoomImageRatio,
|
minZoomImageRatio: _this.minZoomImageRatio,
|
||||||
wrapHorizontal: _this.wrapHorizontal,
|
wrapHorizontal: _this.wrapHorizontal,
|
||||||
@ -1319,7 +1344,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
});
|
});
|
||||||
|
|
||||||
_this.world.addItem( tiledImage, {
|
_this.world.addItem( tiledImage, {
|
||||||
index: options.index
|
index: queueItem.options.index
|
||||||
});
|
});
|
||||||
|
|
||||||
if (_this.collectionMode) {
|
if (_this.collectionMode) {
|
||||||
@ -1336,19 +1361,20 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_this.navigator) {
|
if (_this.navigator) {
|
||||||
var optionsClone = $.extend({}, options, {
|
optionsClone = $.extend({}, queueItem.options, {
|
||||||
originalTiledImage: tiledImage,
|
originalTiledImage: tiledImage,
|
||||||
tileSource: tileSource
|
tileSource: queueItem.tileSource
|
||||||
});
|
});
|
||||||
|
|
||||||
_this.navigator.addTiledImage(optionsClone);
|
_this.navigator.addTiledImage(optionsClone);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.success) {
|
if (queueItem.options.success) {
|
||||||
options.success({
|
queueItem.options.success({
|
||||||
item: tiledImage
|
item: tiledImage
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}, function( event ) {
|
}, function( event ) {
|
||||||
event.options = options;
|
event.options = options;
|
||||||
raiseAddItemFailed(event);
|
raiseAddItemFailed(event);
|
||||||
|
Loading…
Reference in New Issue
Block a user