From 7ba516b30aa2db16e070cec76967110488d784b7 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Tue, 27 Mar 2018 09:48:18 -0700 Subject: [PATCH 1/2] Fixed issue with square tile code on IE --- src/tilesource.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/tilesource.js b/src/tilesource.js index be5c1d5e..cc48aeec 100644 --- a/src/tilesource.js +++ b/src/tilesource.js @@ -392,9 +392,7 @@ $.TileSource.prototype = { sy = Math.min( sy, dimensionsScaled.y - py ); if (isSource) { - scale = 1; - px = 0; - py = 0; + return new $.Rect(0, 0, Math.floor(sx), Math.floor(sy)); } return new $.Rect( px * scale, py * scale, sx * scale, sy * scale ); From 02a397638c7cb5a3a8485ab6f759d265bf4c4822 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Mon, 2 Apr 2018 11:09:23 -0700 Subject: [PATCH 2/2] Fixed test errors --- src/tile.js | 17 +++++++++++------ src/tilesource.js | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/tile.js b/src/tile.js index 0cc836f0..de1eb40d 100644 --- a/src/tile.js +++ b/src/tile.js @@ -367,16 +367,21 @@ $.Tile.prototype = { // changes as we are rendering the image drawingHandler({context: context, tile: this, rendered: rendered}); - if (!this.sourceBounds) { // Just in case - this.sourceBounds = new $.Rect(0, 0, rendered.canvas.width, rendered.canvas.height); + var sourceWidth, sourceHeight; + if (this.sourceBounds) { + sourceWidth = Math.min(this.sourceBounds.width, rendered.canvas.width); + sourceHeight = Math.min(this.sourceBounds.height, rendered.canvas.height); + } else { + sourceWidth = rendered.canvas.width; + sourceHeight = rendered.canvas.height; } context.drawImage( rendered.canvas, - this.sourceBounds.x, - this.sourceBounds.y, - this.sourceBounds.width, - this.sourceBounds.height, + 0, + 0, + sourceWidth, + sourceHeight, position.x, position.y, size.x, diff --git a/src/tilesource.js b/src/tilesource.js index cc48aeec..a5b3897b 100644 --- a/src/tilesource.js +++ b/src/tilesource.js @@ -392,7 +392,7 @@ $.TileSource.prototype = { sy = Math.min( sy, dimensionsScaled.y - py ); if (isSource) { - return new $.Rect(0, 0, Math.floor(sx), Math.floor(sy)); + return new $.Rect(0, 0, sx, sy); } return new $.Rect( px * scale, py * scale, sx * scale, sy * scale );