Skip to content

Commit 43cfff9

Browse files
committed
refactor: clean up a little
1 parent 2863252 commit 43cfff9

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/types/packet.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export class Packet extends Graphics {
2525
speed = 200;
2626
progress = 0;
2727
viewgraph: ViewGraph;
28-
currentPath: Edge[];
2928
currentEdge: Edge;
3029
currentStart: number;
3130
color: number;
@@ -75,12 +74,12 @@ export class Packet extends Graphics {
7574
}
7675

7776
select() {
78-
this.highlight(); // Calls highlight on select
77+
this.highlight();
7978
this.showInfo();
8079
}
8180

8281
deselect() {
83-
this.removeHighlight(); // Calls removeHighlight on deselect
82+
this.removeHighlight();
8483
}
8584

8685
showInfo() {
@@ -151,11 +150,10 @@ export class Packet extends Graphics {
151150
deleteSelf();
152151
return;
153152
}
154-
this.currentEdge = this.viewgraph
155-
.getConnections(newStart)
156-
.find((edge) => {
157-
return edge.otherEnd(newStart) === newEdgeId;
158-
});
153+
const currentNodeEdges = this.viewgraph.getConnections(newStart);
154+
this.currentEdge = currentNodeEdges.find((edge) => {
155+
return edge.otherEnd(newStart) === newEdgeId;
156+
});
159157
if (this.currentEdge === undefined) {
160158
deleteSelf();
161159
return;
@@ -183,7 +181,6 @@ export class Packet extends Graphics {
183181
const dx = end.x - start.x;
184182
const dy = end.y - start.y;
185183

186-
// Mover el paquete
187184
this.x = start.x + progress * dx;
188185
this.y = start.y + progress * dy;
189186
}

0 commit comments

Comments
 (0)