fix(nodes): trigger computedPosition watcher when selected changes
* z-index will not change back if selected does not trigger a change
This commit is contained in:
@@ -57,12 +57,18 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
[() => node.value.position, () => store.getNode(node.value.parentNode!)],
|
[
|
||||||
|
() => node.value.position,
|
||||||
|
() => store.getNode(node.value.parentNode!)?.computedPosition,
|
||||||
|
() => node.value.selected,
|
||||||
|
() => store.getNode(node.value.parentNode!)?.selected,
|
||||||
|
],
|
||||||
([pos, parent]) => {
|
([pos, parent]) => {
|
||||||
const xyzPos = {
|
const xyzPos = {
|
||||||
...pos,
|
...pos,
|
||||||
z: node.value.dragging || node.value.selected ? 1000 : node.value.computedPosition.z,
|
z: node.value.dragging || node.value.selected ? 1000 : 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parent) {
|
if (parent) {
|
||||||
node.value.computedPosition = getXYZPos(parent, xyzPos)
|
node.value.computedPosition = getXYZPos(parent, xyzPos)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -339,11 +339,11 @@ export const getTransformForBounds = (
|
|||||||
return [x, y, clampedZoom]
|
return [x, y, clampedZoom]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getXYZPos = (parentNode: GraphNode, computedPosition: XYZPosition): XYZPosition => {
|
export const getXYZPos = (parentPos: XYZPosition, computedPosition: XYZPosition): XYZPosition => {
|
||||||
return {
|
return {
|
||||||
x: computedPosition.x + parentNode.computedPosition.x,
|
x: computedPosition.x + parentPos.x,
|
||||||
y: computedPosition.y + parentNode.computedPosition.y,
|
y: computedPosition.y + parentPos.y,
|
||||||
z: parentNode.computedPosition.z > computedPosition.z ? parentNode.computedPosition.z : computedPosition.z,
|
z: parentPos.z > computedPosition.z ? parentPos.z : computedPosition.z,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user