mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-22 21:42:30 -05:00
Fix allowing connecting lines with end points that are very close together
This commit is contained in:
parent
1c3d5d72f9
commit
70ff3b656f
1 changed files with 8 additions and 10 deletions
|
@ -149,19 +149,17 @@ class LineMode extends React.Component {
|
||||||
if (event.event.button > 0) return; // only first mouse button
|
if (event.event.button > 0) return; // only first mouse button
|
||||||
|
|
||||||
// If I single clicked, don't do anything
|
// If I single clicked, don't do anything
|
||||||
if (!this.hitResult && // Might be connecting 2 points that are very close
|
if (this.path.segments.length < 2 ||
|
||||||
(this.path.segments.length < 2 ||
|
(this.path.segments.length === 2 &&
|
||||||
(this.path.segments.length === 2 &&
|
touching(this.path.firstSegment.point, event.point, LineMode.SNAP_TOLERANCE) &&
|
||||||
touching(this.path.firstSegment.point, event.point, LineMode.SNAP_TOLERANCE)))) {
|
!this.hitResult)) { // Let lines be short if you're connecting them
|
||||||
this.path.remove();
|
this.path.remove();
|
||||||
this.path = null;
|
this.path = null;
|
||||||
return;
|
return;
|
||||||
} else if (
|
} else if (!this.hitResult &&
|
||||||
// Single click on an existing path end point
|
touching(this.path.lastSegment.point, this.path.segments[this.path.segments.length - 2].point,
|
||||||
touching(
|
LineMode.SNAP_TOLERANCE)) {
|
||||||
this.path.lastSegment.point,
|
// Single click or short drag on an existing path end point
|
||||||
this.path.segments[this.path.segments.length - 2].point,
|
|
||||||
LineMode.SNAP_TOLERANCE)) {
|
|
||||||
this.path.removeSegment(this.path.segments.length - 1);
|
this.path.removeSegment(this.path.segments.length - 1);
|
||||||
this.path = null;
|
this.path = null;
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue