Skip to content

Commit 0ecf705

Browse files
committed
Fixed a bug
1 parent b5a06d8 commit 0ecf705

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/PathfindingVisualizer/PathfindingVisualizer.jsx

+2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export default class PathfindingVisualizer extends React.Component {
8282
}
8383

8484
handleMouseDown(row, col) { // put/remove a wall
85+
if (this.state.grid[row][col].isStart || this.state.grid[row][col].isFinish) return; // start/finish node
8586
const oldNodeIsWall = this.state.grid[row][col].isWall;
8687
const newGrid = this.state.grid;
8788
newGrid[row][col] = createNode(row, col);
@@ -91,6 +92,7 @@ export default class PathfindingVisualizer extends React.Component {
9192

9293
handleMouseEnter(row, col) { // put/remove a wall
9394
if (!this.state.mouseIsPressed) return; // or do nothing if mouse is not pressed
95+
if (this.state.grid[row][col].isStart || this.state.grid[row][col].isFinish) return; // start/finish node
9496
const oldNodeIsWall = this.state.grid[row][col].isWall;
9597
const newGrid = this.state.grid;
9698
newGrid[row][col] = createNode(row, col);

0 commit comments

Comments
 (0)