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 · 5 comments

Comments

Projects
None yet
2 participants
@maxkfranz
Copy link
Member

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Member Author

commented Aug 23, 2017

@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

This comment has been minimized.

Copy link
Member Author

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 added a commit that referenced this issue Nov 10, 2017

@maxkfranz

This comment has been minimized.

Copy link
Member Author

commented Nov 10, 2017

@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

@maxkfranz maxkfranz closed this Nov 10, 2017

@d2fong

This comment has been minimized.

Copy link
Member

commented Nov 11, 2017

Thanks. Good to know it is working well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.