-
-
Notifications
You must be signed in to change notification settings - Fork 323
Add "Breakpoints" feature to edges for custom edge routing #2548
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
Conversation
Very cool. It's very clever to use pass through nodes. I haven't look at the code too deeply yet, so I'll start with bugs and suggestions:
|
Sure, we should just still leave the context menu though so this doesn't become a feature nobody is ever aware of like the Alt drag one
You should have seen it with the smooth edges, it looked a whole lot worse. I think the ideal thing would be for it to be curved coming in and out of the handles still, but straight to and a from breakpoints. I'm just not sure how to make it so that an edge is half bezier half straight
Honestly this is just kinda an issue with react flow that I have no idea how to solve without re-implementong that complex custom sorting algo we had, and even then we still had this exact issue where edges would be over the nodes
I'll try to fix this 👍 |
Definetly. On that note: we should probably show the short cuts for options in our context menus.
Edges over breakpoints is a huge issue though. Two unfortunately positioned edges can cover almost the entire hitbox of a breakpoint, making it almost unusable. We need a solution for this. |
In my opinion to fix this we need to PR react flow and adjust the default sorting logic so that edges don't ever get hoisted over the nodes they're connecting to. Like clamp them at the node's zIndex - 1 max. That doesn't fix the issue of overlapping separate edges, but that's an entirely different problem that I don't actually think is solvable personally |
I believe I have fixed all of your concerns. Please try it out again and let me know if there's anything else I should change |
Very nice! The only remaining issue is the weird alignment of breakpoints when snapped to grid. |
I think I'd be able to make it so breakpoints are snapped at their position minus their radius, but I fear that that will cause some compounding issue where each render will just offset them more and more... As for being "weirdly off grid", snapping to grid does not guarantee that the dots in the background align with the nodes at all. Never has, unless you pick a specific value that happens to line up with the dots. |
This shouldn't be an issue.
That's why I changed the default snap to grid amount to 16 in #1445. This ensures that things line up with the grid. So things line up by default. |
Ok, I will try to align those to center |
The implementation actually ended up being quite simple. I added a new node type that is secretly just a passthrough node with special styling. This node type is not manually connectable but rather is entirely controlled by us managing the edges going between it and the actual nodes.
This means that everything just works with it. There's a tad bit of jankiness with the node-merge (hold alt and connect) feature since these lines aren't bezier -- but I would prefer to just fix that in a separate PR as it works well enough still.
The breakpoints can be added or removed via context menu:


When a breakpoint is removed, an edge fills its place. When a breakpoint is added, it creates two new edges.
If an edge is deleted, all edges and breakpoints along what visually appears as the single edge will be removed. The way I made this happen was I jut made the BreakPoint component handle deleting itself if at any point in time its missing an edge, as a breakpoint can't just exist on its own. Perhaps in the future we could make it so breakpoints can be on their own, but I think this is good enough for a V1, and it can be improved upon later.
Oh yeah, and since they're just nodes, it works with the auto-layout feature as well.
Fast follows:
Longer-term followups
Closes #2420