Code Monkey home page Code Monkey logo

Comments (4)

moklick avatar moklick commented on June 7, 2024

Screenshot 2022-08-22 at 13 54 05

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.

raarts avatar raarts commented on June 7, 2024

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.

bcakmakoglu avatar bcakmakoglu commented on June 7, 2024

@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.

raarts avatar raarts commented on June 7, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.