mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 05:42: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;
|
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());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue