MoveTo node #1242
-
I feel stupid, but i cannot for the life of me figure out how to move the viewport to a specific node ?
and i get a node with
How do i move the viewport so the node is in the center of the view ? Example: I zoom in on a node, and i can see
I land somewhere completely different. I tried to see if adding/removing instance.dimensions / instance.vueFlowRef.value.getBoundingClientRect and others in, but i simply cannot "get" the logic, on how to map back and forth from x,y on a node to what setViewport want's |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
The simplest way to do this is to use const { fitView } = useVueFlow();
function zoomToNode(nodeId: string) {
fitView({
nodes: [nodeId],
duration: 1000, // use this if you want a smooth transition to the node
padding: 1 // use this for some padding around the node
})
} |
Beta Was this translation helpful? Give feedback.
-
that looks awesome ... |
Beta Was this translation helpful? Give feedback.
-
@skadefro |
Beta Was this translation helpful? Give feedback.
The simplest way to do this is to use
fitView