import type { DisplayObject, Document, FederatedEvent, FederatedPointerEvent, FederatedWheelEvent, IAnimation } from '@antv/g'; import type { AnimationType } from '../constants'; import type { ElementDatum } from './data'; import type { Element, ElementType } from './element'; import type { TransformOptions } from './viewport'; export type IEvent = IGraphLifeCycleEvent | IAnimateEvent | IElementLifeCycleEvent | IViewportEvent | IPointerEvent | IWheelEvent | IKeyboardEvent | IDragEvent; export interface IPointerEvent extends TargetedEvent { } export interface IWheelEvent extends TargetedEvent { } export interface IKeyboardEvent extends KeyboardEvent { } export interface IElementEvent extends IPointerEvent { } export interface IElementDragEvent extends IDragEvent { } export interface IDragEvent extends TargetedEvent { dx: number; dy: number; } export interface IGraphLifeCycleEvent extends NativeEvent { data?: any; } export interface IElementLifeCycleEvent extends NativeEvent { elementType: ElementType; data: ElementDatum; } export interface IViewportEvent extends NativeEvent { data: TransformOptions; } export interface IAnimateEvent extends NativeEvent { animationType: AnimationType; animation: IAnimation | null; data?: any; } /** * G6 原生事件 * * G6 native event */ interface NativeEvent { type: string; } /** * 具有目标的事件 * * Event with target */ type TargetedEvent = Omit & { originalTarget: DisplayObject; target: T; targetType: 'canvas' | 'node' | 'edge' | 'combo'; }; export type Target = Document | Element; export {};