File tree 1 file changed +2
-0
lines changed
src/PathfindingVisualizer
1 file changed +2
-0
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ export default class PathfindingVisualizer extends React.Component {
82
82
}
83
83
84
84
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
85
86
const oldNodeIsWall = this . state . grid [ row ] [ col ] . isWall ;
86
87
const newGrid = this . state . grid ;
87
88
newGrid [ row ] [ col ] = createNode ( row , col ) ;
@@ -91,6 +92,7 @@ export default class PathfindingVisualizer extends React.Component {
91
92
92
93
handleMouseEnter ( row , col ) { // put/remove a wall
93
94
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
94
96
const oldNodeIsWall = this . state . grid [ row ] [ col ] . isWall ;
95
97
const newGrid = this . state . grid ;
96
98
newGrid [ row ] [ col ] = createNode ( row , col ) ;
You can’t perform that action at this time.
0 commit comments