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,
|
z: node.value.computedPosition.z,
|
||||||
}
|
}
|
||||||
if (node.value.parentNode) {
|
if (node.value.parentNode) {
|
||||||
node.value.computedPosition = getXYZPos(node.value, xyzPos)
|
node.value.computedPosition = getXYZPos(node.value.parentNode, xyzPos)
|
||||||
} else {
|
} else {
|
||||||
node.value.computedPosition = xyzPos
|
node.value.computedPosition = xyzPos
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ export interface Connection {
|
|||||||
targetHandle?: string
|
targetHandle?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type OnConnectFunc = (connection: Connection) => void
|
|
||||||
export type OnConnectStartParams = {
|
export type OnConnectStartParams = {
|
||||||
nodeId?: string
|
nodeId?: string
|
||||||
handleId?: string
|
handleId?: string
|
||||||
|
|||||||
+1
-1
@@ -61,7 +61,7 @@ export interface NodeProps<T = any> {
|
|||||||
dragging?: boolean
|
dragging?: boolean
|
||||||
isValidTargetPos?: ValidConnectionFunc
|
isValidTargetPos?: ValidConnectionFunc
|
||||||
isValidSourcePos?: ValidConnectionFunc
|
isValidSourcePos?: ValidConnectionFunc
|
||||||
parentNode?: GraphNode<T>[]
|
parentNode?: any
|
||||||
isParent?: boolean
|
isParent?: boolean
|
||||||
children?: Node<T>[]
|
children?: Node<T>[]
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-8
@@ -327,14 +327,12 @@ export const getTransformForBounds = (
|
|||||||
return [x, y, clampedZoom]
|
return [x, y, clampedZoom]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getXYZPos = (node: GraphNode, result: XYZPosition): XYZPosition => {
|
export const getXYZPos = (parentNode: GraphNode, computedPosition: XYZPosition): XYZPosition => {
|
||||||
if (!node.parentNode) return result
|
return {
|
||||||
return getXYZPos(node.parentNode, {
|
x: computedPosition.x + parentNode.computedPosition.x,
|
||||||
x: result.x + node.parentNode.computedPosition.x,
|
y: computedPosition.y + parentNode.computedPosition.y,
|
||||||
y: result.y + node.parentNode.computedPosition.y,
|
z: parentNode.computedPosition.z > computedPosition.z ? parentNode.computedPosition.z : computedPosition.z,
|
||||||
z:
|
}
|
||||||
node.parentNode.computedPosition.z > node.computedPosition.z ? node.parentNode.computedPosition.z : node.computedPosition.z,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const isParentSelected = (node: GraphNode): boolean => {
|
export const isParentSelected = (node: GraphNode): boolean => {
|
||||||
|
|||||||
Reference in New Issue
Block a user