mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-23 20:55:47 +00:00
Update elements_parser.js
Changed Resolvegradient function for fill and stroke
This commit is contained in:
parent
145bf6e461
commit
77911424ce
1 changed files with 7 additions and 5 deletions
|
|
@ -43,7 +43,8 @@ fabric.ElementsParser.prototype._createObject = function(klass, el, index) {
|
|||
}
|
||||
else {
|
||||
var obj = klass.fromElement(el, this.options);
|
||||
this.resolveGradient(obj);
|
||||
this.resolveGradient(obj,'fill');
|
||||
this.resolveGradient(obj,'stroke');
|
||||
this.reviver && this.reviver(el, obj);
|
||||
this.instances[index] = obj;
|
||||
this.checkIfDone();
|
||||
|
|
@ -53,22 +54,23 @@ fabric.ElementsParser.prototype._createObject = function(klass, el, index) {
|
|||
fabric.ElementsParser.prototype.createCallback = function(index, el) {
|
||||
var _this = this;
|
||||
return function(obj) {
|
||||
_this.resolveGradient(obj);
|
||||
_this.resolveGradient(obj,'fill');
|
||||
_this.resolveGradient(obj,'stroke');
|
||||
_this.reviver && _this.reviver(el, obj);
|
||||
_this.instances[index] = obj;
|
||||
_this.checkIfDone();
|
||||
};
|
||||
};
|
||||
|
||||
fabric.ElementsParser.prototype.resolveGradient = function(obj) {
|
||||
fabric.ElementsParser.prototype.resolveGradient = function(obj,property) {
|
||||
|
||||
var instanceFillValue = obj.get('fill');
|
||||
var instanceFillValue = obj.get(property);
|
||||
if (!(/^url\(/).test(instanceFillValue)) {
|
||||
return;
|
||||
}
|
||||
var gradientId = instanceFillValue.slice(5, instanceFillValue.length - 1);
|
||||
if (fabric.gradientDefs[gradientId]) {
|
||||
obj.set('fill',
|
||||
obj.set(property,
|
||||
fabric.Gradient.fromElement(fabric.gradientDefs[gradientId], obj));
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue