mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Accept CompoundPath items as children of CompoundPath items.
Just add their children and remove the parent. Closes #541
This commit is contained in:
parent
e2d2c836e5
commit
b231e9b2a8
1 changed files with 10 additions and 0 deletions
|
@ -102,6 +102,16 @@ var CompoundPath = PathItem.extend(/** @lends CompoundPath# */{
|
|||
},
|
||||
|
||||
insertChildren: function insertChildren(index, items, _preserve) {
|
||||
// Convert CompoundPath items in the children list by adding their
|
||||
// children to the list and removing their parent.
|
||||
var before = items.slice();
|
||||
for (var i = items.length - 1; i >= 0; i--) {
|
||||
var item = items[i];
|
||||
if (item instanceof CompoundPath) {
|
||||
items.splice.apply(items, [i, 1].concat(item.removeChildren()));
|
||||
item.remove();
|
||||
}
|
||||
}
|
||||
// Pass on 'path' for _type, to make sure that only paths are added as
|
||||
// children.
|
||||
items = insertChildren.base.call(this, index, items, _preserve, Path);
|
||||
|
|
Loading…
Reference in a new issue