fix(nodes): skip applying node extent on mount
This commit is contained in:
@@ -79,16 +79,10 @@ const updatePosition = (nodePos: XYZPosition, parentPos?: XYZPosition) => {
|
|||||||
const updateInternals = () => {
|
const updateInternals = () => {
|
||||||
if (nodeElement.value) updateNodeDimensions([{ id, nodeElement: nodeElement.value, forceUpdate: true }])
|
if (nodeElement.value) updateNodeDimensions([{ id, nodeElement: nodeElement.value, forceUpdate: true }])
|
||||||
|
|
||||||
const currentExtent = applyExtent(node, nodeExtent, parentNode)
|
|
||||||
|
|
||||||
const nextPos =
|
|
||||||
currentExtent && typeof currentExtent !== 'string'
|
|
||||||
? clampPosition(node.position, currentExtent as CoordinateExtent)
|
|
||||||
: node.position
|
|
||||||
|
|
||||||
updatePosition(
|
updatePosition(
|
||||||
{
|
{
|
||||||
...nextPos,
|
x: node.position.x,
|
||||||
|
y: node.position.y,
|
||||||
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,
|
||||||
@@ -127,14 +121,9 @@ onMounted(() => {
|
|||||||
() => parentNode?.dimensions,
|
() => parentNode?.dimensions,
|
||||||
],
|
],
|
||||||
([newX, newY, parentX, parentY, parentZ]) => {
|
([newX, newY, parentX, parentY, parentZ]) => {
|
||||||
const currentExtent = applyExtent(node, nodeExtent, parentNode)
|
|
||||||
const nextPos =
|
|
||||||
currentExtent && typeof currentExtent !== 'string'
|
|
||||||
? clampPosition({ x: newX, y: newY }, currentExtent as CoordinateExtent)
|
|
||||||
: { x: newX, y: newY }
|
|
||||||
|
|
||||||
const xyzPos = {
|
const xyzPos = {
|
||||||
...nextPos,
|
x: newX,
|
||||||
|
y: newY,
|
||||||
z: node.selected ? 1000 : 0,
|
z: node.selected ? 1000 : 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export const getDimensions = (node: HTMLElement): Dimensions => ({
|
|||||||
height: node.offsetHeight,
|
height: node.offsetHeight,
|
||||||
})
|
})
|
||||||
|
|
||||||
export const clamp = (val: number, min = 0, max = 1): number => Math.min(Math.max(val, min), max)
|
export const clamp = (val: number, min = 0, max = 1) => Math.min(Math.max(val, min), max)
|
||||||
|
|
||||||
export const clampPosition = (position: XYPosition, extent: CoordinateExtent): XYPosition => ({
|
export const clampPosition = (position: XYPosition, extent: CoordinateExtent): XYPosition => ({
|
||||||
x: clamp(position.x, extent[0][0], extent[1][0]),
|
x: clamp(position.x, extent[0][0], extent[1][0]),
|
||||||
|
|||||||
Reference in New Issue
Block a user