fix(nodes): skip applying node extent on mount

This commit is contained in:
braks
2022-09-12 20:08:49 +02:00
committed by Braks
parent 59bd0090cd
commit 018d711fc6
2 changed files with 5 additions and 16 deletions
@@ -79,16 +79,10 @@ const updatePosition = (nodePos: XYZPosition, parentPos?: XYZPosition) => {
const updateInternals = () => {
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(
{
...nextPos,
x: node.position.x,
y: node.position.y,
z: node.computedPosition.z ? node.computedPosition.z : node.selected ? 1000 : 0,
},
parentNode ? { ...parentNode.computedPosition } : undefined,
@@ -127,14 +121,9 @@ onMounted(() => {
() => parentNode?.dimensions,
],
([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 = {
...nextPos,
x: newX,
y: newY,
z: node.selected ? 1000 : 0,
}
+1 -1
View File
@@ -24,7 +24,7 @@ export const getDimensions = (node: HTMLElement): Dimensions => ({
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 => ({
x: clamp(position.x, extent[0][0], extent[1][0]),