mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Apply the same optimisation from previous commit to Layer.
This commit is contained in:
parent
02bf012aa5
commit
a365bf45a4
1 changed files with 21 additions and 24 deletions
|
@ -24,30 +24,6 @@ var Layer = this.Layer = Group.extend({
|
|||
}
|
||||
},
|
||||
|
||||
moveAbove: function(item) {
|
||||
// if the item is a layer and contained within Document#layers
|
||||
if (item instanceof Layer && !item.parent) {
|
||||
this.removeFromParent();
|
||||
item.document.layers.splice(item.getIndex() + 1, 0, this);
|
||||
this.document = item.document;
|
||||
return true;
|
||||
} else {
|
||||
return this.base(item);
|
||||
}
|
||||
},
|
||||
|
||||
moveBelow: function(item) {
|
||||
// if the item is a layer and contained within Document#layers
|
||||
if (item instanceof Layer && !item.parent) {
|
||||
this.removeFromParent();
|
||||
item.document.layers.splice(item.getIndex() - 1, 0, this);
|
||||
this.document = item.document;
|
||||
return true;
|
||||
} else {
|
||||
return this.base(item);
|
||||
}
|
||||
},
|
||||
|
||||
getNextSibling: function() {
|
||||
return this.parent ? this.base()
|
||||
: this.document.layers[this.getIndex() + 1] || null;
|
||||
|
@ -61,4 +37,25 @@ var Layer = this.Layer = Group.extend({
|
|||
activate: function() {
|
||||
this.document.activeLayer = this;
|
||||
}
|
||||
}, new function () {
|
||||
function move(above) {
|
||||
return function(item) {
|
||||
// if the item is a layer and contained within Document#layers
|
||||
if (item instanceof Layer && !item.parent) {
|
||||
this.removeFromParent();
|
||||
item.document.layers.splice(item.getIndex() + (above ? 1 : -1),
|
||||
0, this);
|
||||
this.document = item.document;
|
||||
return true;
|
||||
} else {
|
||||
return this.base(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
moveAbove: move(true),
|
||||
|
||||
moveBelow: move(false)
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue