UNPKG

@delove/reaflow

Version:

Node-based Visualizations for React

50 lines (49 loc) 1.25 kB
import { RefObject } from 'react'; import { CanvasRef } from '../Canvas'; export interface ProximityProps { /** * Disable proximity or not. */ disabled?: boolean; /** * Min distance required before match is made. * * @default 40 */ minDistance?: number; /** * Ref pointer to the canvas. */ canvasRef?: RefObject<CanvasRef>; /** * Distance from the match. */ onDistanceChange?: (distance: number | null) => void; /** * When a match state has changed. */ onMatchChange?: (matche: string | null, distance: number | null) => void; /** * When the pointer intersects a node. */ onIntersects?: (matche: string | null) => void; } export interface ProximityResult { /** * The matched id of the node. */ match: string | null; /** * Event for drag started. */ onDragStart: (event: PointerEvent) => void; /** * Event for active dragging. */ onDrag: (event: PointerEvent) => void; /** * Event for drag ended. */ onDragEnd: (event: PointerEvent) => void; } export declare const useProximity: ({ canvasRef, disabled, minDistance, ...rest }: ProximityProps) => ProximityResult;