refactor(core,nodes): elevate selected nodes zIndex *by* 1000 instead *to* 1000
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { isNumber } from '@vueuse/core'
|
||||||
import type { GraphNode, HandleConnectable, NodeComponent, SnapGrid, XYZPosition } from '../../types'
|
import type { GraphNode, HandleConnectable, NodeComponent, SnapGrid, XYZPosition } from '../../types'
|
||||||
|
|
||||||
const { id, type, name, draggable, selectable, connectable, ...props } = defineProps<{
|
const { id, type, name, draggable, selectable, connectable, ...props } = defineProps<{
|
||||||
@@ -119,10 +120,11 @@ watch(
|
|||||||
const xyzPos = {
|
const xyzPos = {
|
||||||
x: newX,
|
x: newX,
|
||||||
y: newY,
|
y: newY,
|
||||||
z: node.selected ? 1000 : 0,
|
// if a zIndex style is present, add 1000 to it
|
||||||
|
z: (isNumber(getStyle.value.zIndex) ? getStyle.value.zIndex : 0) + (node.selected ? 1000 : 0),
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePosition(xyzPos, parentX && parentY ? { x: parentX, y: parentY, z: parentZ! } : undefined)
|
updatePosition(xyzPos, parentX && parentY ? { x: parentX, y: parentY, z: parentZ || 0 } : undefined)
|
||||||
},
|
},
|
||||||
{ flush: 'post' },
|
{ flush: 'post' },
|
||||||
)
|
)
|
||||||
@@ -142,6 +144,7 @@ function updateInternals() {
|
|||||||
{
|
{
|
||||||
x: node.position.x,
|
x: node.position.x,
|
||||||
y: node.position.y,
|
y: node.position.y,
|
||||||
|
// should be using computedPosition.z but in case it's not present, fall back to selected state
|
||||||
z: node.computedPosition.z ? node.computedPosition.z : node.selected ? 1000 : 0,
|
z: node.computedPosition.z ? node.computedPosition.z : node.selected ? 1000 : 0,
|
||||||
},
|
},
|
||||||
parentNode ? { ...parentNode.computedPosition } : undefined,
|
parentNode ? { ...parentNode.computedPosition } : undefined,
|
||||||
|
|||||||
Reference in New Issue
Block a user