Skip to content

Commit

Permalink
Update graph.js
Browse files Browse the repository at this point in the history
  • Loading branch information
imaitland authored Feb 7, 2024
1 parent daf141e commit e7a0766
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions js/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ var boxsize = 60;
var emojimode = true;
var nightmode = true;

function delay(milliseconds){
return new Promise(resolve => {
setTimeout(resolve, milliseconds);
});
}

// Assume that there is a js object with name 'graph_data' already present...

const Graph = ForceGraph()(document.getElementById("graph"))
Expand Down Expand Up @@ -56,10 +62,13 @@ const Graph = ForceGraph()(document.getElementById("graph"))
.linkAutoColorBy((d) => {
d.source.tag;
})
.onNodeClick((node) => {
// Center/zoom on node
.onNodeClick(async (node) => {
// Center/zoom on clicked node
Graph.centerAt(node.x, node.y, 1000);
Graph.zoom(8, 2000);
// wait for complete
await delay(1500);
// Store last clicked in local storage
if (node.id == "day") {
document.getElementsByClassName("logo")[0].style.color = "black";

Expand Down

0 comments on commit e7a0766

Please sign in to comment.