Coder Social home page Coder Social logo

Comments (16)

moklick avatar moklick commented on May 11, 2024 1

Hey,

we just released v.4.0.0. There we dropped isInteractive and added nodesDraggable, nodesConnectable and elementsSelectable. This use case should be working with nodesDraggable = false and nodesConnectable and elementsSelectable = true. You can see a working example here: https://react-flow.netlify.app/interaction. Can you confirm @bartvanremortele ?

from xyflow.

moklick avatar moklick commented on May 11, 2024

Hey,

I disabled the pointer events for inactive graphs in order to be able to zoom and pan even if the pointer is above a node.

Maybe we could introduce another option like ‘disablePointerEventsWhenInactive’ or something like that.

What do you think about that?

from xyflow.

bartvanremortele avatar bartvanremortele commented on May 11, 2024

Hey,

Yes, I did some further digging and now understand why it's implemented in the way it is. The zoom layer has a lower z-index than the nodes and the pointer-events: none makes it possible to trigger the handlers on the zoom layer because the node's events are disabled.

As far as I understood by reading this issue on d3-zoom, the UX I want is probably not a good idea.

That being said, I believe react-flow should still give a user the choice of enabling/disabling pointer-events in a straightforward manner. I'm not a fan of disablePointerEventsWhenInactive, I would inverse this by adding an option to disable the dragging. enableDragging which defaults to true seems like a better option in my opinion.

That being said, I have decided to take a different path for now and re-introducing the pointer-events: all inside of the node and improving the UX around the zooming/panning by highlighting the hovered node and changing to cursor to give a clearer indication as to which actions are accessible on his current cursor position.

from xyflow.

bartvanremortele avatar bartvanremortele commented on May 11, 2024

perhaps we can figure out a better solution using d3-zoom's filter

from xyflow.

moklick avatar moklick commented on May 11, 2024

Maybe enablePointerEvents would be a good option. And yes I would like to drop d3-zoom and d3-selection. But maybe you are right and we can figure out a better way how to use it for now

from xyflow.

bartvanremortele avatar bartvanremortele commented on May 11, 2024

@moklick I did some searching to improve the zooming / panning behaviour in conjunction with click handlers on nodes and came across https://github.com/prc5/react-zoom-pan-pinch#readme this implementation. I believe this might be a good contender to replace d3-zoom.

Your thoughts?

from xyflow.

moklick avatar moklick commented on May 11, 2024

I will have a look, thanks!

from xyflow.

dekelb avatar dekelb commented on May 11, 2024

Another feature that is related to this is an option to allow drag & drop the elements (nodes), but prevent creating new edges.
As far as I understand this is not possible atm.

@moklick is there an option for this out-of-the-box?

from xyflow.

moklick avatar moklick commented on May 11, 2024

hey @dekelb

sorry I can't follow you. What do you want to achieve?

from xyflow.

dekelb avatar dekelb commented on May 11, 2024

thanks for the super fast reply @moklick !
I want to be able to move the nodes (drag and drop), but in my case - the creation of new edges (create new connection between nodes) should be disabled.

Maybe I missed something in the docs, but from what I understand there is no simple way to do this.

from xyflow.

moklick avatar moklick commented on May 11, 2024

@dekelb can you open a new issue for this? thanks!

from xyflow.

dekelb avatar dekelb commented on May 11, 2024

@moklick just opened #291 - let me know what you think.

from xyflow.

 avatar commented on May 11, 2024

If you use nodesDraggable={false} then the onElementClick is not working anymore.

from xyflow.

moklick avatar moklick commented on May 11, 2024

Good catch @emielwit! The bug should be fixed with version 4.2.2

from xyflow.

moklick avatar moklick commented on May 11, 2024

hey @bartvanremortele I will close this issue for now. Feel free to open a new one for discussing the switch from d3-zoom to another zoom/pan library.

from xyflow.

pfidelus-dev avatar pfidelus-dev commented on May 11, 2024

Hi, I met issue similar to @emiel-betty but for onNodeDoubleClick event. I opened a bug #2525

from xyflow.

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.