chore(examples): cleanup examples
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { VueFlow, isNode, useVueFlow } from '@vue-flow/core'
|
|
||||||
import type { Elements } from '@vue-flow/core'
|
import type { Elements } from '@vue-flow/core'
|
||||||
|
import { VueFlow, isNode, useVueFlow } from '@vue-flow/core'
|
||||||
|
|
||||||
import { Background } from '@vue-flow/background'
|
import { Background } from '@vue-flow/background'
|
||||||
import { Controls } from '@vue-flow/controls'
|
import { Controls } from '@vue-flow/controls'
|
||||||
@@ -14,12 +14,13 @@ const elements = ref<Elements>([
|
|||||||
{ id: 'e1-2', source: '1', target: '2', animated: true },
|
{ id: 'e1-2', source: '1', target: '2', animated: true },
|
||||||
{ id: 'e1-3', source: '1', target: '3' },
|
{ id: 'e1-3', source: '1', target: '3' },
|
||||||
])
|
])
|
||||||
const { onPaneReady, onNodeDragStop, onConnect, addEdges, setTransform, toObject } = useVueFlow({
|
const { onNodeDragStop, onConnect, addEdges, setTransform, toObject } = useVueFlow({
|
||||||
defaultZoom: 1.5,
|
|
||||||
minZoom: 0.2,
|
minZoom: 0.2,
|
||||||
maxZoom: 4,
|
maxZoom: 4,
|
||||||
connectOnClick: true,
|
connectOnClick: true,
|
||||||
fitViewOnInit: false,
|
fitViewOnInit: false,
|
||||||
|
selectionOnDrag: true,
|
||||||
|
panOnDrag: [2],
|
||||||
})
|
})
|
||||||
|
|
||||||
onNodeDragStop((e) => console.log('drag stop', e))
|
onNodeDragStop((e) => console.log('drag stop', e))
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { Elements, FlowEvents, VueFlowStore } from '@vue-flow/core'
|
import type { Elements, FlowEvents, VueFlowStore } from '@vue-flow/core'
|
||||||
import { VueFlow, addEdge, isNode } from '@vue-flow/core'
|
import { VueFlow, isNode } from '@vue-flow/core'
|
||||||
|
|
||||||
import { Background } from '@vue-flow/background'
|
import { Background } from '@vue-flow/background'
|
||||||
import { Controls } from '@vue-flow/controls'
|
import { Controls } from '@vue-flow/controls'
|
||||||
@@ -50,7 +50,7 @@ export default defineComponent({
|
|||||||
this.instance = instance as any
|
this.instance = instance as any
|
||||||
},
|
},
|
||||||
onConnect(params: FlowEvents['connect']) {
|
onConnect(params: FlowEvents['connect']) {
|
||||||
addEdge(params, this.elements)
|
this.instance?.addEdges([params])
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -67,21 +67,16 @@ onMounted(() => {
|
|||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
const { onPaneReady } = useVueFlow({
|
useVueFlow({
|
||||||
connectionMode: ConnectionMode.Loose,
|
connectionMode: ConnectionMode.Loose,
|
||||||
connectionLineStyle,
|
connectionLineStyle,
|
||||||
snapToGrid: true,
|
snapToGrid: true,
|
||||||
snapGrid,
|
snapGrid,
|
||||||
defaultZoom: 1.5,
|
|
||||||
})
|
|
||||||
onPaneReady((i) => {
|
|
||||||
i.fitView()
|
|
||||||
console.log('flow loaded:', i)
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VueFlow v-model="elements" :style="{ backgroundColor: bgColor }">
|
<VueFlow v-model="elements" fit-view-on-init :style="{ backgroundColor: bgColor }">
|
||||||
<template #node-selectorNode="props">
|
<template #node-selectorNode="props">
|
||||||
<ColorSelectorNode v-bind="props" />
|
<ColorSelectorNode v-bind="props" />
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ const onDrop = (event: DragEvent) => {
|
|||||||
position,
|
position,
|
||||||
label: `${type} node`,
|
label: `${type} node`,
|
||||||
} as Node
|
} as Node
|
||||||
|
|
||||||
addNodes([newNode])
|
addNodes([newNode])
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user