mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
Abstract the injector tree visualizer so it can be used for both the Injector Tree and Router Tree tabs without having to rely on separate identical implementations. PR Close #62264
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
/**
|
|
* @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);
|
|
}
|
|
}
|