mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 14:46:10 +03:00
World.getHomeBounds()
This commit is contained in:
parent
45b7118732
commit
2ee59635fa
@ -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 );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
30
src/world.js
30
src/world.js
@ -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 );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user