mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-22 07:19:57 -05:00
Add from/to parameters to Item#removeChildren() and improve documentation.
This commit is contained in:
parent
5bc4f69856
commit
5d13d3a40d
1 changed files with 24 additions and 7 deletions
|
@ -772,14 +772,31 @@ var Item = this.Item = Base.extend({
|
||||||
/**
|
/**
|
||||||
* Removes all of the item's {@link #children} (if any).
|
* Removes all of the item's {@link #children} (if any).
|
||||||
*
|
*
|
||||||
* @return {Boolean} {@true removing was successful}
|
* @name Item#removeChildren
|
||||||
|
* @function
|
||||||
|
* @return {Array} an array containing the removed items
|
||||||
*/
|
*/
|
||||||
removeChildren: function() {
|
/**
|
||||||
var removed = false;
|
* Removes all of the item's {@link #children} (if any).
|
||||||
if (this._children) {
|
*
|
||||||
for (var i = this._children.length - 1; i >= 0; i--)
|
* @return {Array} an array containing the removed items
|
||||||
removed = this._children[i].remove() || removed;
|
*/
|
||||||
}
|
/**
|
||||||
|
* Removes the children from the specified {@code from} index to the
|
||||||
|
* {@code to} index from the parent's {@link #children} array.
|
||||||
|
*
|
||||||
|
* @param {Number} from the beginning index, inclusive
|
||||||
|
* @param {Number} [to=children.length] the ending index, exclusive
|
||||||
|
* @return {Array} an array containing the removed items
|
||||||
|
*/
|
||||||
|
removeChildren: function(from, to) {
|
||||||
|
if (!this._children)
|
||||||
|
return null;
|
||||||
|
from = from || 0;
|
||||||
|
to = Base.pick(to, this._children.length);
|
||||||
|
var removed = this._children.splice(from, to - from);
|
||||||
|
for (var i = removed.length - 1; i >= 0; i--)
|
||||||
|
removed[i].remove();
|
||||||
return removed;
|
return removed;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue