From 2bcc1aa0f4ed7aada2b0e417d4863b9d356e6445 Mon Sep 17 00:00:00 2001 From: VoidVolker Date: Fri, 29 Jul 2016 01:33:48 +0300 Subject: [PATCH 1/4] [=] 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. --- src/tiledimage.js | 8 ++++++-- src/tilesource.js | 8 +++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/tiledimage.js b/src/tiledimage.js index b45aa47a..e4749fbc 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -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 ); } diff --git a/src/tilesource.js b/src/tilesource.js index 48941848..213cf3bd 100644 --- a/src/tilesource.js +++ b/src/tilesource.js @@ -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 ); }, From ecebc3305f6636c661597449b84021dc385f81e9 Mon Sep 17 00:00:00 2001 From: VoidVolker Date: Fri, 29 Jul 2016 12:41:25 +0300 Subject: [PATCH 2/4] [=] Dropped useless calculations --- src/tilesource.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/tilesource.js b/src/tilesource.js index 213cf3bd..eb5aabc0 100644 --- a/src/tilesource.js +++ b/src/tilesource.js @@ -345,13 +345,11 @@ $.TileSource.prototype = { * @param {OpenSeadragon.Point} point */ getTileAtPoint: function( level, point ) { - 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 ); + var numTiles = this.getNumTiles( level ); + return new $.Point( + Math.floor( (point.x * numTiles.x) / 1 ), + Math.floor( (point.y * numTiles.y * this.dimensions.x) / this.dimensions.y ) + ); }, /** From eb799bdc709848f15cc08a65dfec7a12f0bb3990 Mon Sep 17 00:00:00 2001 From: VoidVolker Date: Fri, 29 Jul 2016 20:36:05 +0300 Subject: [PATCH 3/4] [=] fix for image source type image and in legacytilesource --- src/imagetilesource.js | 4 +--- src/legacytilesource.js | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/imagetilesource.js b/src/imagetilesource.js index f4ef5fa9..18059f87 100644 --- a/src/imagetilesource.js +++ b/src/imagetilesource.js @@ -171,9 +171,7 @@ * @param {Number} level * @param {OpenSeadragon.Point} point */ - getTileAtPoint: function (level, point) { - return new $.Point(0, 0); - }, + getTileAtPoint: $.TileSource.prototype.getTileAtPoint, /** * Retrieves a tile url * @function diff --git a/src/legacytilesource.js b/src/legacytilesource.js index b661b967..59732915 100644 --- a/src/legacytilesource.js +++ b/src/legacytilesource.js @@ -174,9 +174,7 @@ $.extend( $.LegacyTileSource.prototype, $.TileSource.prototype, /** @lends OpenS * @param {Number} level * @param {OpenSeadragon.Point} point */ - getTileAtPoint: function( level, point ) { - return new $.Point( 0, 0 ); - }, + getTileAtPoint: $.TileSource.prototype.getTileAtPoint, /** From 41c82c88a97e80d3a320458cf06e4d0a1a00f290 Mon Sep 17 00:00:00 2001 From: VoidVolker Date: Fri, 29 Jul 2016 20:45:57 +0300 Subject: [PATCH 4/4] [-] remove ref to getTileAtPoint - becasue this are subclass of TileSource --- src/imagetilesource.js | 6 ------ src/legacytilesource.js | 8 -------- 2 files changed, 14 deletions(-) diff --git a/src/imagetilesource.js b/src/imagetilesource.js index 18059f87..3562bf50 100644 --- a/src/imagetilesource.js +++ b/src/imagetilesource.js @@ -166,12 +166,6 @@ return new $.Point(0, 0); } }, - /** - * @function - * @param {Number} level - * @param {OpenSeadragon.Point} point - */ - getTileAtPoint: $.TileSource.prototype.getTileAtPoint, /** * Retrieves a tile url * @function diff --git a/src/legacytilesource.js b/src/legacytilesource.js index 59732915..04579034 100644 --- a/src/legacytilesource.js +++ b/src/legacytilesource.js @@ -169,14 +169,6 @@ $.extend( $.LegacyTileSource.prototype, $.TileSource.prototype, /** @lends OpenS } }, - /** - * @function - * @param {Number} level - * @param {OpenSeadragon.Point} point - */ - getTileAtPoint: $.TileSource.prototype.getTileAtPoint, - - /** * This method is not implemented by this class other than to throw an Error * announcing you have to implement it. Because of the variety of tile