Further clean-up code, as we only need previous / next references inside one sub-condition.

This commit is contained in:
Jürg Lehni 2011-04-27 12:26:10 +01:00
parent 138ec7d93c
commit e6a0f48256

View file

@ -141,32 +141,30 @@ var Segment = this.Segment = Base.extend({
}
return false;
},
_setSelected: function(point, selected) {
if (!this._path)
return;
var selected = !!selected, // convert to boolean
state = this._selectionState,
wasSelected = !!state,
pointSelected = !!(state & SelectionState.POINT);
handleInSelected = !!(state & SelectionState.HANDLE_IN);
pointSelected = !!(state & SelectionState.POINT),
handleInSelected = !!(state & SelectionState.HANDLE_IN),
handleOutSelected = !!(state & SelectionState.HANDLE_OUT);
previous = this.getPrevious(),
next = this.getNext(),
segments = this._path._segments,
length = segments.length;
if (point == this._point) {
if (pointSelected != selected) {
if (selected) {
handleInSelected = handleOutSelected = false;
} else {
var previous = this.getPrevious(),
next = this.getNext();
// When deselecting a point, the handles get selected
// instead depending on the selection state of their
// neighbors.
handleInSelected = previous != null
handleInSelected = previous
&& (previous._point.isSelected()
|| previous._handleOut.isSelected());
handleOutSelected = next != null
handleOutSelected = next
&& (next._point.isSelected()
|| next._handleOut.isSelected());
}