mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Check result from removeFromParent().
This commit is contained in:
parent
59e2783979
commit
2f6fbcba74
2 changed files with 3 additions and 4 deletions
|
@ -804,8 +804,7 @@ var Item = this.Item = Base.extend({
|
||||||
|
|
||||||
function append(top) {
|
function append(top) {
|
||||||
return function(item) {
|
return function(item) {
|
||||||
if (this.children) {
|
if (this.children && item.removeFromParent()) {
|
||||||
item.removeFromParent();
|
|
||||||
this.children.splice(top ? this.children.length : 0, 0, item);
|
this.children.splice(top ? this.children.length : 0, 0, item);
|
||||||
// TODO: Reassign _index
|
// TODO: Reassign _index
|
||||||
item.parent = this;
|
item.parent = this;
|
||||||
|
|
|
@ -57,8 +57,8 @@ var Layer = this.Layer = Group.extend({
|
||||||
function move(above) {
|
function move(above) {
|
||||||
return function(item) {
|
return function(item) {
|
||||||
// if the item is a layer and contained within Document#layers
|
// if the item is a layer and contained within Document#layers
|
||||||
if (item instanceof Layer && !item.parent) {
|
if (item instanceof Layer && !item.parent
|
||||||
this.removeFromParent();
|
&& this.removeFromParent()) {
|
||||||
item._document.layers.splice(item.getIndex() + (above ? 1 : -1),
|
item._document.layers.splice(item.getIndex() + (above ? 1 : -1),
|
||||||
0, this);
|
0, this);
|
||||||
this.setDocument(item._document);
|
this.setDocument(item._document);
|
||||||
|
|
Loading…
Reference in a new issue