mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 14:46:10 +03:00
Merge pull request #715 from LarissaSmith/master
Added autoRefigureSizes flag for disabling calls to _figureSizes …
This commit is contained in:
commit
4ac34b1190
24
src/world.js
24
src/world.js
@ -52,8 +52,14 @@ $.World = function( options ) {
|
||||
this.viewer = options.viewer;
|
||||
this._items = [];
|
||||
this._needsDraw = false;
|
||||
this._autoRefigureSizes = true;
|
||||
this._needsSizesFigured = false;
|
||||
this._delegatedFigureSizes = function(event) {
|
||||
if (_this._autoRefigureSizes) {
|
||||
_this._figureSizes();
|
||||
} else {
|
||||
_this._needsSizesFigured = true;
|
||||
}
|
||||
};
|
||||
|
||||
this._figureSizes();
|
||||
@ -275,6 +281,21 @@ $.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 calculations on the world bounds. If a lot of images are going to be positioned in
|
||||
* rapid succession, this is a good idea. When finished, setAutoRefigureSizes should be called with true
|
||||
* or the system may behave oddly.
|
||||
* @param {Boolean} [value] The value to which to set the flag.
|
||||
*/
|
||||
setAutoRefigureSizes: function(value) {
|
||||
this._autoRefigureSizes = value;
|
||||
if (value & this._needsSizesFigured) {
|
||||
this._figureSizes();
|
||||
this._needsSizesFigured = false;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Arranges all of the TiledImages with the specified settings.
|
||||
* @param {Object} options - Specifies how to arrange.
|
||||
@ -304,6 +325,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 +359,7 @@ $.extend( $.World.prototype, $.EventSource.prototype, /** @lends OpenSeadragon.W
|
||||
y += increment;
|
||||
}
|
||||
}
|
||||
this.setAutoRefigureSizes(true);
|
||||
},
|
||||
|
||||
// private
|
||||
|
Loading…
Reference in New Issue
Block a user