Closed schinazi closed 7 years ago
@schinazi I think that you are right. How about using '.offsetParent()' (http://api.jquery.com/offsetparent/) instead of having 'componentParentSelector' option?
@metincansiper Thanks for the suggestion. I tried out simplifying it by just replacing where you were using $(cy.container()).position() and instead using $(cy.container()).offset(), which gives the container's position relative to the document (http://api.jquery.com/offset/).
This works for my use case, and it looks like it works in demo.html as well.
If you think this works, I can squash the commits in this branch if you like.
Thanks, Brian
@schinazi Thanks. I merged this PR.
Currently the context menu DOM element (#cy-context-menus-cxt-menu) is appended to the document's body element.
When the menu is positioned at the time of the user's click, the "left" and "right" positions are calculated based on the rendered graph's container's location plus the cilck position within the graph.
If the graph was rendered in a container which was moved away from the normal flow position in the body (such as for the purpose of containing it in a "slide- in" animation), then the calculated position for the context menu might not be correct based on the current positioning of elements in the browser.
To accommodate this, add an option that allows for supplying a CSS selector that the #cy-context-menus-cxt-menu element should be appended to instead of the body.