diff --git a/src/viewer.js b/src/viewer.js index 215f14f8..af54b5f1 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -1250,6 +1250,10 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, } } + if (_this._loadQueue.length === 0) { + refreshWorld(myQueueItem); + } + /** * Raised when an error occurs while adding a item. * @event add-item-failed @@ -1268,6 +1272,20 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, } } + function refreshWorld(theItem) { + if (_this.collectionMode) { + _this.world.arrange({ + immediately: theItem.options.collectionImmediately, + rows: _this.collectionRows, + columns: _this.collectionColumns, + layout: _this.collectionLayout, + tileSize: _this.collectionTileSize, + tileMargin: _this.collectionTileMargin + }); + _this.world.setAutoRefigureSizes(true); + } + } + this._loadQueue.push(myQueueItem); getTileSourceImplementation( this, options.tileSource, function( tileSource ) { @@ -1328,19 +1346,16 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, debugMode: _this.debugMode }); + if (_this.collectionMode) { + _this.world.setAutoRefigureSizes(false); + } _this.world.addItem( tiledImage, { index: queueItem.options.index }); - if (_this.collectionMode) { - _this.world.arrange({ - immediately: queueItem.options.collectionImmediately, - rows: _this.collectionRows, - columns: _this.collectionColumns, - layout: _this.collectionLayout, - tileSize: _this.collectionTileSize, - tileMargin: _this.collectionTileMargin - }); + if (_this._loadQueue.length === 0) { + //this restores the autoRefigureSizes flag to true. + refreshWorld(queueItem); } if (_this.world.getItemCount() === 1 && !_this.preserveViewport) { diff --git a/src/world.js b/src/world.js index 0c0502aa..5597f0f8 100644 --- a/src/world.js +++ b/src/world.js @@ -85,7 +85,12 @@ $.extend( $.World.prototype, $.EventSource.prototype, /** @lends OpenSeadragon.W this._items.push( item ); } - this._figureSizes(); + if (this._autoRefigureSizes) { + this._figureSizes(); + } else { + this._needsSizesFigured = true; + } + this._needsDraw = true; item.addHandler('bounds-change', this._delegatedFigureSizes);