mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 14:10:14 -05:00
Apply same optimisations from DOM methods in Item / Layer to Segment too.
This commit is contained in:
parent
be6d60102c
commit
aa4892c0d8
1 changed files with 4 additions and 11 deletions
|
@ -64,11 +64,7 @@ var Segment = this.Segment = Base.extend({
|
|||
|
||||
getIndex: function() {
|
||||
// TODO: Cache and update indices instead of searching?
|
||||
return this.path._segments.indexOf(this);
|
||||
},
|
||||
|
||||
getPath: function() {
|
||||
return this._path;
|
||||
return this.path ? this.path._segments.indexOf(this) : -1;
|
||||
},
|
||||
|
||||
// TODO:
|
||||
|
@ -82,14 +78,11 @@ var Segment = this.Segment = Base.extend({
|
|||
// },
|
||||
|
||||
getNext: function() {
|
||||
var index = this.index;
|
||||
return this.path && index < this.path._segments.length - 1
|
||||
? this.path._segments[index + 1] : null;
|
||||
return this.path && this.path._segments[this.getIndex() + 1] || null;
|
||||
},
|
||||
|
||||
getPrevious: function() {
|
||||
return this.path != null && index > 0
|
||||
? this.path._segments[this.index - 1] : null;
|
||||
return this.path && this.path._segments[this.getIndex() - 1] || null;
|
||||
},
|
||||
|
||||
// TODO:
|
||||
|
@ -109,7 +102,7 @@ var Segment = this.Segment = Base.extend({
|
|||
|
||||
remove: function() {
|
||||
if (this.path && this.path._segments)
|
||||
return this.path._segments.splice(this.index, 1);
|
||||
return !!this.path._segments.splice(this.getIndex(), 1).length;
|
||||
return false;
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue