fix(handles): connectOnClick reset before connections can be made

This commit is contained in:
braks
2022-10-13 23:23:43 +02:00
committed by Braks
parent 18a812db64
commit d420feaf48
4 changed files with 28 additions and 13 deletions
+14 -4
View File
@@ -370,8 +370,12 @@ export default (state: State, getters: ComputedGetters): Actions => {
const applyEdgeChanges: Actions['applyEdgeChanges'] = (changes) => applyChanges(changes, state.edges)
const startConnection: Actions['startConnection'] = (startHandle, position, event) => {
state.connectionStartHandle = startHandle
const startConnection: Actions['startConnection'] = (startHandle, position, event, isClick = false) => {
if (isClick) {
state.connectionClickStartHandle = startHandle
} else {
state.connectionStartHandle = startHandle
}
if (position) state.connectionPosition = position
@@ -387,9 +391,15 @@ export default (state: State, getters: ComputedGetters): Actions => {
state.connectionPosition = position
}
const endConnection: Actions['endConnection'] = (event) => {
const endConnection: Actions['endConnection'] = (event, isClick) => {
state.connectionPosition = { x: NaN, y: NaN }
state.connectionStartHandle = null
if (isClick) {
state.connectionClickStartHandle = null
} else {
state.connectionStartHandle = null
}
state.hooks.connectEnd.trigger(event)
}
+1
View File
@@ -84,6 +84,7 @@ const defaultState = (): State => ({
},
connectionMode: ConnectionMode.Loose,
connectionStartHandle: null,
connectionClickStartHandle: null,
connectionPosition: { x: NaN, y: NaN },
connectOnClick: true,