Comments (3)
Hey @natsu-k
that's some crazy nodes :) Thanks for the feedback. We will check that.
from react-flow.
Thanks for getting back to me @moklick
I just threw that together super quickly to demonstrate what I noticed occurring. I've been really inspired by this library. I've been using it and your example on custom nodes along with a background API to create a version of this that lets you build your node graph within the react app itself and then save it back to json. Things like being able to change text and colour of the nodes, and toggle the 4 handles between "off, source, and target".
I was looking a bit closer at the code behind the bezier curve tonight to see why the output was generating like so.
I noticed the condition:
else if (leftAndRight.includes(sourcePosition) || leftAndRight.includes(targetPosition))
So if either the source or target position (but not both, as that is caught in the previous if statement) are left or right, then generate a bezier curve with both of the centre control points placed at the same location ${sourceX},${targetY}
. This would only generate a correct looking curve for half of the possible configurations.
SOURCE position | TARGET position | Curve |
---|---|---|
LEFT | TOP | inverted |
LEFT | BOTTOM | inverted |
RIGHT | TOP | inverted |
RIGHT | BOTTOM | inverted |
TOP | LEFT | correct |
TOP | RIGHT | correct |
BOTTOM | LEFT | correct |
BOTTOM | RIGHT | correct |
So it looks like you might be able to resolve it by adding in an extra condition and adjusting the original on Line 31:
} else if (!(leftAndRight.includes(sourcePosition)) && leftAndRight.includes(targetPosition)) {
dAttr = `M${sourceX},${sourceY} C${sourceX},${targetY} ${sourceX},${targetY} ${targetX},${targetY}`;
} else if (leftAndRight.includes(sourcePosition) && !(leftAndRight.includes(targetPosition))) {
dAttr = `M${sourceX},${sourceY} C${targetX},${sourceY} ${targetX},${sourceY} ${targetX},${targetY}`;
}
There might be a better way of writing this code, but I just wanted to contribute what I have figured out so far.
from react-flow.
Thanks for your input! We just released a v3.0.0 (because we had a breaking change regarding custom nodes). The nodes now should be connected correctly: https://react-flow.netlify.app/horizontal
from react-flow.
Related Issues (20)
- [React Flow]: Handle: No node id found. Make sure to only use a Handle inside a custom Node.
- [React Flow]: Handle: No node id found. Make sure to only use a Handle inside a custom Node. HOT 1
- Zoom In, Zoom Out, fitview, and toggle interactivity HOT 4
- Mini Map preview disappeared in 12.0.0-next.18 HOT 1
- Allow drag selection inside nodes HOT 11
- Revert to window level event listeners
- [SvelteFlow] panOnScroll shift+scroll horizontal does not work after clicking canvas HOT 4
- `Edge` should accept a generic `type` argument like `Node` HOT 2
- Node Position Changes Cause All Nodes To Disappear HOT 3
- Provide helper to create an edge from edge params or `Connection` HOT 9
- Large Data React-Window Virtualization HOT 7
- prevent outcoming edge from target handle HOT 5
- Edge marker is not dynamically updated HOT 9
- accept array of classes in noPanClassName HOT 5
- snap guidelines HOT 2
- Extra Objects needed HOT 2
- Node position not matching the nodes list and rendered node HOT 5
- defining a fixed markerEnd (or Start) in custom Edge doesn't work? HOT 2
- I face a bug to align center expand and collapse flow HOT 1
- Export type definitions for individual methods and variables of `useSvelteFlow` functionality HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-flow.