Comments (4)
There is a little button "Open in Codesandbox" in the bottom right corner that shows the whole code of that example: https://codesandbox.io/s/zbu68r?file=/App.js&from-sandpack=true. But you have a good point here. It's not very beginner friendly. We will keep this open for now.
from web.
Adding to this: a page on coordinates (both pixel as well as react-flow) and width/height and how to retrieve them.
Both when inside a custom node as well a in a ReactFlow handler. I have spent a lot of time already with react-flow, and this keeps stopping me in my tracks.
(latest hurdles for me:
- inside a custom node draghandler the mouse coordinates are easy to get, but getting the reactflow outer bounds is hard from there, even though width+height are in the store.
- getting the coordinates of the custom node or width/height in pixels is challenging too).
A page dedicated to this subject with code examples would be very helpful for beginners.
Another possible help page might be on strategies for handling dynamic re-layouting (for example while an textarea field inside a custom node is edited, growing and growing to overlap other nodes).
Both typescript and plain JS code for all examples would also be great I think.
from web.
@raarts FYI: Custom Nodes receive xPos
and yPos
as props so you should be able to fetch the coordinates from there pretty easily :)
// props that get passed to a custom node
export interface NodeProps<T = any> {
id: string;
type: string;
data: T;
selected: boolean;
isConnectable: boolean;
xPos: number;
yPos: number;
dragging: boolean;
zIndex: number;
targetPosition?: Position;
sourcePosition?: Position;
dragHandle?: string;
}
from web.
@bcakmakoglu Yes, I know, but I needed it in browser pixels so I gathered I needed something like a reverse project() function. There isn't one, so I ended up just copying it out of the reactflow sourcecode, and reverse it myself.
from web.
Related Issues (20)
- Fix Svelte unknown prop workaround
- Make it possible to display a "new" tag in the sidebar for an example/API page HOT 1
- docs for onbeforedelete handler
- Improve documentation for useStore
- 📝 Expand troubleshooting section to warn about potential canvas problems.
- Documentation about performance best practices and limitations
- Multiple Edge Drawing HOT 1
- Svelte Flow attribution/proOptions: create something like a remove attribution page
- Add Github link
- layouting guide: add a chart that helps picking a layout algorithm
- Check if we need to update our React Flow examples built with sandpack HOT 2
- Theming guide: add info about style order when using tailwind or something similar
- revise pro examples page HOT 1
- Food Former - A food creation game HOT 1
- discord link is missing in svelte flow navigation
- Showcase Project : Roadmap-Flow - Roadmap for Programmers with List of topic wise Questions HOT 1
- AppBlocks No Code IoT Platform HOT 1
- Domino - Build Amazing Ideas, Piece by Piece HOT 1
- add flowise to the showcase HOT 1
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 web.