diff --git a/src/button.js b/src/button.js index 09010322..0ddb919a 100644 --- a/src/button.js +++ b/src/button.js @@ -61,7 +61,7 @@ $.ButtonState = { * @memberof OpenSeadragon * @extends OpenSeadragon.EventSource * @param {Object} options - * @param {Element} [options.element=null] Element to use as the button. If not specified, an HTML <button> element is created. + * @param {Element} [options.element=null] Element to use as the button. If not specified, an HTML <div> element is created. * @param {String} [options.tooltip=null] Provides context help for the button when the * user hovers over it. * @param {String} [options.srcRest=null] URL of image to use in 'rest' state. diff --git a/src/tilesource.js b/src/tilesource.js index 271fca7d..f826ab48 100644 --- a/src/tilesource.js +++ b/src/tilesource.js @@ -356,6 +356,15 @@ $.TileSource.prototype = { var x = Math.floor(pixelX / this.getTileWidth(level)); var y = Math.floor(pixelY / this.getTileHeight(level)); + // When point.x == 1 or point.y == 1 / this.aspectRatio we want to + // return the last tile of the row/column + if (point.x >= 1) { + x = this.getNumTiles(level).x - 1; + } + if (point.y >= 1 / this.aspectRatio) { + y = this.getNumTiles(level).y - 1; + } + return new $.Point(x, y); }, diff --git a/test/modules/tilesource.js b/test/modules/tilesource.js index 71fb053d..21a9f30c 100644 --- a/test/modules/tilesource.js +++ b/test/modules/tilesource.js @@ -85,6 +85,17 @@ assertTileAtPoint(level, new OpenSeadragon.Point(0.5, 0.5), new OpenSeadragon.Point(0, 0)); assertTileAtPoint(level, new OpenSeadragon.Point(1, 10 / 15), new OpenSeadragon.Point(0, 0)); } + + // Test for issue #1113 + tileSource = new OpenSeadragon.TileSource({ + width: 1006, + height: 1009, + tileWidth: 1006, + tileHeight: 1009, + tileOverlap: 0, + maxLevel: 0, + }); + assertTileAtPoint(0, new OpenSeadragon.Point(1, 1009 / 1006), new OpenSeadragon.Point(0, 0)); }); }());