最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - JSPlumb show connection label on hover - Stack Overflow

programmeradmin2浏览0评论

I'm using JSPlumb to connect a bunch of blocks and I am able to set a label for a connection using:

JSPLUMB_INSTANCE.bind("connection", function (info) {
    info.connection.getOverlay("label").setLabel("w="+width+"<br>p="+pipelining);
});

This way the label is always visible on the connection. Is there a way to make the label only appear on mouse hover?

I'm using JSPlumb to connect a bunch of blocks and I am able to set a label for a connection using:

JSPLUMB_INSTANCE.bind("connection", function (info) {
    info.connection.getOverlay("label").setLabel("w="+width+"<br>p="+pipelining);
});

This way the label is always visible on the connection. Is there a way to make the label only appear on mouse hover?

Share asked Jul 6, 2014 at 17:39 mohsaiedmohsaied 2,1361 gold badge17 silver badges25 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

I've had the same challenge as you are describing, my solution looks like this:

function setConnectionLabel(connection, label) {
    connection.bind("mouseenter", function(conn) {
        conn.addOverlay(["Label", { label: label, location:0.5, id: "connLabel"} ]);
    }); 

    connection.bind("mouseout", function(conn) {
        conn.removeOverlay("connLabel");
    });
}

So in your case this should do the trick:

JSPLUMB_INSTANCE.bind("connection", function (info) {
    setConnectionLabel(info.connection, "Labeltext");
});

let me know if it works out for you, cheers!

Update: Use "mouseover" instead of "mouseenter"
New Documentation

发布评论

评论列表(0)

  1. 暂无评论