Add cyclic looping to Segment#previous/next for closed paths.

This commit is contained in:
Jürg Lehni 2011-04-27 12:21:31 +01:00
parent 92369bf14f
commit 0e89466a11

View file

@ -118,11 +118,16 @@ var Segment = this.Segment = Base.extend({
},
getNext: function() {
return this._path && this._path._segments[this.getIndex() + 1] || null;
var segments = this._path && this._path._segments;
// TODO: Port cyclic looping when closed back to Scriptographer
return segments && (segments[this.getIndex() + 1]
|| this._path.closed && segments[0]) || null;
},
getPrevious: function() {
return this._path && this._path._segments[this.getIndex() - 1] || null;
var segments = this._path && this._path._segments;
return segments && (segments[this.getIndex() - 1]
|| this._path.closed && segments[segments.length - 1]) || null;
},
_isSelected: function(point) {