World.getHomeBounds()

This commit is contained in:
Ian Gilman 2014-08-12 16:04:55 -07:00
parent 45b7118732
commit 2ee59635fa
2 changed files with 30 additions and 4 deletions

View File

@ -151,6 +151,10 @@ $.TiledImage.prototype = /** @lends OpenSeadragon.TiledImage.prototype */{
*/ */
destroy: function() { destroy: function() {
this.reset(); this.reset();
},
getWorldBounds: function() {
return new $.Rect( this._worldX, this._worldY, this._worldWidth, this._worldHeight );
} }
}; };

View File

@ -146,24 +146,46 @@ $.World.prototype = /** @lends OpenSeadragon.World.prototype */{
}, },
resetTiles: function() { resetTiles: function() {
for (var i = 0; i < this._items.length; i++ ) { for ( var i = 0; i < this._items.length; i++ ) {
this._items[i].reset(); this._items[i].reset();
} }
}, },
update: function() { update: function() {
for (var i = 0; i < this._items.length; i++ ) { for ( var i = 0; i < this._items.length; i++ ) {
this._items[i].update(); this._items[i].update();
} }
}, },
needsUpdate: function() { needsUpdate: function() {
for (var i = 0; i < this._items.length; i++ ) { for ( var i = 0; i < this._items.length; i++ ) {
if (this._items[i].needsUpdate()) { if ( this._items[i].needsUpdate() ) {
return true; return true;
} }
} }
return false; return false;
},
getHomeBounds: function() {
if ( !this._items.length ) {
return new $.Rect(0, 0, 1, 1);
}
var bounds = this._items[0].getWorldBounds();
var left = bounds.x;
var top = bounds.y;
var right = bounds.x + bounds.width;
var bottom = bounds.y + bounds.height;
var box;
for ( var i = 1; i < this._items.length; i++ ) {
box = this._items[i].getWorldBounds();
left = Math.min( left, box.x );
top = Math.min( top, box.y );
right = Math.max( right, box.x + box.width );
bottom = Math.max( bottom, box.y + box.height );
}
return new $.Rect( left, top, right - left, bottom - top );
} }
}; };