ensuring triggers & conditions are not too close to one another
This commit is contained in:
1 parent
4aedd9323b
commit
d8a2dd53d5
7 files changed
+20
-18
No files matched your search
@@ -13,8 +13,8 @@ export const DEFAULT_DIMS: DAGDims = {
|
||||
width: NODE_WIDTH,
|
||||
},
|
||||
distanceFactor: {
|
||||
node: 1.5,
|
||||
collection: 1,
|
||||
node: [1.5, 1.5],
|
||||
collection: [1.25, 1.05],
|
||||
},
|
||||
position: {
|
||||
x: 50,
|
||||
|
||||
@@ -9,11 +9,11 @@ export const moveAlong = (
|
||||
reversed: boolean = false
|
||||
): XYPosition => {
|
||||
const moveOnY = {
|
||||
y: startPoint.y + dims[by].height * dims.distanceFactor.node * increment,
|
||||
y: startPoint.y + dims[by].height * dims.distanceFactor[by][0] * increment,
|
||||
x: startPoint.x,
|
||||
};
|
||||
const moveOnX = {
|
||||
x: startPoint.x + dims[by].width * dims.distanceFactor.node * increment,
|
||||
x: startPoint.x + dims[by].width * dims.distanceFactor[by][1] * increment,
|
||||
y: startPoint.y,
|
||||
};
|
||||
if (reversed) {
|
||||
@@ -30,11 +30,14 @@ export const moveAlongRelativeTo = (
|
||||
) =>
|
||||
dims.flipped
|
||||
? {
|
||||
x: relatedPos.x + dims.distanceFactor.node * dims[incrementBy].width,
|
||||
x:
|
||||
relatedPos.x +
|
||||
dims.distanceFactor.node[0] * 1.5 * dims[incrementBy].width,
|
||||
y: offsetPos.y,
|
||||
}
|
||||
: {
|
||||
y: relatedPos.y + dims.distanceFactor.node * dims[incrementBy].height,
|
||||
y:
|
||||
relatedPos.y + dims.distanceFactor.node[1] * dims[incrementBy].height,
|
||||
x: offsetPos.x,
|
||||
};
|
||||
|
||||
@@ -46,12 +49,12 @@ export const moveFromTo = (
|
||||
): XYPosition => {
|
||||
if (!dims.flipped) {
|
||||
return {
|
||||
x: startPoint.x + dims[from].width * dims.distanceFactor.collection,
|
||||
x: startPoint.x + dims[from].width * dims.distanceFactor[to][0],
|
||||
y: startPoint.y + (dims[from].height - dims[to].height) / 2,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
y: startPoint.y + dims[from].height * dims.distanceFactor.collection,
|
||||
y: startPoint.y + dims[from].height * dims.distanceFactor[to][1],
|
||||
x: startPoint.x + (dims[from].width - dims[to].width) / 2,
|
||||
};
|
||||
}
|
||||
@@ -62,6 +65,6 @@ export const offsetBy = (
|
||||
position: XYPosition,
|
||||
dims: DAGDims
|
||||
): XYPosition => ({
|
||||
x: position.x + dims.distanceFactor[by] * dims[by].width,
|
||||
y: position.y + dims.distanceFactor[by] * dims[by].height,
|
||||
x: position.x + dims.distanceFactor[by][0] * dims[by].width,
|
||||
y: position.y + dims.distanceFactor[by][1] * dims[by].height,
|
||||
});
|
||||
@@ -44,7 +44,6 @@ export const useAutomationNodes = (
|
||||
nodeIndex: 0,
|
||||
})
|
||||
);
|
||||
|
||||
outputState.extend(
|
||||
makeConditionNodes(automation.condition, {
|
||||
...args,
|
||||
@@ -338,7 +337,7 @@ export const makeChooseeNodes = makeSpecialNodeMaker(
|
||||
let addPos = distance.moveAlong(
|
||||
"node",
|
||||
elseOutput.data.nodes[0].position,
|
||||
1 / args.dims.distanceFactor.node,
|
||||
1 / args.dims.distanceFactor.node[0],
|
||||
args.dims,
|
||||
true
|
||||
);
|
||||
|
||||
@@ -20,7 +20,7 @@ export type DAGEntities = {
|
||||
};
|
||||
export type DAGDims = DAGEntities & {
|
||||
position: XYPosition;
|
||||
distanceFactor: Record<keyof DAGEntities, number>;
|
||||
distanceFactor: Record<keyof DAGEntities, [number, number]>;
|
||||
flipped: boolean;
|
||||
};
|
||||
export type ElementMakerBaseProps = {
|
||||
|
||||
@@ -62,14 +62,14 @@ const Template: ComponentStory<typeof ButtonNode> = (args) => {
|
||||
? {
|
||||
x:
|
||||
DEFAULT_DIMS.node.width *
|
||||
DEFAULT_DIMS.distanceFactor.node,
|
||||
DEFAULT_DIMS.distanceFactor.node[0],
|
||||
y: 0,
|
||||
}
|
||||
: {
|
||||
x: 0,
|
||||
y:
|
||||
DEFAULT_DIMS.node.height *
|
||||
DEFAULT_DIMS.distanceFactor.node,
|
||||
DEFAULT_DIMS.distanceFactor.node[1],
|
||||
},
|
||||
},
|
||||
dims,
|
||||
|
||||
@@ -179,7 +179,7 @@ export const ReturnTarget: ComponentStory<typeof Demo> = (args) => {
|
||||
50 +
|
||||
args.height *
|
||||
2 *
|
||||
DEFAULT_DIMS.distanceFactor.collection,
|
||||
DEFAULT_DIMS.distanceFactor.collection[1],
|
||||
},
|
||||
},
|
||||
DEFAULT_DIMS,
|
||||
|
||||
@@ -68,12 +68,12 @@ export const Colors: ComponentStory<typeof SequenceNode> = (args) => {
|
||||
x:
|
||||
50 +
|
||||
DEFAULT_DIMS.node.height *
|
||||
DEFAULT_DIMS.distanceFactor.node *
|
||||
DEFAULT_DIMS.distanceFactor.node[0] *
|
||||
i,
|
||||
y:
|
||||
50 +
|
||||
DEFAULT_DIMS.node.height *
|
||||
DEFAULT_DIMS.distanceFactor.node *
|
||||
DEFAULT_DIMS.distanceFactor.node[1] *
|
||||
i,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user