mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
Fix handling of recursion in Item#setSelected() / #setFullySelected().
This commit is contained in:
parent
cf4c2b4919
commit
3ece08bea1
2 changed files with 13 additions and 8 deletions
|
@ -469,12 +469,16 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{
|
|||
return this._selected;
|
||||
},
|
||||
|
||||
setSelected: function(selected) {
|
||||
if (this._children) {
|
||||
for (var i = 0, l = this._children.length; i < l; i++) {
|
||||
setSelected: function(selected /*, noChildren */) {
|
||||
// Don't recursively call #setSelected() if it was called with noChildren
|
||||
// set to true, see #setFullySelected().
|
||||
if (this._children && !arguments[1]) {
|
||||
for (var i = 0, l = this._children.length; i < l; i++)
|
||||
this._children[i].setSelected(selected);
|
||||
}
|
||||
} else if ((selected = !!selected) != this._selected) {
|
||||
}
|
||||
// We also need to set _selcted of this item, regardless if it had
|
||||
// children or not.
|
||||
if ((selected = !!selected) != this._selected) {
|
||||
this._selected = selected;
|
||||
this._project._updateSelection(this);
|
||||
this._changed(Change.ATTRIBUTE);
|
||||
|
@ -496,11 +500,11 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{
|
|||
|
||||
setFullySelected: function(selected) {
|
||||
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++)
|
||||
this._children[i].setFullySelected(selected);
|
||||
}
|
||||
}
|
||||
this.setSelected(selected);
|
||||
// Pass true for hidden noChildren argument
|
||||
this.setSelected(selected, true);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -643,6 +643,7 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
|
|||
for (var i = 0; i < length; i++)
|
||||
this._segments[i]._selectionState = selected
|
||||
? SelectionState.POINT : 0;
|
||||
// No need to pass true for noChildren since Path has none anyway.
|
||||
this.setSelected(selected);
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue