From 28784dc9b3992a0763c5831b79f40888fa81f241 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 13 Sep 2014 13:14:58 +0200 Subject: [PATCH] Update path.class.js Like any other shape in fabric, when exported to svg, the shape has to be translated around origin. This additional translation brings it there. Fixes svg export of paths OUTSIDE of path-gropus. Inside was already ok. --- src/shapes/path.class.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/shapes/path.class.js b/src/shapes/path.class.js index cd38075d..65c9da12 100644 --- a/src/shapes/path.class.js +++ b/src/shapes/path.class.js @@ -537,19 +537,21 @@ */ toSVG: function(reviver) { var chunks = [], - markup = this._createBaseSVGMarkup(); + markup = this._createBaseSVGMarkup(), addTransform = ''; for (var i = 0, len = this.path.length; i < len; i++) { chunks.push(this.path[i].join(' ')); } var path = chunks.join(' '); - + if (!(this.group && this.group.type == 'path-group')) { + addTransform = 'translate(' + (-this.width / 2) + ', ' + (-this.height / 2) + ')'; + } markup.push( //jscs:disable validateIndentation '\n' //jscs:enable validateIndentation