From 1e8d578bb136c8c08abc1fa3ed2dfd5877ea428c Mon Sep 17 00:00:00 2001 From: moklick Date: Fri, 28 Jan 2022 13:26:23 +0100 Subject: [PATCH] chore(examples): cleanup --- example/src/Subflow/index.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/example/src/Subflow/index.tsx b/example/src/Subflow/index.tsx index 5c08ff06..44621ae4 100644 --- a/example/src/Subflow/index.tsx +++ b/example/src/Subflow/index.tsx @@ -55,7 +55,7 @@ const initialNodes: Node[] = [ { id: '4b2', data: { label: 'Node 4b2' }, - position: { x: 100, y: 100 }, + position: { x: 20, y: 100 }, className: 'light', parentNode: '4b', }, @@ -113,15 +113,18 @@ const BasicFlow = () => { const onConnect = useCallback((connection: Connection) => { setEdges((eds) => addEdge(connection, eds)); }, []); + const onInit = useCallback((reactFlowInstance: ReactFlowInstance) => setRfInstance(reactFlowInstance), []); const updatePos = () => { setNodes((nds) => { return nds.map((n) => { - n.position = { - x: Math.random() * 400, - y: Math.random() * 400, - }; + if (!n.parentNode) { + n.position = { + x: Math.random() * 400, + y: Math.random() * 400, + }; + } return n; }); @@ -149,8 +152,6 @@ const BasicFlow = () => { }); }; - console.log(nodes); - return (