Merge branch 'ig-closest' into ig-both

This commit is contained in:
Ian Gilman 2017-05-17 09:41:58 -07:00
commit f0809e4a4d
2 changed files with 4 additions and 11 deletions

View File

@ -980,7 +980,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
) )
), ),

View File

@ -320,21 +320,14 @@ $.TileSource.prototype = {
/** /**
* @function * @function
* @param {Rect} rect
*/ */
getClosestLevel: function( rect ) { getClosestLevel: function() {
var i, var i,
tilesPerSide,
tiles; tiles;
for( i = this.minLevel; i < this.maxLevel; i++ ){ for( i = this.minLevel; 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;
} }
} }