refactor(elements): split edges and nodes

This commit is contained in:
moklick
2021-02-11 18:45:05 +01:00
parent 201a35dec2
commit ba5286a105
12 changed files with 166 additions and 190 deletions
+2 -3
View File
@@ -3,7 +3,7 @@ import { zoomIdentity } from 'd3-zoom';
import { useStoreState, useStore } from '../store/hooks';
import { clamp } from '../utils';
import { getRectOfNodes, isNode } from '../utils/graph';
import { getRectOfNodes } from '../utils/graph';
import { FitViewParams, FlowTransform, ZoomPanHelperFunctions, Rect, Transform } from '../types';
const DEFAULT_PADDING = 0.1;
@@ -56,8 +56,7 @@ const useZoomPanHelper = (): ZoomPanHelperFunctions => {
d3Zoom.transform(d3Selection, nextTransform);
},
fitView: (options: FitViewParams = { padding: DEFAULT_PADDING, includeHiddenNodes: false }) => {
const { elements, width, height, minZoom, maxZoom } = store.getState();
const nodes = elements.filter(isNode);
const { nodes, width, height, minZoom, maxZoom } = store.getState();
if (!nodes.length) {
return;