update(examples): correct examples

Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
Braks
2021-12-20 19:29:52 +01:00
parent 994dd9929c
commit 5139b0786b
28 changed files with 169 additions and 615 deletions
+3 -16
View File
@@ -1,29 +1,16 @@
<script lang="ts" setup>
import { getElements } from './utils'
import {
VueFlow,
removeElements,
addEdge,
MiniMap,
Controls,
Background,
FlowInstance,
Connection,
Edge,
Elements,
} from '~/index'
import { VueFlow, MiniMap, Controls, Background, FlowInstance } from '~/index'
const onLoad = (flowInstance: FlowInstance) => {
flowInstance.fitView()
console.log(flowInstance.getElements())
}
const elements = ref<Elements>(getElements())
const onElementsRemove = (elementsToRemove: Elements) => (elements.value = removeElements(elementsToRemove, elements.value))
const onConnect = (params: Connection | Edge) => (elements.value = addEdge(params, elements.value))
const elements = getElements()
</script>
<template>
<VueFlow v-model="elements" :min-zoom="0.2" @load="onLoad" @elements-remove="onElementsRemove" @connect="onConnect">
<VueFlow v-model="elements" :min-zoom="0.2" @pane-ready="onLoad">
<MiniMap />
<Controls />
</VueFlow>
+4 -4
View File
@@ -69,18 +69,18 @@ export function getElements(): Elements {
y: edgeTypeIndex * 300 + sourceTargetIndex * edgeTypes.length * 300,
}
const sourceId = getNodeId()
const sourceData = { label: `Source ${sourceId}` }
const sourceLabel = `Source ${sourceId}`
const sourceNode = {
id: sourceId,
style,
data: sourceData,
label: sourceLabel,
position: sourcePosition,
sourcePosition: currSourceTargetPos.source,
targetPosition: currSourceTargetPos.target,
}
const targetId = getNodeId()
const targetData = { label: `Target ${targetId}` }
const targetLabel = `Target ${targetId}`
const targetPosition = {
x: sourcePosition.x + currOffset.x,
y: sourcePosition.y + currOffset.y,
@@ -88,7 +88,7 @@ export function getElements(): Elements {
const targetNode = {
id: targetId,
style,
data: targetData,
label: targetLabel,
position: targetPosition,
sourcePosition: currSourceTargetPos.source,
targetPosition: currSourceTargetPos.target,