mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Add comment about ideally not relying on parent.children.indexOf for getIndex().
This commit is contained in:
parent
eeb7d377e6
commit
604ff7824c
1 changed files with 5 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
Item = Base.extend({
|
||||
beans: true,
|
||||
|
||||
initialize: function() {
|
||||
this.parent = Paper.document.activeLayer;
|
||||
this.parent.children.push(this);
|
||||
|
@ -155,7 +156,7 @@ Item = Base.extend({
|
|||
getNextSibling: function() {
|
||||
if (this.parent) {
|
||||
var index = this.index + 1;
|
||||
if (index < this.parent.children.length)
|
||||
if (index < this.parent.children.length)
|
||||
return this.parent.children[index];
|
||||
}
|
||||
},
|
||||
|
@ -175,6 +176,9 @@ Item = Base.extend({
|
|||
* The index of this item within the list of it's parent's children.
|
||||
*/
|
||||
getIndex: function() {
|
||||
// TODO: Relying on indexOf() here is slow, especially since it is
|
||||
// used for getPrevious/NextSibling().
|
||||
// We need linked lists instead.
|
||||
return this.parent.children.indexOf(this);
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue