Dev docs Container
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Siklos 2022-08-04 00:12:06 +02:00
parent 7236fc85bf
commit d959945da7

View file

@ -14,6 +14,10 @@ interface IContainerProps {
const GAP = 50;
export class Container extends React.Component<IContainerProps> {
/**
* Returns A copy of the properties of the Container
* @returns A copy of the properties of the Container
*/
public GetProperties(): Properties {
const properties : Properties = {
...this.props.properties
@ -21,7 +25,10 @@ export class Container extends React.Component<IContainerProps> {
return properties;
}
public * MakeIterator() {
/**
* Returns a Generator iterating of over the children depth-first
*/
public * MakeIterator(): Generator<Container, void, unknown> {
const queue: Container[] = [this];
const visited = new Set<Container>(queue);
while (queue.length > 0) {
@ -40,6 +47,10 @@ export class Container extends React.Component<IContainerProps> {
}
}
/**
* Returns the depth of the container
* @returns The depth of the container
*/
public getDepth() {
let depth = 0;
@ -52,6 +63,10 @@ export class Container extends React.Component<IContainerProps> {
return depth;
}
/**
* Returns the absolute position by iterating to the parent
* @returns The absolute position of the container
*/
public getAbsolutePosition(): [number, number] {
let x = Number(this.props.properties.x);
let y = Number(this.props.properties.y);
@ -64,6 +79,10 @@ export class Container extends React.Component<IContainerProps> {
return [x, y];
}
/**
* Render the container
* @returns Render the container
*/
public render(): React.ReactNode {
const containersElements = this.props.children.map(child => child.render());
const xText = Number(this.props.properties.width) / 2;