feat: script setup style

* Add Node.vue
This commit is contained in:
Braks
2021-10-20 22:39:54 +02:00
parent 9307c9066a
commit f8728f0d6e
4 changed files with 266 additions and 30 deletions
+13 -13
View File
@@ -1,20 +1,11 @@
import { HandleElement, Position } from '../../types'
import { getDimensions } from '../../utils'
export const getHandleBounds = (nodeElement: HTMLDivElement, scale: number) => {
const bounds = nodeElement.getBoundingClientRect()
return {
source: getHandleBoundsByHandleType('.source', nodeElement, bounds, scale),
target: getHandleBoundsByHandleType('.target', nodeElement, bounds, scale)
}
}
import { HandleElement, Position } from '~/types'
import { getDimensions } from '~/utils'
export const getHandleBoundsByHandleType = (
selector: string,
nodeElement: HTMLDivElement,
parentBounds: ClientRect | DOMRect,
k: number
k: number,
): HandleElement[] | null => {
const handles = nodeElement.querySelectorAll(selector)
@@ -35,7 +26,16 @@ export const getHandleBoundsByHandleType = (
position: handlePosition,
x: (bounds.left - parentBounds.left) / k,
y: (bounds.top - parentBounds.top) / k,
...dimensions
...dimensions,
}
})
}
export const getHandleBounds = (nodeElement: HTMLDivElement, scale: number) => {
const bounds = nodeElement.getBoundingClientRect()
return {
source: getHandleBoundsByHandleType('.source', nodeElement, bounds, scale),
target: getHandleBoundsByHandleType('.target', nodeElement, bounds, scale),
}
}