Files
vue-flow/package/src/components/UserSelection/utils.ts
2022-05-11 22:10:40 +02:00

14 lines
377 B
TypeScript

import type { XYPosition } from '../../types'
export function getMousePosition(event: MouseEvent): XYPosition | void {
const flowNode = (event.target as Element).closest('.vue-flow')
if (!flowNode) return
const containerBounds = flowNode.getBoundingClientRect()
return {
x: event.clientX - containerBounds.left,
y: event.clientY - containerBounds.top,
}
}