You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
3.2 KiB

4 months ago
import type { RuntimeContext } from '../runtime/types';
import type { EdgeDirection, Element, IPointerEvent, State } from '../types';
import type { BaseBehaviorOptions } from './base-behavior';
import { BaseBehavior } from './base-behavior';
/**
* <zh/>
*
* <en/> Hover element behavior options
*/
export interface HoverActivateOptions extends BaseBehaviorOptions {
/**
* <zh/>
*
* <en/> Whether to enable animation
* @defaultValue true
*/
animation?: boolean;
/**
* <zh/>
*
* <en/> Whether to enable hover element function
* @defaultValue true
*/
enable?: boolean | ((event: IPointerEvent) => boolean);
/**
* <zh/> n度关系
* - `0`
* - `1`
*
* <en/> N-degree relationship of the hovered element
* - default to `0`, which means only the current node is activated
* - `1` means the current node and its directly adjacent nodes and edges are activated, etc
* @defaultValue 0
*/
degree?: number | ((event: IPointerEvent) => number);
/**
* <zh/>
* - `'both'`:
* - `'in'`:
* - `'out'`:
*
* <en/> Specify the direction of the edge
* - `'both'`: Activate all relationships of the current node
* - `'in'`: Activate the incoming edges and nodes of the current node
* - `'out'`: Activate the outgoing edges and nodes of the current node
* @defaultValue 'both'
*/
direction?: EdgeDirection;
/**
* <zh/> `active`
*
* <en/> Active element state, default to`active`
* @defaultValue 'active'
*/
state?: State;
/**
* <zh/>
*
* <en/> Inactive element state, default to no change
*/
inactiveState?: State;
/**
* <zh/>
*
* <en/> Callback when the element is hovered
*/
onHover?: (event: IPointerEvent) => void;
/**
* <zh/>
*
* <en/> Callback when the hover ends
*/
onHoverEnd?: (event: IPointerEvent) => void;
}
/**
* <zh/>
*
* <en/> Hover element behavior
* @remarks
* <zh/>
*
* <en/> When the mouse hovers over an element, you can activate the state of the element, such as highlighting nodes or edges.
*/
export declare class HoverActivate extends BaseBehavior<HoverActivateOptions> {
static defaultOptions: Partial<HoverActivateOptions>;
private isFrozen;
constructor(context: RuntimeContext, options: HoverActivateOptions);
private toggleFrozen;
private bindEvents;
private hoverElement;
protected getActiveIds(event: IPointerEvent<Element>): string[];
private updateElementsState;
private getElementsState;
private validate;
private unbindEvents;
destroy(): void;
}