docs: update nested example

This commit is contained in:
bcakmakoglu
2022-05-26 21:35:30 +02:00
committed by Braks
parent c0920bfb4d
commit 6c06eeee74
2 changed files with 19 additions and 15 deletions

View File

@@ -5,6 +5,8 @@ import { onMounted } from 'vue'
const { onConnect, nodes, edges, addEdges, addNodes } = useVueFlow({
fitViewOnInit: true,
connectionMode: ConnectionMode.Loose,
// set this to true so edges get elevated when selected, defaults to false
elevateEdgesOnSelect: true,
nodes: [
{ id: '1', type: 'input', label: 'node', position: { x: 250, y: 0 } },
{

View File

@@ -57,25 +57,27 @@ const connectionLineVisible = $(
let groups = $ref<ReturnType<typeof groupEdgesByZLevel>>([])
onPaneReady(() => {
const stop = watch(
[$$(elevateEdgesOnSelect), $$(getSelectedNodes), $$(getEdges), $$(getNodes)],
() => {
if (elevateEdgesOnSelect) {
nextTick(() => (groups = groupEdgesByZLevel(getEdges, getNode)))
}
},
{
flush: 'post',
immediate: true,
},
)
const scope = effectScope()
onBeforeUnmount(() => {
stop()
onPaneReady(() => {
scope.run(() => {
watch(
[$$(getSelectedNodes), $$(getEdges), $$(getNodes)],
() => {
if (elevateEdgesOnSelect) {
nextTick(() => (groups = groupEdgesByZLevel(getEdges, getNode)))
}
},
{
flush: 'post',
immediate: true,
},
)
})
})
onBeforeUnmount(() => scope.stop())
const getType = (type?: string, template?: GraphEdge['template']) => {
const name = type || 'default'
let edgeType = template ?? getEdgeTypes[name]