mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Define Item#clear() as an alias for Item#removeChildren(), or Path#removeSegments() for paths.
This commit is contained in:
parent
df80eb2f23
commit
132f54d362
3 changed files with 7 additions and 4 deletions
|
@ -1956,6 +1956,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
||||||
* Removes all of the item's {@link #children} (if any).
|
* Removes all of the item's {@link #children} (if any).
|
||||||
*
|
*
|
||||||
* @name Item#removeChildren
|
* @name Item#removeChildren
|
||||||
|
* @alias Item#clear
|
||||||
* @function
|
* @function
|
||||||
* @return {Item[]} an array containing the removed items
|
* @return {Item[]} an array containing the removed items
|
||||||
*/
|
*/
|
||||||
|
@ -1985,6 +1986,8 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
||||||
return removed;
|
return removed;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
clear: '#removeChildren',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reverses the order of the item's children
|
* Reverses the order of the item's children
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -635,6 +635,7 @@ var Path = PathItem.extend(/** @lends Path# */{
|
||||||
* Removes all segments from the path's {@link #segments} array.
|
* Removes all segments from the path's {@link #segments} array.
|
||||||
*
|
*
|
||||||
* @name Path#removeSegments
|
* @name Path#removeSegments
|
||||||
|
* @alias Path#clear
|
||||||
* @function
|
* @function
|
||||||
* @return {Segment[]} an array containing the removed segments
|
* @return {Segment[]} an array containing the removed segments
|
||||||
*/
|
*/
|
||||||
|
@ -707,6 +708,8 @@ var Path = PathItem.extend(/** @lends Path# */{
|
||||||
return removed;
|
return removed;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
clear: '#removeSegments',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies whether an path is selected and will also return {@code true}
|
* Specifies whether an path is selected and will also return {@code true}
|
||||||
* if the path is partially selected, i.e. one or more of its segments is
|
* if the path is partially selected, i.e. one or more of its segments is
|
||||||
|
|
|
@ -108,10 +108,7 @@ var PathItem = Item.extend(/** @lends PathItem# */{
|
||||||
}
|
}
|
||||||
|
|
||||||
// First clear the previous content
|
// First clear the previous content
|
||||||
if (this._type === 'path')
|
this.clear();
|
||||||
this.removeSegments();
|
|
||||||
else
|
|
||||||
this.removeChildren();
|
|
||||||
|
|
||||||
for (var i = 0, l = parts.length; i < l; i++) {
|
for (var i = 0, l = parts.length; i < l; i++) {
|
||||||
var part = parts[i],
|
var part = parts[i],
|
||||||
|
|
Loading…
Reference in a new issue