mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 14:10:14 -05:00
Implement calling of _removeOwner() for gradients.
This commit is contained in:
parent
9b50020721
commit
bf21e32082
2 changed files with 9 additions and 5 deletions
|
@ -225,8 +225,13 @@ var Color = this.Color = Base.extend(new function() {
|
|||
// name combination.
|
||||
parser = parsers[type][index] = name === 'gradient'
|
||||
? function(value) {
|
||||
if (value)
|
||||
value._addOwner(this);
|
||||
var current = this._components[0];
|
||||
if (current !== value) {
|
||||
if (current)
|
||||
current._removeOwner(this);
|
||||
if (value)
|
||||
value._addOwner(this);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
: name === 'hue'
|
||||
|
|
|
@ -45,7 +45,7 @@ var Gradient = this.Gradient = Base.extend(/** @lends Gradient# */{
|
|||
},
|
||||
|
||||
/**
|
||||
* Called by GradientColor#initialize
|
||||
* Called by Color#setGradient()
|
||||
* This is required to pass on _changed() notifications to the _owners.
|
||||
*/
|
||||
_addOwner: function(color) {
|
||||
|
@ -54,9 +54,8 @@ var Gradient = this.Gradient = Base.extend(/** @lends Gradient# */{
|
|||
this._owners.push(color);
|
||||
},
|
||||
|
||||
// TODO: Where and when should this be called:
|
||||
/**
|
||||
* Called by GradientColor whenever this gradient stops being used.
|
||||
* Called by Color whenever this gradient stops being used.
|
||||
*/
|
||||
_removeOwner: function(color) {
|
||||
var index = this._owners ? this._owners.indexOf(color) : -1;
|
||||
|
|
Loading…
Reference in a new issue