feat(core): store handle validation in store state

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2023-03-08 16:32:11 +01:00
committed by Braks
parent 9b9942c7f7
commit 9fb551569d
5 changed files with 20 additions and 12 deletions
+2 -7
View File
@@ -8,6 +8,7 @@ import type {
HandleType,
NodeHandleBounds,
ValidConnectionFunc,
ValidHandleResult,
XYPosition,
} from '~/types'
@@ -64,12 +65,6 @@ export function getClosestHandle(
return closestHandle
}
interface Result {
handleDomNode: Element | null
isValid: boolean
connection: Connection
}
// checks if and returns connection in fom of an object { source: 123, target: 312 }
export function isValidHandle(
event: MouseEvent | TouchEvent,
@@ -90,7 +85,7 @@ export function isValidHandle(
const handleBelow = doc.elementFromPoint(x, y)
const handleToCheck = handleBelow?.classList.contains('vue-flow__handle') ? handleBelow : handleDomNode
const result: Result = {
const result: ValidHandleResult = {
handleDomNode: handleToCheck,
isValid: false,
connection: { source: '', target: '', sourceHandle: null, targetHandle: null },