mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 01:12:39 -05:00
Split Item#copyTo() into #addTo() and #copyTo()
This commit is contained in:
parent
5291043a5f
commit
f2e9fab264
1 changed files with 16 additions and 6 deletions
|
@ -2522,17 +2522,27 @@ new function() { // Injection scope for hit-test functions shared with project
|
|||
moveBelow: '#insertBelow',
|
||||
|
||||
/**
|
||||
* When passed a project, copies the item to the project,
|
||||
* or duplicates it within the same project. When passed an item,
|
||||
* copies the item into the specified item.
|
||||
* Adds it to the specified owner, which can be either a {@link Item} or a
|
||||
* {@link Project}.
|
||||
*
|
||||
* @param {Project|Layer|Group|CompoundPath} owner the item or project to
|
||||
* add the item to
|
||||
* @return {Item} the item itself, if it was successfully added
|
||||
*/
|
||||
addTo: function(owner) {
|
||||
return owner._insertItem(undefined, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Clones the item and adds it to the specified owner, which can be either
|
||||
* a {@link Item} or a {@link Project}.
|
||||
*
|
||||
* @param {Project|Layer|Group|CompoundPath} owner the item or project to
|
||||
* copy the item to
|
||||
* @return {Item} the new copy of the item
|
||||
* @return {Item} the new copy of the item, if it was successfully added
|
||||
*/
|
||||
copyTo: function(owner) {
|
||||
// Pass false for insert, since we're inserting at a specific location.
|
||||
return owner._insertItem(undefined, this.clone(false));
|
||||
return this.clone(false).addTo(owner);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue