mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-01-19 17:21:50 +03:00
Added autoRefigureSizes flag for disabling calls to _figureSizes during bounds-change event handlers. This improves performance when a lot of bounds-change events are fired in quick succession. Used flag to optimize world._arrange.
This commit is contained in:
parent
7076d64b1b
commit
24be6a52ed
18
src/world.js
18
src/world.js
@ -52,8 +52,11 @@ $.World = function( options ) {
|
||||
this.viewer = options.viewer;
|
||||
this._items = [];
|
||||
this._needsDraw = false;
|
||||
this._autoRefigureSizes = true;
|
||||
this._delegatedFigureSizes = function(event) {
|
||||
if (this._autoRefigureSizes) {
|
||||
_this._figureSizes();
|
||||
}
|
||||
};
|
||||
|
||||
this._figureSizes();
|
||||
@ -275,6 +278,17 @@ $.extend( $.World.prototype, $.EventSource.prototype, /** @lends OpenSeadragon.W
|
||||
return this._contentFactor;
|
||||
},
|
||||
|
||||
/**
|
||||
* As a performance optimization, setting this flag to false allows the bounds-change event handler
|
||||
* on tiledImages to skip calls to _figureSizes. If a lot of images are going to be positioned in
|
||||
* rapid succession, this is a good idea. _figuresSizes only needs to be called once when the
|
||||
* positioning is done.
|
||||
* @param {Boolean} [value] The value to which to set autoRefigureSizes.
|
||||
*/
|
||||
setAutoRefigureSizes: function(value) {
|
||||
this._autoRefigureSizes = value;
|
||||
},
|
||||
|
||||
/**
|
||||
* Arranges all of the TiledImages with the specified settings.
|
||||
* @param {Object} options - Specifies how to arrange.
|
||||
@ -304,6 +318,8 @@ $.extend( $.World.prototype, $.EventSource.prototype, /** @lends OpenSeadragon.W
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
var item, box, width, height, position;
|
||||
|
||||
this.setAutoRefigureSizes(false);
|
||||
for (var i = 0; i < this._items.length; i++) {
|
||||
if (i && (i % wrap) === 0) {
|
||||
if (layout === 'horizontal') {
|
||||
@ -336,6 +352,8 @@ $.extend( $.World.prototype, $.EventSource.prototype, /** @lends OpenSeadragon.W
|
||||
y += increment;
|
||||
}
|
||||
}
|
||||
this.setAutoRefigureSizes(true);
|
||||
this._figureSizes();
|
||||
},
|
||||
|
||||
// private
|
||||
|
Loading…
x
Reference in New Issue
Block a user