mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat: Fit to view on load rather than using older position
This commit is contained in:
parent
b9767e9c6e
commit
bbdb26511a
@ -12,7 +12,7 @@ import { useReactFlow } from 'reactflow';
|
||||
const LoadNodesButton = () => {
|
||||
const { t } = useTranslation();
|
||||
const dispatch = useAppDispatch();
|
||||
const { setViewport } = useReactFlow();
|
||||
const { fitView } = useReactFlow();
|
||||
|
||||
const uploadedFileRef = useRef<() => void>(null);
|
||||
|
||||
@ -36,10 +36,10 @@ const LoadNodesButton = () => {
|
||||
}
|
||||
|
||||
if (retrievedNodeTree) {
|
||||
const { x = 0, y = 0, zoom = 1 } = retrievedNodeTree.viewport;
|
||||
dispatch(loadFileNodes(retrievedNodeTree.nodes));
|
||||
dispatch(loadFileEdges(retrievedNodeTree.edges));
|
||||
setViewport({ x, y, zoom });
|
||||
fitView();
|
||||
|
||||
dispatch(
|
||||
addToast(
|
||||
makeToast({ title: t('toast.nodesLoaded'), status: 'success' })
|
||||
@ -56,7 +56,7 @@ const LoadNodesButton = () => {
|
||||
// Cleanup
|
||||
uploadedFileRef.current?.();
|
||||
},
|
||||
[setViewport, dispatch, t]
|
||||
[fitView, dispatch, t]
|
||||
);
|
||||
return (
|
||||
<FileButton
|
||||
|
Loading…
Reference in New Issue
Block a user