Skip to content

Commit

Permalink
#9 chore: Add container bounding box calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
afonsobspinto committed Aug 2, 2022
1 parent 316cb28 commit 3b6c9e9
Show file tree
Hide file tree
Showing 12 changed files with 308 additions and 32 deletions.
113 changes: 104 additions & 9 deletions dist/meta-diagram.cjs.development.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/meta-diagram.cjs.development.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/meta-diagram.cjs.production.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/meta-diagram.cjs.production.min.js.map

Large diffs are not rendered by default.

113 changes: 104 additions & 9 deletions dist/meta-diagram.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/meta-diagram.esm.js.map

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions dist/react-diagrams/MetaNodeModel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ export declare class MetaNodeModel extends NodeModel {
constructor(options?: {});
getGraphPath(): string[];
private calculateLocalPosition;
getContainerBoundingBox(nodes: MetaNodeModel[]): any;
getContainerBoundingBox(metaGraph: MetaNodeModel[]): any;
updateLocalPosition(metaGraph: MetaGraph): void;
updateContainerBoundingBox(nodes: MetaNodeModel[]): void;
setContainerBoundingBox(containerBoundingBox: {
left: number;
top: number;
right: number;
bottom: number;
}): void;
}
7 changes: 5 additions & 2 deletions example/components/widgets/CustomNodeWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ export interface CustomNodeWidgetProps {
export class CustomNodeWidget extends React.Component<CustomNodeWidgetProps> {

render() {
const bb = this.props.model.getOptions()['containerBoundingBox']
const width = bb ? `${bb.getWidth()}px` : "250px"
const height = bb ? `${bb.getHeight()}px` : "200px"
// @ts-ignore
const customNodeStyle = {
zIndex: Math.pow(10, this.props.model.getOptions()['depth']),
border: "solid 2px gray",
borderRadius: "5px",
width: "250px",
height: "200px",
width: width,
height: height,
display: "flex",
alignItems: "flex-start",
justifyContent: "space-between",
Expand Down
1 change: 1 addition & 0 deletions src/helpers/engineHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ export function updateNodeLocalPosition(metaGraph: MetaGraph, node: MetaNodeMode
// @ts-ignore
export function updateNodesContainerBoundingBoxes(nodes: MetaNodeModel[], metaGraph: MetaGraph): void {
nodes.forEach(n => n.setContainerBoundingBox(metaGraph.getNodeContainerBoundingBox(n)))
console.log(nodes)
}
Loading

0 comments on commit 3b6c9e9

Please sign in to comment.