mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Merge pull request #135 from 0/layer-insert-below
Fix insertBelow for Layer items
This commit is contained in:
commit
4c409b37fb
2 changed files with 15 additions and 5 deletions
|
@ -98,7 +98,7 @@ var Layer = this.Layer = Group.extend(/** @lends Layer# */{
|
|||
if (item instanceof Layer && !item._parent
|
||||
&& this._remove(false, true)) {
|
||||
Base.splice(item._project.layers, [this],
|
||||
item._index + (above ? 1 : -1), 0);
|
||||
item._index + (above ? 1 : 0), 0);
|
||||
this._setProject(item._project);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -59,9 +59,19 @@ test('insertAbove / insertBelow', function() {
|
|||
var project = paper.project;
|
||||
var firstLayer = project.activeLayer;
|
||||
var secondLayer = new Layer();
|
||||
var thirdLayer = new Layer();
|
||||
|
||||
thirdLayer.insertBelow(firstLayer);
|
||||
equals(function() {
|
||||
return thirdLayer.previousSibling == null;
|
||||
}, true);
|
||||
equals(function() {
|
||||
return thirdLayer.nextSibling == firstLayer;
|
||||
}, true);
|
||||
|
||||
secondLayer.insertBelow(firstLayer);
|
||||
equals(function() {
|
||||
return secondLayer.previousSibling == null;
|
||||
return secondLayer.previousSibling == thirdLayer;
|
||||
}, true);
|
||||
equals(function() {
|
||||
return secondLayer.nextSibling == firstLayer;
|
||||
|
@ -78,10 +88,10 @@ test('insertAbove / insertBelow', function() {
|
|||
equals(function() {
|
||||
return secondLayer.parent == firstLayer;
|
||||
}, true);
|
||||
// There should now only be one layer left:
|
||||
// There should now only be two layers left:
|
||||
equals(function() {
|
||||
return project.layers.length;
|
||||
}, 1);
|
||||
}, 2);
|
||||
});
|
||||
|
||||
test('addChild / appendBottom / nesting', function() {
|
||||
|
@ -114,4 +124,4 @@ test('addChild / appendBottom / nesting', function() {
|
|||
return project.layers[0] == secondLayer
|
||||
&& project.layers[1] == firstLayer;
|
||||
}, true);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue