mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 05:06:09 +03:00
Refactored code to take into account optimization suggestions (https://github.com/openseadragon/openseadragon/pull/2337#discussion_r1170931340)
This commit is contained in:
parent
0c358c140d
commit
877c3b68ed
@ -354,24 +354,27 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, /** @lends OpenSea
|
||||
*/
|
||||
getLevelSize: function( level ) {
|
||||
|
||||
var numLevels = this.maxLevel - this.minLevel;
|
||||
// Need to take into account that the list may or may not include the full resolution size
|
||||
if( this.sizes && ((this.sizes.length === numLevels) ||
|
||||
(this.sizes.length === numLevels + 1)) ) {
|
||||
var levelWidth, levelHeight;
|
||||
if( this.sizes.length === numLevels ) {
|
||||
levelWidth = (level === this.sizes.length) ? this.width : this.sizes[level].width;
|
||||
levelHeight = (level === this.sizes.length) ? this.height : this.sizes[level].height;
|
||||
}
|
||||
else {
|
||||
levelWidth = this.sizes[level].width;
|
||||
levelHeight = this.sizes[level].height;
|
||||
}
|
||||
return { width: levelWidth, height: levelHeight };
|
||||
}
|
||||
else {
|
||||
if (!this.sizes) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var levelWidth, levelHeight;
|
||||
var numLevels = this.maxLevel - this.minLevel;
|
||||
var sizeLength = this.sizes.length;
|
||||
|
||||
// Need to take into account that the list may or may not include the full resolution size
|
||||
if (sizeLength === numLevels) {
|
||||
levelWidth = (level === sizeLength) ? this.width : this.sizes[level].width;
|
||||
levelHeight = (level === sizeLength) ? this.height : this.sizes[level].height;
|
||||
} else if ( sizeLength === numLevels + 1 ) {
|
||||
levelWidth = this.sizes[level].width;
|
||||
levelHeight = this.sizes[level].height;
|
||||
} else {
|
||||
// Sizes field doesn't contain resolution level sizes, so discard
|
||||
return null;
|
||||
}
|
||||
|
||||
return {width: levelWidth, height: levelHeight};
|
||||
},
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user