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