refactor(core): pass original event to edge update event params

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2023-02-15 00:08:11 +01:00
committed by Braks
parent 09c56a60b3
commit 83636d4e53
4 changed files with 19 additions and 27 deletions

View File

@@ -14,14 +14,15 @@ const elements = ref<Elements>([
{ id: 'e1-2', source: '1', target: '2', animated: true },
{ id: 'e1-3', source: '1', target: '3' },
])
const { onNodeDragStop, onConnect, addEdges, setTransform, toObject } = useVueFlow({
const { onNodeDragStop, onEdgeClick, onConnect, addEdges, setTransform, toObject } = useVueFlow({
minZoom: 0.2,
maxZoom: 4,
connectOnClick: true,
fitViewOnInit: false,
})
onNodeDragStop((e) => console.log('drag stop', e))
onNodeDragStop((e) => console.log('drag stop', e.event))
onEdgeClick(console.log)
onConnect((params) => addEdges([params]))
const updatePos = () =>

View File

@@ -1,10 +1,8 @@
<script lang="ts" setup>
import type { Elements } from '@vue-flow/core'
<script setup>
import { VueFlow } from '@vue-flow/core'
import { Background, BackgroundVariant } from '@vue-flow/background'
import ConnectionLine from './ConnectionLine.vue'
const elements = ref<Elements>([
const elements = ref([
{
id: '1',
type: 'input',
@@ -16,9 +14,8 @@ const elements = ref<Elements>([
<template>
<VueFlow v-model="elements">
<template #connection-line="props">
<ConnectionLine v-bind="props" />
<template #connection-line="{ sourceX, sourceY, targetX, targetY }">
<ConnectionLine :source-x="sourceX" :source-y="sourceY" :target-x="targetX" :target-y="targetY" />
</template>
<Background :variant="BackgroundVariant.Lines" />
</VueFlow>
</template>