欢迎就是需要使用jsplumb跟正在使用jsplumb的一起讨论 欢迎私聊

1.关于jsplumb的connection的一些事件

####connection拖动的事件

instance.bind('connectionDragStop', function(conn) {});

 ####连接废弃

instance.bind('connectionAborted', (conn, originalEvent) => {})

####在落下来某一个点之前

instance.bind('beforeDrop', (conn) => {})

####

instance.bind('beforeDrag', (conn) => {})

####

instance.bind('connectionDrag', (conn) => {})

####

instance.bind('beforeDetach', (conn) => {})

 ####想要拿到连线的点击事件啊,hover事件啊,都可以通过bind来实现

instance.bind('click', function(c) {})

 

等等这些事件吧~~~~~

2.就是关于连接线的一些样式问题

  1.你可以在一个页面上实现多种连接的样式,这个都是可以实现的

  2.有关于线是实线啊,虚线啊这些也都是可以实现的 虚线的话dashstyle可以来实现,应该是跟css差不多的

 

恩。。。。。

放一些废弃代码

initConnect(instance) {
            var that = this;
            instance.batch(function() {
                for (const point of that.$store.state.nodes) {
                    that.initNode(instance, point.node_id)
                    if (point.child_nodes.length > 0 || point.parent_node == 'root') {
                        instance.addEndpoint(point.node_id, {
                            uuid: `${point.node_id}-bottom`,
                            anchor: 'Bottom',
                            maxConnections: -1,
                            // connectorStyle: { stroke: '#2FB39C', strokeWidth: 2 },
                            // connectorHoverStyle: {
                            //     strokeWidth: 3,
                            //     stroke: "yellow",
                            // },
                            deleteEndpointsOnEmpty: true,
                            dragOptions: {},
                        }, {
                            isSource: true,
                            isTarget: true,
                        });
                    }
                    if (point.parent_node !== 'root') {
                        instance.addEndpoint(point.node_id, {
                            uuid: `${point.node_id}-top`,
                            anchor: 'Top',
                            maxConnections: -1,
                            deleteEndpointsOnEmpty: true,
                        }, {
                            isSource: true,
                            isTarget: true,
                        });
                    }
                    if (point.jump_nodes.length > 0) {
                        point.jump_nodes.forEach((item, index) => {
                            instance.connect({
                                source: point.node_id,
                                target: item,
                                paintStyle: {
                                    stroke: "#E72F1F",
                                    strokeWidth: 2.5,
                                    dashstyle: "4 2",

                                },
                                maxConnections: -1,
                                anchor: 'Right',
                                overlays: [
                                    ["Arrow",
                                        {
                                            width: 9,
                                            length: 8,
                                            location: 1,
                                            events: {
                                                click: function() {
                                                    // alert('click')
                                                }
                                            }
                                        }
                                    ],
                                    ["Custom", {
                                        create: function(component) {
                                            return $('<img src=' + shears + '>');
                                        },
                                        location: -50,
                                        events: {
                                            click: function(e) {
                                                that.deleteConfirmFun(instance, e.component)
                                            },

                                        }
                                    }]
                                ]
                            });
                        })
                    }
                }
                // init transition
                for (const i of that.$store.state.lines) {
                    const uuid = [`${i[0]}-bottom`, `${i[1]}-top`];
                    instance.connect({
                        uuids: uuid,
                    });
                }


            })
            var sourceEndpoint=this.jsPlumbInstance.getEndpoint(`A1-bottom`);
                console.log('sourceEndpoint',sourceEndpoint)
        },
addConnect(point) {
            var parent=this.findParentNode(point.node_id);
            // console.log('parentNode',parentNode)
            this.jsPlumbInstance.addEndpoint(point.node_id, {
                uuid: `${point.node_id}-bottom`,
                anchor: 'Bottom',
                maxConnections: -1,
                deleteEndpointsOnEmpty: true,
                dragOptions: {},
            }, {
                isSource: true,
                isTarget: true,
            });
            this.jsPlumbInstance.addEndpoint(point.node_id, {
                uuid: `${point.node_id}-top`,
                anchor: 'Top',
                maxConnections: -1,
                deleteEndpointsOnEmpty: true,
            }, {
                isSource: true,
                isTarget: true,
            });
            var sourceEndpoint=this.jsPlumbInstance.getEndpoint(`${parent.node_id}-bottom`);
            var targetEndpoint=this.jsPlumbInstance.getEndpoint(`${point.node_id}-top`);
            const uuid = [`${parent.node_id}-bottom`, `${point.node_id}-top`];
            this.jsPlumbInstance.connect({
                source:sourceEndpoint,
                target:targetEndpoint
            })
            this.jsPlumbInstance.repaintEverything({clearEdits:false})
        },
deleteEndpoint() {
            console.log('123')
            // jsPlumb.detach(conn);
            // 删除他与子元素的连接
            console.log(this.jsPlumbInstance)
            // this.jsPlumbInstance.remove(this.nodes[0].node_id);
            // this.jsPlumbInstance.empty(this.nodes[0].node_id);

            var a = this.jsPlumbInstance.getEndpoint(`${this.nodes[0].node_id}-bottom`)
            console.log('a', a)
            this.jsPlumbInstance.deleteEndpoint(a)
        },

 

 恩。。。还有一个问题

就是如果你连线的元素发生了位置的转移,如果你是通过端点去连接的

然后我想说 是确实需要重绘的

如果你元素的位置发生了改变

有什么想说的 欢迎来指教 

 

 

内容来源于网络如有侵权请私信删除
你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!