UNPKG

@gravity-ui/graph

Version:

Modern graph editor component

61 lines (60 loc) 2.54 kB
import { EventedComponent } from "../../components/canvas/EventedComponent/EventedComponent"; import { TGraphLayerContext } from "../../components/canvas/layers/graphLayer/GraphLayer"; import { Component } from "../../lib"; import { TComponentProps, TComponentState } from "../../lib/Component"; import { ComponentDescriptor } from "../../lib/CoreComponent"; export type TCameraProps = TComponentProps & { root?: HTMLDivElement; children: ComponentDescriptor[]; }; export declare class Camera extends EventedComponent<TCameraProps, TComponentState, TGraphLayerContext> { private camera; private ownerDocument; private lastDragEvent?; private removeAutoPanScheduler?; private lastMouseEvent?; private unsubscribeCamera?; constructor(props: TCameraProps, parent: Component); private handleCameraStateChange; protected handleClick: () => void; protected setRoot(): void; protected addWheelListener(root?: HTMLDivElement): void; protected propsChanged(nextProps: TCameraProps): void; protected unmount(): void; private startAutoPanning; private stopAutoPanning; private handleMouseMoveForAutoPan; private performAutoPan; private handleMouseDownEvent; /** * DragService handles draggable graph components; camera pan is deferred in that case. */ private isTargetDraggable; private onDragStart; private onDragUpdate; private onDragEnd; /** * Applies a pan delta from wheel input. * * Transitional: invoked directly from {@link handleWheelEvent}. Will become a handler * for a semantic `camera:pan` graph event once the input event bus replaces raw DOM subscriptions. */ private handlePan; /** * Applies a zoom delta from wheel input. * * Transitional: invoked directly from {@link handleWheelEvent}. Will become a handler * for a semantic `camera:zoom` graph event once the input event bus replaces raw DOM subscriptions. */ private handleZoom; /** * Transitional wheel entry point: resolves pan vs zoom intent, then dispatches to * {@link handlePan} / {@link handleZoom}. Intent classification lives in * {@link GraphEditorSettings.wheelIntentFromEvent} today; later an input layer will * emit semantic graph events (`camera:pan`, `camera:zoom`, …) and Camera will subscribe. */ private handleWheelEvent; protected moveWithEdges(deltaX: number, deltaY: number): void; render(): void; updateChildren(): ComponentDescriptor[]; }