Link:dbclick事件,其“顶点添加”设置为true [Jointjs] [Rappid]

时间:2019-02-04 07:22:08

标签: jointjs rappid

双击vertexAdding:设置为true的链接时,我无法获得Link:dbclick事件。 将“顶点添加”设置为false时,dbclick事件可以正常工作。

我正在使用link:pointerup来添加“工具”视图来像这样链接::

 this.paper.on('link:pointerup',  (linkView) => {
            var tools;
            var ns = joint.linkTools;


            var toolsView = new joint.dia.ToolsView({
                name: 'link:pointerup',
                tools: [
                    new ns.Vertices(),
                    new ns.Vertices({ vertexAdding: true}),
                    new ns.Remove({ focusOpacity: 0.5,
                             distance: 5,
                            offset: 10}),
                    new ns.TargetArrowhead(),
                    new ns.Segments(),
                    new ns.Boundary({ padding: 10 }),
                ]
            });

            joint.ui.Halo.clear(this.paper);
            joint.ui.FreeTransform.clear(this.paper);
            this.paper.removeTools();
            linkView.addTools(toolsView);

        });

对于链接创建:::

 export class Link2 extends joint.shapes.standard.Link  {

        defaults() {
            return joint.util.defaultsDeep({
                router: {
                    name: 'normal',
                },
                connector: {
                    name: 'normal',

                },
                labels: [],
                attrs: {
                    line: {
                        stroke: '#284f96',
                        strokeDasharray: '0',
                        strokeWidth: 1,
                        fill: 'none',
                        sourceMarker: {
                            d: 'M 0 0 0 0',
                            fill: {
                                type: 'color-palette',
                                group: 'marker-source',
                                when: { ne: { 'attrs/line/sourceMarker/d': 'M 0 0 0 0' } },
                                index: 2
                            },

                        },
                        targetMarker: {
                            d: ' M 0 -3 -6 0 0 3 z',
                            },

                        }
                }
            }, joint.shapes.standard.Link.prototype.defaults);
        }

        defaultLabel = {
            attrs: {
                rect: {
                    fill: '#ffffff',
                    stroke: '#8f8f8f',
                    strokeWidth: 2,
                    refWidth: 10,
                    refHeight: 10,
                    refX: 0,
                    refY: 0
                }
            }
        };



        getMarkerWidth(type: any) {
            const d = (type === 'source') ? this.attr('line/sourceMarker/d') : this.attr('line/targetMarker/d');
            console.log("marker width", this.getDataWidth(d));
            return this.getDataWidth(d);
        }

        getDataWidth = memoize(function (d: any) {
            return (new joint.g.Rect(d)).bbox().width;
        });

        static connectionPoint(line: any, view: any, magnet: any, opt: any, type: any, linkView: any) {
            // const markerWidth = linkView.model.getMarkerWidth(type);
            opt = { offset: 5, stroke: true };
            // connection point for UML shapes lies on the root group containg all the shapes components
            const modelType = view.model.get('type');
            if (modelType.indexOf('uml') === 0) opt.selector = 'root';
            // taking the border stroke-width into account
            if (modelType === 'standard.InscribedImage') opt.selector = 'border';
            return joint.connectionPoints.boundary.call(this, line, view, magnet, opt, type, linkView);
        }
    }

我正在使用以下代码在Link :::

上获取双击事件
 this.rappid.paper.on(
      "link:pointerdblclick", (linkView) => {
        // linkView.model.attr("priority",0);
        console.log("linkview", linkView);
        // this.currentLink = linkView
        this.setState({ modalView: "lableModal", visible: true, currentLink: linkView });

      });

0 个答案:

没有答案