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:24:22 +01:00
committed by Braks
parent 09c56a60b3
commit 83636d4e53
4 changed files with 19 additions and 27 deletions
@@ -1,5 +1,5 @@
import EdgeAnchor from './EdgeAnchor'
import type { Connection, EdgeComponent, EdgeUpdatable, GraphEdge, HandleType } from '~/types'
import type { Connection, EdgeComponent, EdgeUpdatable, GraphEdge, HandleType, MouseTouchEvent } from '~/types'
import { ConnectionMode, Position } from '~/types'
interface Props {
@@ -24,7 +24,6 @@ const EdgeWrapper = defineComponent({
emits,
nodesSelectionActive,
noPanClassName,
getEdges,
getEdgeTypes,
removeSelectedEdges,
findEdge,
@@ -47,8 +46,6 @@ const EdgeWrapper = defineComponent({
const edgeUpdaterType = ref<HandleType>('source')
const mouseEvent = ref<MouseEvent>()
const edgeEl = ref<SVGElement>()
provide(EdgeId, props.id)
@@ -222,13 +219,12 @@ const EdgeWrapper = defineComponent({
mouseOver = false
}
function onEdgeUpdate(connection: Connection) {
if (!connectionExists(connection, getEdges.value)) hooks.emit.update({ edge, connection })
function onEdgeUpdate(event: MouseTouchEvent, connection: Connection) {
hooks.emit.update({ event, edge, connection })
}
function onEdgeUpdateEnd() {
if (!mouseEvent.value) return
hooks.emit.updateEnd({ event: mouseEvent.value, edge })
function onEdgeUpdateEnd(event: MouseTouchEvent) {
hooks.emit.updateEnd({ event, edge })
updating = false
}
@@ -243,8 +239,6 @@ const EdgeWrapper = defineComponent({
edgeUpdaterType.value = type.value
mouseEvent.value = event
hooks.emit.updateStart({ event, edge })
handlePointerDown(event)