chore(docs): update examples with new API for add/remove
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -32,7 +32,7 @@ onNodeDragStop((e) => console.log('drag stop', e))
|
|||||||
* onConnect is called when a new connection is created.
|
* onConnect is called when a new connection is created.
|
||||||
* You can add additional properties to your new edge (like a type or label) or block the creation altogether
|
* You can add additional properties to your new edge (like a type or label) or block the creation altogether
|
||||||
*/
|
*/
|
||||||
onConnect((params) => addEdges([params]))
|
onConnect((params) => addEdges(params))
|
||||||
|
|
||||||
const dark = ref(false)
|
const dark = ref(false)
|
||||||
|
|
||||||
@@ -73,7 +73,9 @@ function toggleClass() {
|
|||||||
<template>
|
<template>
|
||||||
<VueFlow v-model="elements" :class="{ dark }" class="basicflow" :default-viewport="{ zoom: 1.5 }" :min-zoom="0.2" :max-zoom="4">
|
<VueFlow v-model="elements" :class="{ dark }" class="basicflow" :default-viewport="{ zoom: 1.5 }" :min-zoom="0.2" :max-zoom="4">
|
||||||
<Background :pattern-color="dark ? '#FFFFFB' : '#aaa'" gap="8" />
|
<Background :pattern-color="dark ? '#FFFFFB' : '#aaa'" gap="8" />
|
||||||
|
|
||||||
<MiniMap />
|
<MiniMap />
|
||||||
|
|
||||||
<Controls />
|
<Controls />
|
||||||
|
|
||||||
<Panel :position="PanelPosition.TopRight" class="controls">
|
<Panel :position="PanelPosition.TopRight" class="controls">
|
||||||
|
|||||||
@@ -37,10 +37,10 @@ const sourceHandleStyleB = computed(() => ({
|
|||||||
style="display: flex; flex-direction: row; flex-wrap: wrap; justify-content: center; max-width: 90%; margin: auto; gap: 3px"
|
style="display: flex; flex-direction: row; flex-wrap: wrap; justify-content: center; max-width: 90%; margin: auto; gap: 3px"
|
||||||
>
|
>
|
||||||
<template v-for="color of colors" :key="color.name">
|
<template v-for="color of colors" :key="color.name">
|
||||||
<button :title="color.name" :style="{ backgroundColor: color.value }" type="button" @click="onSelect(color)"></button>
|
<button :title="color.name" :style="{ backgroundColor: color.value }" type="button" @click="onSelect(color)" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<button class="animated-bg-gradient" title="gradient" type="button" @click="onGradient"></button>
|
<button class="animated-bg-gradient" title="gradient" type="button" @click="onGradient" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Handle id="a" type="source" :position="Position.Right" :style="sourceHandleStyleA" />
|
<Handle id="a" type="source" :position="Position.Right" :style="sourceHandleStyleA" />
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ function onDragOver(event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onConnect((params) => addEdges([params]))
|
onConnect((params) => addEdges(params))
|
||||||
|
|
||||||
function onDrop(event) {
|
function onDrop(event) {
|
||||||
const type = event.dataTransfer?.getData('application/vueflow')
|
const type = event.dataTransfer?.getData('application/vueflow')
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ export default {
|
|||||||
}"
|
}"
|
||||||
class="nodrag nopan"
|
class="nodrag nopan"
|
||||||
>
|
>
|
||||||
<button class="edgebutton" @click="removeEdges([id])">×</button>
|
<button class="edgebutton" @click="removeEdges(id)">×</button>
|
||||||
</div>
|
</div>
|
||||||
</EdgeLabelRenderer>
|
</EdgeLabelRenderer>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { MiniMap } from '@vue-flow/minimap'
|
|||||||
|
|
||||||
const { nodes, addNodes, addEdges, onConnect, dimensions } = useVueFlow()
|
const { nodes, addNodes, addEdges, onConnect, dimensions } = useVueFlow()
|
||||||
|
|
||||||
onConnect((params) => addEdges([params]))
|
onConnect((params) => addEdges(params))
|
||||||
|
|
||||||
function addRandomNode() {
|
function addRandomNode() {
|
||||||
const nodeId = (nodes.value.length + 1).toString()
|
const nodeId = (nodes.value.length + 1).toString()
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const { onConnect, addEdges } = useVueFlow()
|
|||||||
|
|
||||||
const elements = ref(initialElements)
|
const elements = ref(initialElements)
|
||||||
|
|
||||||
onConnect((params) => addEdges([params]))
|
onConnect((params) => addEdges(params))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ const captureZoomClick = ref(false)
|
|||||||
|
|
||||||
const captureZoomScroll = ref(false)
|
const captureZoomScroll = ref(false)
|
||||||
|
|
||||||
onConnect((params) => addEdges([params]))
|
onConnect((params) => addEdges(params))
|
||||||
|
|
||||||
onNodeDragStart((e) => console.log('drag start', e))
|
onNodeDragStart((e) => console.log('drag start', e))
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ const { onConnect, addEdges, addNodes } = useVueFlow({
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
onConnect((params) => addEdges([params]))
|
onConnect((params) => addEdges(params))
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// add nodes to parent
|
// add nodes to parent
|
||||||
|
|||||||
Reference in New Issue
Block a user