How to interactively create links in JointJS

一世执手 提交于 2019-12-04 07:15:49

Maybe you can use the magnet feature of JointJS? If you set magnet: true on an SVG subelement of a JointJS element, that element becomes active and will allow the user to create a link starting from that element. For example:

var r = new joint.shapes.basic.Rect({
    position: { x: 50, y: 50 },
    size: { width: 100, height: 40 },
    attrs: { text: { text: 'basic.Rect', magnet: true } }
});

This will make the element behave like a port.

To prevent the dangling links:

joint.dia.Paper({ linkPinning: false })

Here is a nice solution.

You can combine

linkView.startArrowheadMove('target');

and

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