feat(examples): Add OptionsAPI example

Signed-off-by: bcakmakoglu <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
bcakmakoglu
2022-02-21 20:25:17 +01:00
committed by Braks
parent ae3cb8f80c
commit 78c58688a2
2 changed files with 77 additions and 3 deletions
+3 -3
View File
@@ -9,7 +9,7 @@ const elements = ref<Elements>([
{ id: 'e1-2', source: '1', target: '2', animated: true },
{ id: 'e1-3', source: '1', target: '3' },
])
const { nodes, onPaneReady, onNodeDragStop, onConnect, instance, addEdges, store } = useVueFlow()
const { onPaneReady, onNodeDragStop, onConnect, instance, addEdges } = useVueFlow()
onPaneReady(({ fitView }) => {
fitView({ padding: 0.1 })
})
@@ -28,7 +28,7 @@ const updatePos = () =>
const logToObject = () => console.log(instance.value?.toObject())
const resetTransform = () => elements.value.push({ id: '1234', position: { x: 50, y: 50 }, label: 'Foobar' })
const toggleclasss = () => elements.value.forEach((el) => (el.class = el.class === 'light' ? 'dark' : 'light'))
const toggleclass = () => elements.value.forEach((el) => (el.class = el.class === 'light' ? 'dark' : 'light'))
</script>
<template>
<VueFlow
@@ -45,7 +45,7 @@ const toggleclasss = () => elements.value.forEach((el) => (el.class = el.class =
<div style="position: absolute; right: 10px; top: 10px; z-index: 4">
<button style="margin-right: 5px" @click="resetTransform">reset transform</button>
<button style="margin-right: 5px" @click="updatePos">change pos</button>
<button style="margin-right: 5px" @click="toggleclasss">toggle classs</button>
<button style="margin-right: 5px" @click="toggleclass">toggle class</button>
<button @click="logToObject">toObject</button>
</div>
</VueFlow>