From e17fe9ddef4febe34eb826fff9df017ac586fce5 Mon Sep 17 00:00:00 2001 From: kangax Date: Thu, 7 Jun 2012 16:23:35 +0200 Subject: [PATCH] Prevent error in `fabric.Object#toDataURL` when called before `setCoords`. --- src/object.class.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/object.class.js b/src/object.class.js index 6ef6c6ef..5d47543b 100644 --- a/src/object.class.js +++ b/src/object.class.js @@ -562,7 +562,7 @@ return this; }, - + /** * Returns width of an object's bounding rectangle * @method getBoundingRectWidth @@ -583,10 +583,10 @@ getBoundingRectHeight: function() { var yCoords = [this.oCoords.tl.y, this.oCoords.tr.y, this.oCoords.br.y, this.oCoords.bl.y]; var minY = fabric.util.array.min(yCoords); - var maxY = fabric.util.array.max(yCoords); + var maxY = fabric.util.array.max(yCoords); return Math.abs(minY - maxY); - }, - + }, + /** * Draws borders of an object's bounding box. * Requires public properties: width, height @@ -789,7 +789,8 @@ G_vmlCanvasManager.initElement(el); } - el.width = this.getBoundingRectWidth(); + this.setCoords(); + el.width = this.getBoundingRectWidth(); el.height = this.getBoundingRectHeight(); fabric.util.wrapElement(el, 'div');