Skip to content

Commit 76e2189

Browse files
authored
misc(treemap): esc to zoom out (#12498)
1 parent 78d65c8 commit 76e2189

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lighthouse-treemap/app/src/main.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,14 @@ class TreemapViewer {
159159
this.updateColors();
160160
});
161161

162-
treemapEl.addEventListener('keypress', (e) => {
162+
treemapEl.addEventListener('keyup', (e) => {
163163
if (!(e instanceof KeyboardEvent)) return;
164164

165165
if (e.key === 'Enter') this.updateColors();
166+
167+
if (e.key === 'Escape' && this.treemap) {
168+
this.treemap.zoom([]); // zoom out to root
169+
}
166170
});
167171

168172
treemapEl.addEventListener('mouseover', (e) => {

lighthouse-treemap/types/treemap.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ declare global {
77
constructor(data: any, options: WebTreeMapOptions);
88
render(el: HTMLElement): void;
99
layout(data: any, el: HTMLElement): void;
10+
zoom(address: number[]): void
1011
}
1112

1213
interface WebTreeMapOptions {

0 commit comments

Comments
 (0)