angular/devtools/projects/ng-devtools/src/lib/shared/tree-visualizer-host/graph-renderer.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
1.3 KiB
TypeScript
Raw Normal View History

/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
export abstract class GraphRenderer<T, U> {
abstract render(graph: T): void;
abstract getNodeById(id: string): U | null;
abstract snapToNode(node: U): void;
abstract snapToRoot(): void;
abstract zoomScale(scale: number): void;
abstract root: U | null;
abstract get graphElement(): HTMLElement;
protected nodeClickListeners: ((pointerEvent: PointerEvent, node: U) => void)[] = [];
protected nodeMouseoverListeners: ((pointerEvent: PointerEvent, node: U) => void)[] = [];
protected nodeMouseoutListeners: ((pointerEvent: PointerEvent, node: U) => void)[] = [];
cleanup(): void {
this.nodeClickListeners = [];
this.nodeMouseoverListeners = [];
this.nodeMouseoutListeners = [];
}
onNodeClick(cb: (pointerEvent: PointerEvent, node: U) => void): void {
this.nodeClickListeners.push(cb);
}
onNodeMouseover(cb: (pointerEvent: PointerEvent, node: U) => void): void {
this.nodeMouseoverListeners.push(cb);
}
onNodeMouseout(cb: (pointerEvent: PointerEvent, node: U) => void): void {
this.nodeMouseoutListeners.push(cb);
}
}