@luxonis/depthai-pipeline-lib 1.4.12 → 1.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -49,16 +49,21 @@ const PipelineCanvasBody = ({ pipeline, ...flexProps }) => {
|
|
|
49
49
|
const layouted = getLayoutedElements(pipeline?.nodes ?? [], pipeline?.edges ?? []);
|
|
50
50
|
setNodes([...layouted.nodes]);
|
|
51
51
|
setEdges([...layouted.edges]);
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
}, [pipeline?.edges, pipeline?.nodes, setEdges, setNodes]);
|
|
53
|
+
const setViewportAndFit = async (x, y, zoom, nds) => {
|
|
54
|
+
await setViewport({ x, y, zoom });
|
|
55
|
+
await fitView({ nodes: nds });
|
|
56
|
+
};
|
|
57
|
+
React.useEffect(() => {
|
|
58
|
+
if (!autoArrangeRef.current) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (nodes.length > 0 && edges.length > 0) {
|
|
54
62
|
const viewport = getViewport();
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
}, [fitView, getViewport, pipeline?.edges, pipeline?.nodes, setEdges, setNodes, setViewport]);
|
|
63
|
+
void setViewportAndFit(viewport.x, viewport.y, viewport.zoom, nodes);
|
|
64
|
+
}
|
|
65
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
66
|
+
}, [nodes, edges]);
|
|
62
67
|
return (_jsxs(Flex, { align: "center", justify: "center", full: true, height: "container.xs", rounded: "common", border: "base", ...flexProps, children: [!pipeline && _jsx(Header, { text: "Loading pipeline..." }), pipeline && (_jsx(ReactFlow, { nodes: nodes, edges: edges, onNodeDragStart: () => (autoArrangeRef.current = false), onNodesChange: onNodesChange, fitView: true, nodeTypes: { generic: PipelineNode }, minZoom: 0.4 }))] }));
|
|
63
68
|
};
|
|
64
69
|
export const PipelineCanvas = props => (_jsx(ReactFlowProvider, { children: _jsx(PipelineCanvasBody, { ...props }) }));
|