mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-29 08:36:10 +03:00
Merge pull request #1198 from openseadragon/ig-closest
Improved best first level calculation
This commit is contained in:
commit
e4771234a2
@ -978,7 +978,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
|
|||||||
var targetZeroRatio = viewport.deltaPixelsFromPointsNoRotate(
|
var targetZeroRatio = viewport.deltaPixelsFromPointsNoRotate(
|
||||||
this.source.getPixelRatio(
|
this.source.getPixelRatio(
|
||||||
Math.max(
|
Math.max(
|
||||||
this.source.getClosestLevel(viewport.containerSize) - 1,
|
this.source.getClosestLevel(),
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
@ -320,25 +320,20 @@ $.TileSource.prototype = {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
* @param {Rect} rect
|
* @returns {Number} The highest level in this tile source that can be contained in a single tile.
|
||||||
*/
|
*/
|
||||||
getClosestLevel: function( rect ) {
|
getClosestLevel: function() {
|
||||||
var i,
|
var i,
|
||||||
tilesPerSide,
|
|
||||||
tiles;
|
tiles;
|
||||||
|
|
||||||
for( i = this.minLevel; i < this.maxLevel; i++ ){
|
for (i = this.minLevel + 1; i <= this.maxLevel; i++){
|
||||||
tiles = this.getNumTiles( i );
|
tiles = this.getNumTiles(i);
|
||||||
tilesPerSide = new $.Point(
|
if (tiles.x > 1 || tiles.y > 1) {
|
||||||
Math.floor( rect.x / this.getTileWidth(i) ),
|
|
||||||
Math.floor( rect.y / this.getTileHeight(i) )
|
|
||||||
);
|
|
||||||
|
|
||||||
if( tiles.x + 1 >= tilesPerSide.x && tiles.y + 1 >= tilesPerSide.y ){
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Math.max( 0, i - 1 );
|
|
||||||
|
return i - 1;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user