mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-04-23 03:00:31 -04:00
feat(ui): make useZoomToNode not rely on reactflow ctx
This commit is contained in:
committed by
Kent Keirsey
parent
6cd794d860
commit
e9e2bab4ee
@@ -1,13 +1,17 @@
|
|||||||
import { useReactFlow } from '@xyflow/react';
|
import { logger } from 'app/logging/logger';
|
||||||
|
import { $flow } from 'features/nodes/store/reactFlowInstance';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
|
|
||||||
|
const log = logger('workflows');
|
||||||
|
|
||||||
export const useZoomToNode = () => {
|
export const useZoomToNode = () => {
|
||||||
const flow = useReactFlow();
|
const zoomToNode = useCallback((nodeId: string) => {
|
||||||
const zoomToNode = useCallback(
|
const flow = $flow.get();
|
||||||
(nodeId: string) => {
|
if (!flow) {
|
||||||
flow.fitView({ duration: 300, maxZoom: 1.5, nodes: [{ id: nodeId }] });
|
log.warn('No flow instance found, cannot zoom to node');
|
||||||
},
|
return;
|
||||||
[flow]
|
}
|
||||||
);
|
flow.fitView({ duration: 300, maxZoom: 1.5, nodes: [{ id: nodeId }] });
|
||||||
|
}, []);
|
||||||
return zoomToNode;
|
return zoomToNode;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user