Skip to content

Commit c4c4c66

Browse files
committed
chore: add changeset
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
1 parent f2af818 commit c4c4c66

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

.changeset/strange-buses-hope.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@vue-flow/core": patch
3+
---
4+
5+
Wait until viewport helper is initialized before triggering viewport functions and pane ready event

examples/vite/src/Basic/Basic.vue

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ const elements = ref<Elements>([
1414
{ id: 'e1-2', source: '1', target: '2', animated: true },
1515
{ id: 'e1-3', source: '1', target: '3' },
1616
])
17-
const { onNodeDragStop, onEdgeClick, onConnect, addEdges, setTransform, toObject } = useVueFlow({
18-
minZoom: 0.2,
19-
maxZoom: 4,
20-
connectOnClick: true,
21-
fitViewOnInit: false,
22-
})
17+
const { onNodeDragStop, onEdgeClick, onConnect, addEdges, setTransform, toObject, fitView, onPaneReady, setNodes, setEdges } =
18+
useVueFlow({
19+
minZoom: 0.2,
20+
maxZoom: 4,
21+
connectOnClick: true,
22+
fitViewOnInit: false,
23+
})
2324
2425
onNodeDragStop((e) => console.log('drag stop', e.event))
2526
onEdgeClick(console.log)
@@ -35,13 +36,29 @@ const updatePos = () =>
3536
}
3637
})
3738
39+
onPaneReady((instance) => {
40+
setNodes([
41+
{ id: '1', type: 'input', label: 'Node 1', position: { x: 250, y: 5 }, class: 'light' },
42+
{ id: '2', label: 'Node 2', position: { x: 100, y: 100 }, class: 'light' },
43+
{ id: '3', label: 'Node 3', position: { x: 400, y: 100 }, class: 'light' },
44+
{ id: '4', label: 'Node 4', position: { x: 400, y: 200 }, class: 'light' },
45+
])
46+
47+
setEdges([
48+
{ id: 'e1-2', source: '1', target: '2', animated: true },
49+
{ id: 'e1-3', source: '1', target: '3' },
50+
])
51+
52+
instance.fitView()
53+
})
54+
3855
const logToObject = () => console.log(toObject())
3956
const resetTransform = () => setTransform({ x: 0, y: 0, zoom: 1 })
4057
const toggleclass = () => elements.value.forEach((el) => (el.class = el.class === 'light' ? 'dark' : 'light'))
4158
</script>
4259

4360
<template>
44-
<VueFlow v-model="elements" fit-view-on-init connection-mode="strict" class="vue-flow-basic-example">
61+
<VueFlow v-model="elements" connection-mode="strict" class="vue-flow-basic-example">
4562
<Background />
4663
<MiniMap />
4764
<Controls />

0 commit comments

Comments
 (0)