mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(node-editor): fit view on init
This commit is contained in:
parent
c3adb301a0
commit
acea304348
@ -7,8 +7,10 @@ import {
|
||||
OnConnectEnd,
|
||||
OnConnectStart,
|
||||
OnEdgesChange,
|
||||
OnInit,
|
||||
OnNodesChange,
|
||||
ReactFlow,
|
||||
ReactFlowInstance,
|
||||
} from 'reactflow';
|
||||
import {
|
||||
connectionEnded,
|
||||
@ -67,6 +69,10 @@ export const Flow = () => {
|
||||
dispatch(connectionEnded());
|
||||
}, [dispatch]);
|
||||
|
||||
const onInit: OnInit = useCallback((v: ReactFlowInstance) => {
|
||||
if (v) v.fitView();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<ReactFlow
|
||||
nodeTypes={nodeTypes}
|
||||
@ -77,6 +83,7 @@ export const Flow = () => {
|
||||
onConnectStart={onConnectStart}
|
||||
onConnect={onConnect}
|
||||
onConnectEnd={onConnectEnd}
|
||||
onInit={onInit}
|
||||
defaultEdgeOptions={{
|
||||
style: { strokeWidth: 2 },
|
||||
}}
|
||||
|
Loading…
Reference in New Issue
Block a user