diff --git a/src/color/Color.js b/src/color/Color.js index c34ca2a1..10a3547d 100644 --- a/src/color/Color.js +++ b/src/color/Color.js @@ -270,7 +270,7 @@ var Color = this.Color = Base.extend(new function() { ? ((value % 360) + 360) % 360 // All other values are 0..1 : Math.min(Math.max(value, 0), 1); - this._cssString = null; + this._changed(); return this; }; }, src); @@ -306,6 +306,27 @@ var Color = this.Color = Base.extend(new function() { }, { /** @lends Color# */ + _changed: function() { + this._cssString = null; + for (var i = 0, l = this._owners && this._owners.length; i < l; i++) + this._owners[i]._changed(Change.STYLE); + }, + + _addOwner: function(item) { + if (!this._owners) + this._owners = []; + this._owners.push(item); + }, + + _removeOwner: function(item) { + var index = this._owners ? this._owners.indexOf(item) : -1; + if (index != -1) { + this._owners.splice(index, 1); + if (this._owners.length == 0) + delete this._owners; + } + }, + /** * Returns the type of the color as a string. * @@ -357,7 +378,7 @@ var Color = this.Color = Base.extend(new function() { setAlpha: function(alpha) { this._alpha = alpha == null ? null : Math.min(Math.max(alpha, 0), 1); - this._cssString = null; + this._changed(); return this; }, diff --git a/src/color/GradientColor.js b/src/color/GradientColor.js index accc0a56..4d5a3f02 100644 --- a/src/color/GradientColor.js +++ b/src/color/GradientColor.js @@ -136,6 +136,7 @@ var GradientColor = this.GradientColor = Color.extend({ this._origin = origin; if (this._destination) this._radius = this._destination.getDistance(this._origin); + this._changed(); return this; }, @@ -175,6 +176,7 @@ var GradientColor = this.GradientColor = Color.extend({ destination = Point.read(arguments).clone(); this._destination = destination; this._radius = this._destination.getDistance(this._origin); + this._changed(); return this; }, @@ -218,6 +220,7 @@ var GradientColor = this.GradientColor = Color.extend({ } else { this._hilite = hilite; } + this._changed(); return this; }, diff --git a/src/item/PathStyle.js b/src/item/PathStyle.js index 3490096c..e296ad01 100644 --- a/src/item/PathStyle.js +++ b/src/item/PathStyle.js @@ -104,6 +104,12 @@ var PathStyle = this.PathStyle = Base.extend(new function() { var old = this['_' + key]; if (old != value && !(old && old.equals && old.equals(value))) { this['_' + key] = value; + if (isColor) { + if (old) + old._removeOwner(this._item); + if (value) + value._addOwner(this._item); + } if (this._item) { this._item._changed(Change.STYLE | (strokeFlags[key] ? Change.STROKE : 0));