Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc(treemap): esc to zoom out #12498

Merged
merged 1 commit into from
May 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lighthouse-treemap/app/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,14 @@ class TreemapViewer {
this.updateColors();
});

treemapEl.addEventListener('keypress', (e) => {
treemapEl.addEventListener('keyup', (e) => {
if (!(e instanceof KeyboardEvent)) return;

if (e.key === 'Enter') this.updateColors();

if (e.key === 'Escape' && this.treemap) {
this.treemap.zoom([]); // zoom out to root
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there potential for this have the same recoloring problem (#12496 (comment))? do we need to flip the order to ensure these are recolored? From what I could tell poking around devtools it seemed like the other nodes were just hidden and still there, so not an issue, but calling it out in case it was just oversight.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

played around with it. zoomed into a node, changed view mode with keyboard, zoomed out with ESC. things were colored correctly.

}
});

treemapEl.addEventListener('mouseover', (e) => {
Expand Down
1 change: 1 addition & 0 deletions lighthouse-treemap/types/treemap.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ declare global {
constructor(data: any, options: WebTreeMapOptions);
render(el: HTMLElement): void;
layout(data: any, el: HTMLElement): void;
zoom(address: number[]): void
}

interface WebTreeMapOptions {
Expand Down