diff --git a/quartz/components/scripts/graph.inline.ts b/quartz/components/scripts/graph.inline.ts index 1c9bb5d64..e8dec4c5f 100644 --- a/quartz/components/scripts/graph.inline.ts +++ b/quartz/components/scripts/graph.inline.ts @@ -223,6 +223,18 @@ async function renderGraph(container: string, fullSlug: FullSlug) { .transition() .duration(200) .style("opacity", 0.2) + + d3.selectAll(".node") + .filter((d) => !connectedNodes.includes(d.id)) + .nodes() + .map((it) => d3.select(it.parentNode as HTMLElement).select("text")) + .forEach((it) => { + let opacity = parseFloat(it.style("opacity")) + it.transition() + .duration(200) + .attr("opacityOld", opacity) + .style("opacity", Math.min(opacity, 0.2)) + }) } // highlight links @@ -245,6 +257,12 @@ async function renderGraph(container: string, fullSlug: FullSlug) { if (focusOnHover) { d3.selectAll(".link").transition().duration(200).style("opacity", 1) d3.selectAll(".node").transition().duration(200).style("opacity", 1) + + d3.selectAll(".node") + .filter((d) => !connectedNodes.includes(d.id)) + .nodes() + .map((it) => d3.select(it.parentNode as HTMLElement).select("text")) + .forEach((it) => it.transition().duration(200).style("opacity", it.attr("opacityOld"))) } const currentId = d.id const linkNodes = d3