From 4be589019c9e8304d3b416c43891bf0a814667be Mon Sep 17 00:00:00 2001 From: kangax Date: Thu, 4 Apr 2013 12:56:22 +0200 Subject: [PATCH] Fix positioning of line and image instances when part of a group --- src/image.class.js | 4 +++- src/line.class.js | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/image.class.js b/src/image.class.js index 59e30147..393d3f83 100644 --- a/src/image.class.js +++ b/src/image.class.js @@ -96,8 +96,10 @@ ctx.save(); var m = this.transformMatrix; + var isInPathGroup = this.group && this.group.type !== 'group'; + // this._resetWidthHeight(); - if (this.group) { + if (isInPathGroup) { ctx.translate(-this.group.width/2 + this.width/2, -this.group.height/2 + this.height/2); } if (m) { diff --git a/src/line.class.js b/src/line.class.js index cd2aea3d..282d22b8 100644 --- a/src/line.class.js +++ b/src/line.class.js @@ -86,7 +86,8 @@ _render: function(ctx) { ctx.beginPath(); - if (this.group) { + var isInPathGroup = this.group && this.group.type !== 'group'; + if (isInPathGroup) { ctx.translate(-this.group.width/2 + this.left, -this.group.height / 2 + this.top); } @@ -193,4 +194,4 @@ return new fabric.Line(points, object); }; -})(typeof exports !== 'undefined' ? exports : this); \ No newline at end of file +})(typeof exports !== 'undefined' ? exports : this);