fps-flow
Version:
An easy and simple flow ui created by First Penny
46 lines (45 loc) • 1.58 kB
TypeScript
import { NewNode, SavedFlow, SavedNode } from "./interface";
import { FpNode } from "./node";
import "./style.scss";
export default class FpFlow {
private hostContainer;
private savedFlow?;
nodes: FpNode[];
private flowContainer;
private flowContainerScale;
private currentScale;
private canvas;
connectionFrom: number;
connections: {
from: number;
to: number;
}[];
ctx: CanvasRenderingContext2D;
constructor(hostContainer: HTMLElement, savedFlow?: SavedFlow);
/**
* Adds a node to the flow container
*/
addNode(node?: SavedNode | NewNode): FpNode;
addChild(nodeId: number, child: HTMLElement): void;
getFlowInfo(): SavedFlow;
private renderSavedFLow;
private stopConnection;
private handleConnection;
private drawConnections;
private drawConnection;
private removeConnectionHighlight;
/**
* Used for creating the container bed where the background to container size would be determined
*/
private createFlowContainer;
/**
* Passed as callback to nodes to handle from inside how much do all the items need to move. Just increasing width and height won't work when we need
* to move the node left or top exceeding available space. The scrolling and width are handled internally by node as they have access to flowContainer
* @param direction direction where the node moves
* @param amount how much it moves
*/
private handleNodeEdgeMovement;
private watchZoom;
private get newNodeId();
private removeNode;
}