UNPKG

3.67 kBTypeScriptView Raw
1/*!
2* ZRender, a high performance 2d drawing library.
3*
4* Copyright (c) 2013, Baidu Inc.
5* All rights reserved.
6*
7* LICENSE
8* https://github.com/ecomfe/zrender/blob/master/LICENSE.txt
9*/
10import * as zrUtil from './core/util';
11import Handler from './Handler';
12import Storage from './Storage';
13import { PainterBase } from './PainterBase';
14import Animation from './animation/Animation';
15import Element, { ElementEventCallback } from './Element';
16import { ElementEventName, WithThisType } from './core/types';
17import { LayerConfig } from './canvas/Layer';
18import { GradientObject } from './graphic/Gradient';
19import { PatternObject } from './graphic/Pattern';
20import { EventCallback } from './core/Eventful';
21import Displayable from './graphic/Displayable';
22declare type PainterBaseCtor = {
23 new (dom: HTMLElement, storage: Storage, ...args: any[]): PainterBase;
24};
25declare class ZRender {
26 dom?: HTMLElement;
27 id: number;
28 storage: Storage;
29 painter: PainterBase;
30 handler: Handler;
31 animation: Animation;
32 private _sleepAfterStill;
33 private _stillFrameAccum;
34 private _needsRefresh;
35 private _needsRefreshHover;
36 private _disposed;
37 private _darkMode;
38 private _backgroundColor;
39 constructor(id: number, dom?: HTMLElement, opts?: ZRenderInitOpt);
40 add(el: Element): void;
41 remove(el: Element): void;
42 configLayer(zLevel: number, config: LayerConfig): void;
43 setBackgroundColor(backgroundColor: string | GradientObject | PatternObject): void;
44 getBackgroundColor(): string | GradientObject | PatternObject;
45 setDarkMode(darkMode: boolean): void;
46 isDarkMode(): boolean;
47 refreshImmediately(fromInside?: boolean): void;
48 refresh(): void;
49 flush(): void;
50 private _flush;
51 setSleepAfterStill(stillFramesCount: number): void;
52 wakeUp(): void;
53 refreshHover(): void;
54 refreshHoverImmediately(): void;
55 resize(opts?: {
56 width?: number | string;
57 height?: number | string;
58 }): void;
59 clearAnimation(): void;
60 getWidth(): number | undefined;
61 getHeight(): number | undefined;
62 setCursorStyle(cursorStyle: string): void;
63 findHover(x: number, y: number): {
64 target: Displayable;
65 topTarget: Displayable;
66 } | undefined;
67 on<Ctx>(eventName: ElementEventName, eventHandler: ElementEventCallback<Ctx, ZRenderType>, context?: Ctx): this;
68 on<Ctx>(eventName: string, eventHandler: WithThisType<EventCallback<any[]>, unknown extends Ctx ? ZRenderType : Ctx>, context?: Ctx): this;
69 off(eventName?: string, eventHandler?: EventCallback): void;
70 trigger(eventName: string, event?: unknown): void;
71 clear(): void;
72 dispose(): void;
73}
74export interface ZRenderInitOpt {
75 renderer?: string;
76 devicePixelRatio?: number;
77 width?: number | string;
78 height?: number | string;
79 useDirtyRect?: boolean;
80 useCoarsePointer?: 'auto' | boolean;
81 pointerSize?: number;
82 ssr?: boolean;
83}
84export declare function init(dom?: HTMLElement | null, opts?: ZRenderInitOpt): ZRender;
85export declare function dispose(zr: ZRender): void;
86export declare function disposeAll(): void;
87export declare function getInstance(id: number): ZRender;
88export declare function registerPainter(name: string, Ctor: PainterBaseCtor): void;
89export declare type ElementSSRData = zrUtil.HashMap<unknown>;
90export declare type ElementSSRDataGetter<T> = (el: Element) => zrUtil.HashMap<T>;
91export declare function getElementSSRData(el: Element): ElementSSRData;
92export declare function registerSSRDataGetter<T>(getter: ElementSSRDataGetter<T>): void;
93export declare const version = "5.6.1";
94export interface ZRenderType extends ZRender {
95}
96export {};