mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
Add Item#removeChildren() and #setChildren().
This commit is contained in:
parent
00b5f6a6bb
commit
75b0fa3596
1 changed files with 18 additions and 1 deletions
|
@ -239,7 +239,12 @@ var Item = this.Item = Base.extend({
|
|||
return this._children;
|
||||
},
|
||||
|
||||
// TODO: #setChildren()
|
||||
setChildren: function(children) {
|
||||
this.removeChildren();
|
||||
for (var i = 0, l = children && children.length; i < l; i++)
|
||||
this.appendBottom(children[i]);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Reverses the order of this item's children
|
||||
|
@ -253,6 +258,18 @@ var Item = this.Item = Base.extend({
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes all of the item's children, if it has any
|
||||
*/
|
||||
removeChildren: function() {
|
||||
var removed = false;
|
||||
if (this._children) {
|
||||
for (var i = this._children.length; i >= 0 i--)
|
||||
removed = this._children[i].remove() || removed;
|
||||
}
|
||||
return removed;
|
||||
},
|
||||
|
||||
/**
|
||||
* The first item contained within this item.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue