update(examples): Fix examples

This commit is contained in:
Braks
2021-10-20 22:39:54 +02:00
parent a5ae6a4e48
commit 29c6df1755
25 changed files with 690 additions and 885 deletions
+19
View File
@@ -0,0 +1,19 @@
<script lang="ts" setup>
/**
* Example for checking the different edge types and source and target positions
*/
import { getElements } from './utils'
import Flow, { removeElements, addEdge, MiniMap, Controls, Background, OnLoadParams, Connection, Edge, Elements } from '~/index'
const onLoad = (reactFlowInstance: OnLoadParams) => {
reactFlowInstance.fitView()
console.log(reactFlowInstance.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))
</script>
<template>
<Flow :elements="elements" :on-load="onLoad" :on-elements-remove="onElementsRemove" :on-connect="onConnect" :min-zoom="0.2" />
</template>
-43
View File
@@ -1,43 +0,0 @@
/**
* Example for checking the different edge types and source and target positions
*/
import RevueFlow, {
removeElements,
addEdge,
MiniMap,
Controls,
Background,
OnLoadParams,
Connection,
Edge,
Elements
} from '../../src'
import { getElements } from './utils'
import { defineComponent, ref } from 'vue'
const onLoad = (reactFlowInstance: OnLoadParams) => {
reactFlowInstance.fitView()
console.log(reactFlowInstance.getElements())
}
const initialElements = getElements()
const EdgeTypesFlow = defineComponent({
setup() {
const elements = ref<Elements>(initialElements)
const onElementsRemove = (elementsToRemove: Elements) => (elements.value = removeElements(elementsToRemove, elements.value))
const onConnect = (params: Connection | Edge) => (elements.value = addEdge(params, elements.value))
return () => (
<RevueFlow
v-model={elements.value}
onLoad={onLoad}
onElementsRemove={onElementsRemove}
onConnect={onConnect}
minZoom={0.2}
></RevueFlow>
)
}
})
export default EdgeTypesFlow