mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-01-19 17:21:50 +03:00
Merge pull request #735 from LarissaSmith/master
Optimized adding large numbers of items to the world.
This commit is contained in:
commit
c586d6ca35
@ -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) {
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user