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.

114 lines
3.9 KiB

4 months ago
import type { RuntimeContext } from '../runtime/types';
import type { IKeyboardEvent, IPointerEvent, IWheelEvent, Point, ViewportAnimationEffectTiming } from '../types';
import type { ShortcutKey } from '../utils/shortcut';
import type { BaseBehaviorOptions } from './base-behavior';
import { BaseBehavior } from './base-behavior';
/**
* <zh/>
*
* <en/> Zoom canvas behavior options
*/
export interface ZoomCanvasOptions extends BaseBehaviorOptions {
/**
* <zh/>
*
* <en/> Whether to enable the animation of zooming
* @defaultValue '{ duration: 200 }'
*/
animation?: ViewportAnimationEffectTiming;
/**
* <zh/>
*
* <en/> Whether to enable the function of zooming the canvas
* @defaultValue true
*/
enable?: boolean | ((event: IWheelEvent | IKeyboardEvent | IPointerEvent) => boolean);
/**
* <zh/> ()
* -
*
* <en/> zoom center(viewport coordinates)
* - by default , the center is the mouse position center
*/
origin?: Point;
/**
* <zh/>
* - ShortcutKey**使**['Control'] Control
* - CombinationKey { zoomIn: ['Control', '+'], zoomOut: ['Control', '-'], reset: ['Control', '0'] }
*
* <en/> The way to trigger zoom
* - ShortcutKey: Combination shortcut key, **default to zoom with the mouse wheel**, ['Control'] means zooming when holding down the Control key and scrolling the mouse wheel
* - CombinationKey: Zoom shortcut key, such as { zoomIn: ['Control', '+'], zoomOut: ['Control', '-'], reset: ['Control', '0'] }
*/
trigger?: ShortcutKey | {
zoomIn: ShortcutKey;
zoomOut: ShortcutKey;
reset: ShortcutKey;
};
/**
* <zh/>
*
* <en/> Zoom sensitivity
* @defaultValue 1
*/
sensitivity?: number;
/**
* <zh/>
*
* <en/> Callback when zooming is completed
*/
onFinish?: () => void;
/**
* <zh/>
*
* <en/> Whether to prevent the default event
* @defaultValue true
*/
preventDefault?: boolean;
}
/**
* <zh/>
*
* <en/> Zoom canvas behavior
*/
export declare class ZoomCanvas extends BaseBehavior<ZoomCanvasOptions> {
static defaultOptions: Partial<ZoomCanvasOptions>;
private shortcut;
constructor(context: RuntimeContext, options: ZoomCanvasOptions);
/**
* <zh/>
*
* <en/> Update options
* @param options - <zh/> | <en/> Options
* @internal
*/
update(options: Partial<ZoomCanvasOptions>): void;
private bindEvents;
/**
* <zh/>
*
* <en/> Zoom canvas
* @param value - <zh/> > 0 < 0 | <en/> Zoom value, > 0 zoom in, < 0 zoom out
* @param event - <zh/> | <en/> Event object
* @param animation - <zh/> | <en/> Zoom animation configuration
*/
protected zoom: (value: number, event: IWheelEvent | IKeyboardEvent | IPointerEvent, animation: ZoomCanvasOptions["animation"]) => Promise<void>;
protected onReset: () => Promise<void>;
/**
* <zh/>
*
* <en/> Verify whether it can be zoomed
* @param event - <zh/> | <en/> Event object
* @returns <zh/> | <en/> Whether it can be zoomed
* @internal
*/
protected validate(event: IWheelEvent | IKeyboardEvent | IPointerEvent): boolean;
private preventDefault;
/**
* <zh/>
*
* <en/> Destroy zoom canvas
*/
destroy(): void;
}