From d71ceebd726b169237e4d259aab3ddcca888c6a3 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Thu, 15 Jun 2017 17:28:04 -0700 Subject: [PATCH] Fixed issue with transparent images disappearing on Safari --- src/drawer.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/drawer.js b/src/drawer.js index 4485da98..eed97719 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -426,22 +426,22 @@ $.Drawer.prototype = { this.context.globalCompositeOperation = compositeOperation; } if (bounds) { - // Internet Explorer and Microsoft Edge throw IndexSizeError + // Internet Explorer, Microsoft Edge, and Safari have problems // when you call context.drawImage with negative x or y - // or width or height greater than the canvas width or height respectively + // or x + width or y + height greater than the canvas width or height respectively. if (bounds.x < 0) { bounds.width += bounds.x; bounds.x = 0; } - if (bounds.width > this.canvas.width) { - bounds.width = this.canvas.width; + if (bounds.x + bounds.width > this.canvas.width) { + bounds.width = this.canvas.width - bounds.x; } if (bounds.y < 0) { bounds.height += bounds.y; bounds.y = 0; } - if (bounds.height > this.canvas.height) { - bounds.height = this.canvas.height; + if (bounds.y + bounds.height > this.canvas.height) { + bounds.height = this.canvas.height - bounds.y; } this.context.drawImage(