How to get the links to the front when reparenting

假如想象 提交于 2020-01-17 04:39:04

问题


All the cells/elements are embedded on top of other cell but the links are hidden behind the element. How do I get the links on top of the element(parent)

Here's the Preview

I tried with link.toFront() which isn't working. Below is my code snippet:

paper.on('cell:pointerdown', function (cellView, evt, x, y) {

                    var cell = cellView.model;
                    if (!cell.get('embeds') || cell.get('embeds').length === 0) {
                        // Show the dragged element above all the other cells (except when the
                        // element is a parent).
                        cell.toFront();
                        link.toFront();

                    }

                    if (cell.get('parent')) {
                        graph.getCell(cell.get('parent')).unembed(cell);
                    }
                });

回答1:


If you want to bring a cell to the front with all connected links, try the following.

cell.toFront();
_.invoke(graph.getConnectedLinks(cell), 'toFront');

If you want to bring a parent cell with all its embedded cells to the front, call the toFront method with deep: true option. Method makes sure that all the descendants of the cell (embedded links and elements) are also brought to the front and no cell is hidden behind its parent (child z index is always higher than z index of child parent).

parent.toFront({ deep: true });

You can also checkout the embeddingMode and validateEmbedding paper options, that do the (un)embedding / validation automatically for you.

Documentation:

http://jointjs.com/api#joint.dia.Element:toFront

http://jointjs.com/api#joint.dia.Paper



来源:https://stackoverflow.com/questions/31667581/how-to-get-the-links-to-the-front-when-reparenting

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!