fix(hooks): repair useStoreActions hook

This commit is contained in:
moklick
2021-01-21 19:35:04 +01:00
parent e9a7ade236
commit 252552a694
8 changed files with 63 additions and 37 deletions
+3 -2
View File
@@ -3,7 +3,7 @@ import { zoomIdentity } from 'd3-zoom';
import { useStoreState, useStore } from '../store/hooks';
import { clamp } from '../utils';
import { getRectOfNodes } from '../utils/graph';
import { getRectOfNodes, isNode } from '../utils/graph';
import { FitViewParams, FlowTransform, ZoomPanHelperFunctions, Rect, Transform } from '../types';
const initialZoomPanHelper: ZoomPanHelperFunctions = {
@@ -54,7 +54,8 @@ const usePanZoomHelper = (): ZoomPanHelperFunctions => {
d3Zoom.transform(d3Selection, nextTransform);
},
fitView: (options: FitViewParams = { padding: 0.1 }) => {
const { nodes, width, height, minZoom, maxZoom } = store.getState();
const { elements, width, height, minZoom, maxZoom } = store.getState();
const nodes = elements.filter(isNode);
if (!nodes.length) {
return;