Skip to content

Commit 1b9499d

Browse files
committed
feat: Detail pane: zoom in/out via button next to title
1 parent 748c994 commit 1b9499d

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

graph.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ function highlightNode(node) {
9292
if (node.id() == "simulators") {
9393
return;
9494
}
95+
// Swap out center/uncenter buttons
96+
const centerButton = document.getElementById("center_button");
97+
const uncenterButton = document.getElementById("uncenter_button");
98+
centerButton.classList.add("d-none");
99+
uncenterButton.classList.remove("d-none");
100+
95101
// Ignore the meta node
96102
meta_node.deselect();
97103
meta_node.remove();
@@ -185,7 +191,7 @@ function highlightElement(event) {
185191
// Only unhilight node if double tapped on background
186192
// Single tap is too error prone
187193
if (event.type === "dbltap") {
188-
unhighlightNode(null);
194+
unhighlightNode(null, true);
189195
}
190196
else {
191197
console.log("No-op: single tap on background");
@@ -212,7 +218,13 @@ function highlightElement(event) {
212218
}
213219
}
214220

215-
function unhighlightNode(event) {
221+
function unhighlightNode(event, unselect) {
222+
// Swap out center/uncenter buttons
223+
const centerButton = document.getElementById("center_button");
224+
const uncenterButton = document.getElementById("uncenter_button");
225+
centerButton.classList.remove("d-none");
226+
uncenterButton.classList.add("d-none");
227+
216228
// Ignore the meta node
217229
meta_node.restore();
218230
meta_node_edges.restore();
@@ -245,7 +257,9 @@ function unhighlightNode(event) {
245257
};
246258

247259
return_graph_to_init();
248-
showDetails(null, null);
260+
if (unselect) {
261+
showDetails(null, null);
262+
}
249263
}
250264

251265
function updateHighlights() {

index.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,21 @@ function showDetails(data, connected) {
4444
const quoted_sim = `[id='${data.id}']`;
4545
description.innerHTML = `<div class='d-flex justify-content-between align-items-center sticky-top' style='background-color: white;'>
4646
<h2>${data["full_name"]}</h2>
47-
<button class='btn btn-outline-primary align-middle' title='Center ${data["short_name"]} in the graph' onclick="highlightNode(cy.nodes('${quoted_sim.replace(/'/g, "\\'")}'));">
48-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bullseye" viewBox="0 0 16 16">
49-
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16"/>
50-
<path d="M8 13A5 5 0 1 1 8 3a5 5 0 0 1 0 10m0 1A6 6 0 1 0 8 2a6 6 0 0 0 0 12"/>
51-
<path d="M8 11a3 3 0 1 1 0-6 3 3 0 0 1 0 6m0 1a4 4 0 1 0 0-8 4 4 0 0 0 0 8"/>
52-
<path d="M9.5 8a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0"/>
47+
<div id='center_button'>
48+
<button class='btn btn-outline-primary align-middle m-1 me-2' title='Center ${data["short_name"]} in the graph' onclick="highlightNode(cy.nodes('${quoted_sim.replace(/'/g, "\\'")}'));">
49+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-zoom-in" viewBox="0 0 16 16">
50+
<path fill-rule="evenodd" d="M6.5 12a5.5 5.5 0 1 0 0-11 5.5 5.5 0 0 0 0 11M13 6.5a6.5 6.5 0 1 1-13 0 6.5 6.5 0 0 1 13 0"/>
51+
<path d="M10.344 11.742q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1 6.5 6.5 0 0 1-1.398 1.4z"/>
52+
<path fill-rule="evenodd" d="M6.5 3a.5.5 0 0 1 .5.5V6h2.5a.5.5 0 0 1 0 1H7v2.5a.5.5 0 0 1-1 0V7H3.5a.5.5 0 0 1 0-1H6V3.5a.5.5 0 0 1 .5-.5"/>
53+
</svg>
54+
</div>
55+
<div class="d-none" id='uncenter_button'>
56+
<button class='btn btn-outline-primary align-middle m-1 me-2' title='Go back to default view' onclick="unhighlightNode(null);">
57+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-zoom-out" viewBox="0 0 16 16">
58+
<path fill-rule="evenodd" d="M6.5 12a5.5 5.5 0 1 0 0-11 5.5 5.5 0 0 0 0 11M13 6.5a6.5 6.5 0 1 1-13 0 6.5 6.5 0 0 1 13 0"/>
59+
<path d="M10.344 11.742q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1 6.5 6.5 0 0 1-1.398 1.4z"/>
60+
<path fill-rule="evenodd" d="M3 6.5a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5"/>
5361
</svg>
54-
</button>
5562
</div>`;
5663
} else {
5764
description.innerHTML = `<h2 class="sticky-top" style='background-color: white;'>${data["full_name"]}</h2>`;

0 commit comments

Comments
 (0)