This commit is contained in:
parent
7236fc85bf
commit
d959945da7
1 changed files with 20 additions and 1 deletions
|
@ -14,6 +14,10 @@ interface IContainerProps {
|
||||||
const GAP = 50;
|
const GAP = 50;
|
||||||
|
|
||||||
export class Container extends React.Component<IContainerProps> {
|
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 {
|
public GetProperties(): Properties {
|
||||||
const properties : Properties = {
|
const properties : Properties = {
|
||||||
...this.props.properties
|
...this.props.properties
|
||||||
|
@ -21,7 +25,10 @@ export class Container extends React.Component<IContainerProps> {
|
||||||
return properties;
|
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 queue: Container[] = [this];
|
||||||
const visited = new Set<Container>(queue);
|
const visited = new Set<Container>(queue);
|
||||||
while (queue.length > 0) {
|
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() {
|
public getDepth() {
|
||||||
let depth = 0;
|
let depth = 0;
|
||||||
|
|
||||||
|
@ -52,6 +63,10 @@ export class Container extends React.Component<IContainerProps> {
|
||||||
return depth;
|
return depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the absolute position by iterating to the parent
|
||||||
|
* @returns The absolute position of the container
|
||||||
|
*/
|
||||||
public getAbsolutePosition(): [number, number] {
|
public getAbsolutePosition(): [number, number] {
|
||||||
let x = Number(this.props.properties.x);
|
let x = Number(this.props.properties.x);
|
||||||
let y = Number(this.props.properties.y);
|
let y = Number(this.props.properties.y);
|
||||||
|
@ -64,6 +79,10 @@ export class Container extends React.Component<IContainerProps> {
|
||||||
return [x, y];
|
return [x, y];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the container
|
||||||
|
* @returns Render the container
|
||||||
|
*/
|
||||||
public render(): React.ReactNode {
|
public render(): React.ReactNode {
|
||||||
const containersElements = this.props.children.map(child => child.render());
|
const containersElements = this.props.children.map(child => child.render());
|
||||||
const xText = Number(this.props.properties.width) / 2;
|
const xText = Number(this.props.properties.width) / 2;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue