mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 05:42:07 -05:00
Clean up Item#selected code.
This commit is contained in:
parent
d27ff7803c
commit
2679d6eb9e
1 changed files with 7 additions and 12 deletions
|
@ -195,8 +195,8 @@ var Item = this.Item = Base.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies whether an item is selected and will also return {@code true} if
|
* Specifies whether an item is selected and will also return {@code true}
|
||||||
* the item is partially selected (groups with some selected items/partially
|
* if the item is partially selected (groups with some selected or partially
|
||||||
* selected paths).
|
* selected paths).
|
||||||
*
|
*
|
||||||
* Paper.js draws the visual outlines of selected items on top of your
|
* Paper.js draws the visual outlines of selected items on top of your
|
||||||
|
@ -218,14 +218,11 @@ var Item = this.Item = Base.extend({
|
||||||
isSelected: function() {
|
isSelected: function() {
|
||||||
if (this._children) {
|
if (this._children) {
|
||||||
for (var i = 0, l = this._children.length; i < l; i++) {
|
for (var i = 0, l = this._children.length; i < l; i++) {
|
||||||
if (this._children[i].isSelected()) {
|
if (this._children[i].isSelected())
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return !!this._selected;
|
|
||||||
}
|
}
|
||||||
return false;
|
return !!this._selected;
|
||||||
},
|
},
|
||||||
|
|
||||||
setSelected: function(selected) {
|
setSelected: function(selected) {
|
||||||
|
@ -233,11 +230,9 @@ var Item = this.Item = Base.extend({
|
||||||
for (var i = 0, l = this._children.length; i < l; i++) {
|
for (var i = 0, l = this._children.length; i < l; i++) {
|
||||||
this._children[i].setSelected(selected);
|
this._children[i].setSelected(selected);
|
||||||
}
|
}
|
||||||
} else {
|
} else if ((selected = !!selected) != this._selected) {
|
||||||
if ((selected = !!selected) != this._selected) {
|
this._selected = selected;
|
||||||
this._selected = selected;
|
this._project._selectItem(this, selected);
|
||||||
this._project._selectItem(this, selected);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue