From 0bb8a131a6e386a1a73ce4b7f579b8cfb14f83f1 Mon Sep 17 00:00:00 2001 From: Stefan Hayden Date: Thu, 28 Sep 2017 22:28:08 -0400 Subject: [PATCH] fixes problems with isTargetTransparent trageting. also nulls out cachedCanvas when not being used to make it easier to check if a proper cachedCanvas exists (#4356) --- src/canvas.class.js | 7 ++++--- src/shapes/object.class.js | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/canvas.class.js b/src/canvas.class.js index 83c00018..467d668b 100644 --- a/src/canvas.class.js +++ b/src/canvas.class.js @@ -483,9 +483,10 @@ var ctx = this.contextCache, originalColor = target.selectionBackgroundColor; - target.hasBorders = target.transparentCorners = false; target.selectionBackgroundColor = ''; + this.clearContext(ctx); + ctx.save(); ctx.transform.apply(ctx, this.viewportTransform); target.render(ctx); @@ -494,6 +495,8 @@ target === this._activeObject && target._renderControls(ctx, { hasBorders: false, transparentCorners: false + }, { + hasBorders: false, }); target.selectionBackgroundColor = originalColor; @@ -501,8 +504,6 @@ var isTransparent = fabric.util.isTransparent( ctx, x, y, this.targetFindTolerance); - this.clearContext(ctx); - return isTransparent; }, diff --git a/src/shapes/object.class.js b/src/shapes/object.class.js index 44db2282..cea622a6 100644 --- a/src/shapes/object.class.js +++ b/src/shapes/object.class.js @@ -986,6 +986,7 @@ this.drawCacheOnCanvas(ctx); } else { + this._cacheCanvas = null; this.dirty = false; this.drawObject(ctx); if (this.objectCaching && this.statefullCache) {