Giter VIP home page Giter VIP logo

Comments (4)

motin avatar motin commented on May 25, 2024

Looks like this has been asked and answered previously: #12

from react-cytoscapejs.

jdebr avatar jdebr commented on May 25, 2024

I am doing something similar in my component with the cy reference (except only rerunning layout when the number of elements change, which works well for my use case). I was just thinking that it seems like a useful enough feature that it would be nice to have it wrapped in the component rather than having to do it imperatively outside the component, although I suspect it should be optional behavior as for large graphs it might cause performance issues.

In any case, this isn't an issue for me, so if there's no interest in adding this (or reasons it shouldn't be that I haven't considered) it can be closed. I just wanted to gauge interest in a PR to help out if it sounded useful.

from react-cytoscapejs.

maxkfranz avatar maxkfranz commented on May 25, 2024

from react-cytoscapejs.

jdebr avatar jdebr commented on May 25, 2024

I think that could be useful; however I was thinking of applying and running the layout regardless of whether options.layout has changed.

In the current implementation, the layout is only applied and run if the layout.options has changed according to either the provided diff, or the default shallow diff, which is obviously true the first time the layout prop is passed in. However, at least for synchronous layouts, any new elements added after this initial run will not have the layout applied and will be placed at (0,0). I believe this will be true for asynchronous layouts as well since cy.layout() is only applied to the elements currently in the graph when it is called, but I haven't tested it to be sure.

I would think a frequent use case would be wanting to apply a layout whose options would never change, but would re-apply on any new nodes when they are added after the component is mounted.

from react-cytoscapejs.

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.