Skip to content

Commit af8e5c8

Browse files
committed
feat: left mouse mobile support
1 parent 848d12f commit af8e5c8

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Classes/network.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class Network {
22
static PADDING = 50;
3+
static HIT_BOX = 40;
34

45
constructor(canvasWidth, canvasHeight) {
56
this.size = { w: canvasWidth, h: canvasHeight };
@@ -190,7 +191,7 @@ class Network {
190191
}
191192

192193
twoPointsTooClose(p1, p2) {
193-
return p1.distTo(p2) < 40;
194+
return p1.distTo(p2) < Network.HIT_BOX;
194195
}
195196

196197
createPoints() {

sketch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function mousePressed(event) {
2525
let mousePos = new Point(mouseX, mouseY, -1);
2626

2727
for (let p of network.coordP) {
28-
if (mousePos.distTo(p) <= 10) {
28+
if (mousePos.distTo(p) <= Network.HIT_BOX >> 1) {
2929
if (event.button === RIGHT_CLICK && network.start.index != p.index) {
3030
network.end = p;
3131
} else if (network.end.index != p.index) {

0 commit comments

Comments
 (0)