mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Further clean-up code, as we only need previous / next references inside one sub-condition.
This commit is contained in:
parent
138ec7d93c
commit
e6a0f48256
1 changed files with 7 additions and 9 deletions
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue