[=] Wrap fix for #555

1. Fix for horizontal and vertical wrap. Problem was in
`getTileAtPoint`: it was working only for points inside viewer - thanks
to @avandecreme for finding this.
2. Was small bug in not rendering top row and left column - after scroll
there are empty space and need some time for rendering.
This commit is contained in:
VoidVolker 2016-07-29 01:33:48 +03:00
parent a4d97e1929
commit 2bcc1aa0f4
2 changed files with 11 additions and 5 deletions

View File

@ -967,10 +967,14 @@ function updateLevel( tiledImage, haveDrawn, drawLevel, level, levelOpacity, lev
resetCoverage( tiledImage.coverage, level );
if ( !tiledImage.wrapHorizontal ) {
if ( tiledImage.wrapHorizontal ) {
tileTL.x -= 1; // left invisible column (othervise we will have empty space after scroll at left)
} else {
tileBR.x = Math.min( tileBR.x, numberOfTiles.x - 1 );
}
if ( !tiledImage.wrapVertical ) {
if ( tiledImage.wrapVertical ) {
tileTL.y -= 1; // top invisible row (othervise we will have empty space after scroll at top)
} else {
tileBR.y = Math.min( tileBR.y, numberOfTiles.y - 1 );
}

View File

@ -345,9 +345,11 @@ $.TileSource.prototype = {
* @param {OpenSeadragon.Point} point
*/
getTileAtPoint: function( level, point ) {
var pixel = point.times( this.dimensions.x ).times( this.getLevelScale(level) ),
tx = Math.floor( pixel.x / this.getTileWidth(level) ),
ty = Math.floor( pixel.y / this.getTileHeight(level) );
var levelScale = this.getLevelScale( level ),
numTiles = this.getNumTiles( level ),
pixel = point.times( this.dimensions.x * levelScale ),
tx = Math.floor( (pixel.x * numTiles.x) / (this.dimensions.x * levelScale) ),
ty = Math.floor( (pixel.y * numTiles.y) / (this.dimensions.y * levelScale) );
return new $.Point( tx, ty );
},