fix(nodes): correctly calculate xyzpos from parent
Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -32,7 +32,7 @@ watch([() => node.value.position, () => node.value.parentNode?.position], () =>
|
||||
z: node.value.computedPosition.z,
|
||||
}
|
||||
if (node.value.parentNode) {
|
||||
node.value.computedPosition = getXYZPos(node.value, xyzPos)
|
||||
node.value.computedPosition = getXYZPos(node.value.parentNode, xyzPos)
|
||||
} else {
|
||||
node.value.computedPosition = xyzPos
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ export interface Connection {
|
||||
targetHandle?: string
|
||||
}
|
||||
|
||||
export type OnConnectFunc = (connection: Connection) => void
|
||||
export type OnConnectStartParams = {
|
||||
nodeId?: string
|
||||
handleId?: string
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ export interface NodeProps<T = any> {
|
||||
dragging?: boolean
|
||||
isValidTargetPos?: ValidConnectionFunc
|
||||
isValidSourcePos?: ValidConnectionFunc
|
||||
parentNode?: GraphNode<T>[]
|
||||
parentNode?: any
|
||||
isParent?: boolean
|
||||
children?: Node<T>[]
|
||||
}
|
||||
|
||||
+6
-8
@@ -327,14 +327,12 @@ export const getTransformForBounds = (
|
||||
return [x, y, clampedZoom]
|
||||
}
|
||||
|
||||
export const getXYZPos = (node: GraphNode, result: XYZPosition): XYZPosition => {
|
||||
if (!node.parentNode) return result
|
||||
return getXYZPos(node.parentNode, {
|
||||
x: result.x + node.parentNode.computedPosition.x,
|
||||
y: result.y + node.parentNode.computedPosition.y,
|
||||
z:
|
||||
node.parentNode.computedPosition.z > node.computedPosition.z ? node.parentNode.computedPosition.z : node.computedPosition.z,
|
||||
})
|
||||
export const getXYZPos = (parentNode: GraphNode, computedPosition: XYZPosition): XYZPosition => {
|
||||
return {
|
||||
x: computedPosition.x + parentNode.computedPosition.x,
|
||||
y: computedPosition.y + parentNode.computedPosition.y,
|
||||
z: parentNode.computedPosition.z > computedPosition.z ? parentNode.computedPosition.z : computedPosition.z,
|
||||
}
|
||||
}
|
||||
|
||||
export const isParentSelected = (node: GraphNode): boolean => {
|
||||
|
||||
Reference in New Issue
Block a user