-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix svg base markup #2364
Fix svg base markup #2364
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -266,6 +266,7 @@ | |
ctx.transform.apply(ctx, this.transformMatrix); | ||
} | ||
this.transform(ctx); | ||
this._setShadow(ctx); | ||
this.clipTo && fabric.util.clipContext(this, ctx); | ||
// the array is now sorted in order of highest first, so start from end | ||
for (var i = 0, len = this._objects.length; i < len; i++) { | ||
|
@@ -531,16 +532,19 @@ | |
* @return {String} svg representation of an instance | ||
*/ | ||
toSVG: function(reviver) { | ||
var markup = [ | ||
//jscs:disable validateIndentation | ||
'<g ', | ||
'transform="', this.getSvgTransform(), | ||
var markup = this._createBaseSVGMarkup(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we're using |
||
markup.push( | ||
'<g transform="', | ||
/* avoiding styles intentionally */ | ||
this.getSvgTransform(), | ||
this.getSvgTransformMatrix(), | ||
'" style="', | ||
this.getSvgFilter(), | ||
'">\n' | ||
//jscs:enable validateIndentation | ||
]; | ||
); | ||
|
||
for (var i = 0, len = this._objects.length; i < len; i++) { | ||
markup.push(this._objects[i].toSVG(reviver)); | ||
markup.push('\t', this._objects[i].toSVG(reviver)); | ||
} | ||
|
||
markup.push('</g>\n'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,17 +175,16 @@ | |
var objects = this.getObjects(), | ||
p = this.getPointByOrigin('left', 'top'), | ||
translatePart = 'translate(' + p.x + ' ' + p.y + ')', | ||
markup = [ | ||
//jscs:disable validateIndentation | ||
'<g ', | ||
'style="', this.getSvgStyles(), '" ', | ||
'transform="', this.getSvgTransformMatrix(), translatePart, this.getSvgTransform(), '" ', | ||
'>\n' | ||
//jscs:enable validateIndentation | ||
]; | ||
markup = this._createBaseSVGMarkup(); | ||
markup.push( | ||
'<g ', | ||
'style="', this.getSvgStyles(), '" ', | ||
'transform="', this.getSvgTransformMatrix(), translatePart, this.getSvgTransform(), '" ', | ||
'>\n' | ||
); | ||
|
||
for (var i = 0, len = objects.length; i < len; i++) { | ||
markup.push(objects[i].toSVG(reviver)); | ||
markup.push('\t', objects[i].toSVG(reviver)); | ||
} | ||
markup.push('</g>\n'); | ||
|
||
|
@@ -207,9 +206,14 @@ | |
* @return {Boolean} true if all paths are of the same color (`fill`) | ||
*/ | ||
isSameColor: function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed this function, but i'm more for deleting it or improve the patGroup._set method that as of now is useless. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that it's an ancient method that is hardly useful |
||
var firstPathFill = (this.getObjects()[0].get('fill') || '').toLowerCase(); | ||
var firstPathFill = this.getObjects()[0].get('fill') || ''; | ||
if (typeof firstPathFill !== 'string') { | ||
return false; | ||
} | ||
firstPathFill = firstPathFill.toLowerCase(); | ||
return this.getObjects().every(function(path) { | ||
return (path.get('fill') || '').toLowerCase() === firstPathFill; | ||
var pathFill = path.get('fill') || ''; | ||
return typeof pathFill === 'string' && (pathFill).toLowerCase() === firstPathFill; | ||
}); | ||
}, | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added shadow rendering for whole group.