mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Implement Item#reverseChildren() and add tests for it.
This commit is contained in:
parent
d77741db4f
commit
d9b75a7232
2 changed files with 20 additions and 2 deletions
|
@ -142,7 +142,13 @@ Item = Base.extend({
|
|||
// TODO: get/setKnockout (print specific feature)
|
||||
// TODO get/setAlphaIsShape
|
||||
// TODO: get/setData
|
||||
// TODO: reverseChildren
|
||||
|
||||
/**
|
||||
* Reverses the order of this item's children
|
||||
*/
|
||||
reverseChildren: function() {
|
||||
this.children.reverse();
|
||||
},
|
||||
|
||||
/**
|
||||
* The first item contained within this item.
|
||||
|
|
|
@ -132,4 +132,16 @@ test('hidden', function() {
|
|||
var firstPath = new Path();
|
||||
firstPath.visible = false;
|
||||
equals(firstPath.hidden, true);
|
||||
});
|
||||
});
|
||||
|
||||
test('reverseChildren()', function() {
|
||||
var doc = new Doc();
|
||||
var path = new Path();
|
||||
var secondPath = new Path();
|
||||
var thirdPath = new Path();
|
||||
equals(doc.activeLayer.firstChild == path, true);
|
||||
doc.activeLayer.reverseChildren();
|
||||
equals(doc.activeLayer.firstChild == path, false);
|
||||
equals(doc.activeLayer.firstChild == thirdPath, true);
|
||||
equals(doc.activeLayer.lastChild == path, true);
|
||||
})
|
Loading…
Reference in a new issue