UNPKG

@selenite/graph-editor

Version:

A graph editor for visual programming, based on rete and svelte.

32 lines (31 loc) 1.33 kB
import type { Schemes } from '../../schemes'; import type { Position } from '@selenite/commons'; import { BaseSocketPosition } from './base-socket-position'; export type Side = 'input' | 'output'; /** * Props for `DOMSocketPosition` class. */ export type Props = { /** * Allows to customize the position of the socket. By default, the position is shifted by 12px on the x-axis relative to the center of the socket. * @param position Center position of the socket * @param nodeId Node ID * @param side Side of the socket, 'input' or 'output' * @param key Socket key * @returns Custom position of the socket */ offset?: (position: Position, nodeId: string, side: Side, key: string) => Position; }; /** * Class for socket position calculation based on DOM elements. It uses `getElementCenter` function to calculate the position. */ export declare class DOMSocketPosition<K> extends BaseSocketPosition<Schemes, K> { private props?; constructor(props?: Props | undefined); calculatePosition(nodeId: string, side: Side, key: string, element: HTMLElement): Promise<Position | null>; } /** * Wrapper function for `DOMSocketPosition` class. * @param props Props for `DOMSocketPosition` class */ export declare function getDOMSocketPosition<K>(props?: Props): DOMSocketPosition<K>;