From cf118f1c8c379528810f8d6b6ab7d827aebbbbde Mon Sep 17 00:00:00 2001 From: moklick Date: Wed, 23 Oct 2019 16:16:54 +0200 Subject: [PATCH] fix(fitview): emtpy graph doesnt crash closes #50 --- src/utils/graph.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/graph.ts b/src/utils/graph.ts index 07a4ffdb..c9696b74 100644 --- a/src/utils/graph.ts +++ b/src/utils/graph.ts @@ -178,10 +178,10 @@ export const getConnectedEdges = (nodes: Node[], edges: Edge[]): Edge[] => { }); }; -export const fitView = ({ padding }: FitViewParams = { padding: 0 }): void => { +export const fitView = ({ padding }: FitViewParams = { padding: 0.1 }): void => { const { nodes, width, height, d3Selection, d3Zoom } = store.getState(); - if (!d3Selection || !d3Zoom) { + if (!d3Selection || !d3Zoom || !nodes.length) { return; }