mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-22 07:19:57 -05:00
Only change style and notify item of change if it differs from current one.
This commit is contained in:
parent
1279e820aa
commit
a59fab0409
1 changed files with 9 additions and 1 deletions
|
@ -55,11 +55,19 @@ var PathStyle = this.PathStyle = Base.extend(new function() {
|
||||||
|
|
||||||
fields[set] = function(value) {
|
fields[set] = function(value) {
|
||||||
var children = this._item && this._item.children;
|
var children = this._item && this._item.children;
|
||||||
|
value = isColor ? Color.read(arguments) : value;
|
||||||
if (children) {
|
if (children) {
|
||||||
for (var i = 0, l = children.length; i < l; i++)
|
for (var i = 0, l = children.length; i < l; i++)
|
||||||
children[i]._style[set](value);
|
children[i]._style[set](value);
|
||||||
} else {
|
} else {
|
||||||
this['_' + key] = isColor ? Color.read(arguments) : value;
|
var old = this['_' + key];
|
||||||
|
if (old != value && !(old && old.equals && old.equals(value))) {
|
||||||
|
this['_' + key] = value;
|
||||||
|
// TODO: Tell _item what exactly has changed. Maybe introduce
|
||||||
|
// ChangeFlags, e.g. STROKE, COLOR, FILL, GEOMETRY, etc?
|
||||||
|
if (this._item && this._item._changed)
|
||||||
|
this._item._changed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue