cleaned up choose + distance between nodes

This commit is contained in:
ari committed 2022-07-19 20:27:02 -04:00
1 parent fabb5612d5
commit dcf577f84c
6 files changed
+221 -206

No files matched your search

@@ -32,12 +32,13 @@ export const moveAlongRelativeTo = (
? {
x:
relatedPos.x +
dims.distanceFactor.node[0] * 1.5 * dims[incrementBy].width,
dims.distanceFactor[incrementBy][0] * dims[incrementBy].width,
y: offsetPos.y,
}
: {
y:
relatedPos.y + dims.distanceFactor.node[1] * dims[incrementBy].height,
relatedPos.y +
dims.distanceFactor[incrementBy][1] * dims[incrementBy].height,
x: offsetPos.x,
};
@@ -45,16 +46,21 @@ export const moveFromTo = (
from: keyof DAGEntities,
to: keyof DAGEntities,
startPoint: XYPosition,
dims: DAGDims
dims: DAGDims,
byFrom: boolean = false
): XYPosition => {
if (!dims.flipped) {
return {
x: startPoint.x + dims[from].width * dims.distanceFactor[to][0],
x:
startPoint.x +
dims[from].width * dims.distanceFactor[byFrom ? from : to][0],
y: startPoint.y + (dims[from].height - dims[to].height) / 2,
};
} else {
return {
y: startPoint.y + dims[from].height * dims.distanceFactor[to][1],
y:
startPoint.y +
dims[from].height * dims.distanceFactor[byFrom ? from : to][1],
x: startPoint.x + (dims[from].width - dims[to].width) / 2,
};
}
@@ -65,6 +71,6 @@ export const offsetBy = (
position: XYPosition,
dims: DAGDims
): XYPosition => ({
x: position.x + dims.distanceFactor[by][0] * dims[by].width,
y: position.y + dims.distanceFactor[by][1] * dims[by].height,
x: position.x + dims.distanceFactor[by][0] * 0.9 * dims[by].width,
y: position.y + dims.distanceFactor[by][1] * 0.9 * dims[by].height,
});