Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cy.mount() : Attach to a DOM element for rendering, after init #1937

Closed
maxkfranz opened this issue Aug 18, 2017 · 7 comments
Closed

cy.mount() : Attach to a DOM element for rendering, after init #1937

maxkfranz opened this issue Aug 18, 2017 · 7 comments
Assignees
Milestone

Comments

@maxkfranz
Copy link
Member

maxkfranz commented Aug 18, 2017

Description of new feature

cy.mount( container ) : Attaches the instance to the specified container, just like specifying container at init.

cy.unmount() : Detaches the instance from its container, making it a headless instance.

Motivation for new feature

Sometimes, you want to create an instance before you have the DOM element you want to render in. For example, you might pass a Cytoscape instance into a React component's props, but you can't attach to the DOM element until componentDidMount().

Feature Breakdown

  • Single use mount
  • Multi use mount
@maxkfranz maxkfranz added this to the future milestone Aug 18, 2017
@d2fong
Copy link
Member

d2fong commented Aug 23, 2017

@maxkfranz I can work on this feature. I was able to implement mount for the basic case. I tested it with the pathways search app and I could pass cy instances as props to child components without errors.

@maxkfranz
Copy link
Member Author

@d2fong Great; I'll add this to the 3.3 milestone then.

Not sure if it's worth it to support multiple mounts per core instance. Maybe it's worth trying destroying/replacing the renderer on each mount to support that usecase? If cleanly destroying the renderer without also destroying the core instance is not straight forward, then we could just support the mount-once per core instance usecase.

There's cy.destroyRenderer() and cy.initRenderer(). I think at least the animation loop needs to be handled in initRenderer() rather than the core constructor then. There may be other issues.

@maxkfranz maxkfranz modified the milestones: 3.3.0, future Aug 23, 2017
@d2fong d2fong self-assigned this Aug 23, 2017
@maxkfranz
Copy link
Member Author

maxkfranz commented Oct 2, 2017

Merged #1949 into unstable. It looks good, but let's keep this issue open for now as a reminder to keep an eye out for mount issues while working on other features on the unstable branch.

@maxkfranz
Copy link
Member Author

@d2fong I added buttons to test mounting on the debug page. I played around with it for a while and I wasn't able to break anything. It looks like it's working well.

Closing

@d2fong
Copy link
Member

d2fong commented Nov 11, 2017

Thanks. Good to know it is working well.

@ns-singhs
Copy link

cy.mount() doesn't work well with the cose layout.
There is no event getting triggered afterwards on the graph, the view is proper but it behaves like an image.
Please look into it.
Using "cytoscape": "^3.22.0",

@maxkfranz
Copy link
Member Author

You're welcome to post reproducible issues as new issues in the issue tracker. Include all of the information in the issue template, such as the reproducible demo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants