Merge pull request #735 from LarissaSmith/master

Optimized adding large numbers of items to the world.
This commit is contained in:
Ian Gilman 2015-10-08 09:17:57 -07:00
commit c586d6ca35
2 changed files with 30 additions and 10 deletions

View File

@ -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) {

View File

@ -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);