From 3e5609244530943da9a7ae559950affa4f7628fc Mon Sep 17 00:00:00 2001 From: Antoine Vandecreme Date: Tue, 26 Jan 2016 15:59:10 -0500 Subject: [PATCH] Fix tests. --- src/tile.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/tile.js b/src/tile.js index 4adb7a1d..f8861cd7 100644 --- a/src/tile.js +++ b/src/tile.js @@ -351,10 +351,13 @@ $.Tile.prototype = /** @lends OpenSeadragon.Tile.prototype */{ * @return {OpenSeadragon.Point} */ getTranslationForEdgeSmoothing: function(scale, canvasSize, sketchCanvasSize) { - var sketchCanvasDelta = new $.Point( - Math.ceil((sketchCanvasSize.x - canvasSize.x) / 2), - Math.ceil((sketchCanvasSize.y - canvasSize.y) / 2)); - return sketchCanvasDelta.minus( + // The translation vector must have positive values, otherwise the image goes a bit off + // the sketch canvas to the top and left and we must use negative coordinates to repaint it + // to the main canvas. In that case, some browsers throw: + // INDEX_SIZE_ERR: DOM Exception 1: Index or size was negative, or greater than the allowed value. + var x = Math.max(1, Math.ceil((sketchCanvasSize.x - canvasSize.x) / 2)); + var y = Math.max(1, Math.ceil((sketchCanvasSize.y - canvasSize.y) / 2)); + return new $.Point(x, y).minus( this.position .times($.pixelDensityRatio) .times(scale || 1)