Skip to content

Commit

Permalink
feat: Make loopback edges more intuitive [PT-185596245]
Browse files Browse the repository at this point in the history
  • Loading branch information
dougmartin committed Jul 13, 2023
1 parent 9e33664 commit cb0999b
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/components/graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,44 @@ export const Graph = (props: Props) => {
.attr("y1", d => d.y1)
.attr("y2", d => d.y2)
.attr("marker-end", "url(#arrow)");

// add loopback "ghost" with background
if (!rubberBandNode.loops) {
svg
.selectAll("path.ghost-loop-background")
.data([rubberBandNode])
.enter()
.append("path")
.attr("class", "ghost-loop-background")
.attr("d", nodeLoopPath)
.attr("stroke", "#000")
.attr("stroke-opacity", 0)
.attr("fill-opacity", 0)
.attr("stroke-width", 15)
.attr("style", "cursor: pointer")
.on("click", () => {
onNodeClick?.(rubberBandNode.id);
})
;
svg
.selectAll("path.ghost-loop")
.data([rubberBandNode])
.enter()
.append("path")
.attr("class", "ghost-loop")
.attr("d", nodeLoopPath)
.attr("stroke", "#999")
.attr("stroke-opacity", 0.6)
.attr("stroke-dasharray", 4)
.attr("fill-opacity", 0)
.attr("stroke-width", 1)
.attr("marker-end", "url(#arrow)")
.attr("style", "cursor: pointer")
.on("click", () => {
onNodeClick?.(rubberBandNode.id);
})
;
}
}

}, [svgRef, d3Graph, allowDragging, autoArrange, rubberBand, drawingMode,
Expand Down

0 comments on commit cb0999b

Please sign in to comment.