docs: update nested example

This commit is contained in:
bcakmakoglu
2022-06-23 19:13:50 +02:00
committed by Braks
parent c0920bfb4d
commit 6c06eeee74
2 changed files with 19 additions and 15 deletions
+2
View File
@@ -5,6 +5,8 @@ import { onMounted } from 'vue'
const { onConnect, nodes, edges, addEdges, addNodes } = useVueFlow({ const { onConnect, nodes, edges, addEdges, addNodes } = useVueFlow({
fitViewOnInit: true, fitViewOnInit: true,
connectionMode: ConnectionMode.Loose, connectionMode: ConnectionMode.Loose,
// set this to true so edges get elevated when selected, defaults to false
elevateEdgesOnSelect: true,
nodes: [ nodes: [
{ id: '1', type: 'input', label: 'node', position: { x: 250, y: 0 } }, { id: '1', type: 'input', label: 'node', position: { x: 250, y: 0 } },
{ {
@@ -57,9 +57,12 @@ const connectionLineVisible = $(
let groups = $ref<ReturnType<typeof groupEdgesByZLevel>>([]) let groups = $ref<ReturnType<typeof groupEdgesByZLevel>>([])
const scope = effectScope()
onPaneReady(() => { onPaneReady(() => {
const stop = watch( scope.run(() => {
[$$(elevateEdgesOnSelect), $$(getSelectedNodes), $$(getEdges), $$(getNodes)], watch(
[$$(getSelectedNodes), $$(getEdges), $$(getNodes)],
() => { () => {
if (elevateEdgesOnSelect) { if (elevateEdgesOnSelect) {
nextTick(() => (groups = groupEdgesByZLevel(getEdges, getNode))) nextTick(() => (groups = groupEdgesByZLevel(getEdges, getNode)))
@@ -70,12 +73,11 @@ onPaneReady(() => {
immediate: true, immediate: true,
}, },
) )
onBeforeUnmount(() => {
stop()
}) })
}) })
onBeforeUnmount(() => scope.stop())
const getType = (type?: string, template?: GraphEdge['template']) => { const getType = (type?: string, template?: GraphEdge['template']) => {
const name = type || 'default' const name = type || 'default'
let edgeType = template ?? getEdgeTypes[name] let edgeType = template ?? getEdgeTypes[name]