mirror of
https://github.com/projectstorm/react-diagrams.git
synced 2025-08-15 17:25:12 +08:00
issue-277 few null checks to avoid crash when node went under bottom of screen
This commit is contained in:
@ -59,14 +59,22 @@ export default class PathFinding {
|
|||||||
pathToStart: number[][];
|
pathToStart: number[][];
|
||||||
pathToEnd: number[][];
|
pathToEnd: number[][];
|
||||||
} {
|
} {
|
||||||
const startIndex = path.findIndex(point => matrix[point[1]][point[0]] === 0);
|
const startIndex = path.findIndex(point => {
|
||||||
|
if (matrix[point[1]])
|
||||||
|
return matrix[point[1]][point[0]] === 0;
|
||||||
|
else return false;
|
||||||
|
});
|
||||||
const endIndex =
|
const endIndex =
|
||||||
path.length -
|
path.length -
|
||||||
1 -
|
1 -
|
||||||
path
|
path
|
||||||
.slice()
|
.slice()
|
||||||
.reverse()
|
.reverse()
|
||||||
.findIndex(point => matrix[point[1]][point[0]] === 0);
|
.findIndex(point => {
|
||||||
|
if (matrix[point[1]])
|
||||||
|
return matrix[point[1]][point[0]] === 0;
|
||||||
|
else return false;
|
||||||
|
});
|
||||||
|
|
||||||
// are we trying to create a path exclusively through blocked areas?
|
// are we trying to create a path exclusively through blocked areas?
|
||||||
// if so, let's fallback to the linear routing
|
// if so, let's fallback to the linear routing
|
||||||
|
Reference in New Issue
Block a user