treant-js icon indicating copy to clipboard operation
treant-js copied to clipboard

How to add tooltip on hovering on the nodes

Open kuntalsam opened this issue 7 years ago • 3 comments

On each node. I am trying to show a tooltip containing more information. I could not find an easy way to do it. Please help.

kuntalsam avatar Dec 21 '17 10:12 kuntalsam

javascript

$(".node").hover(function () {
    var title = $(this).children(".node-title").html();
    $('<div class="node-tip"></div>').html(title).appendTo('body').fadeIn('slow');
}, function () {
    $('.node-tip').remove();
}).mousemove(function (e) {
    var mousex = e.pageX + 20;
    var mousey = e.pageY + 10;
    // console.log(mousex + "|" + mousey);

    $('.node-tip')
        .css({
            top: mousey,
            left: mousex
        });
});

css

.node-tip {
    display: none;
    position: absolute;
    border: 0px solid #333;
    background-color: rgba(0,0,0,0.7);
    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    border-radius: 10px;
    -webkit-box-shadow: #000 1px 5px 20px;
    -moz-box-shadow: #000 1px 5px 20px;
    box-shadow: #000 1px 5px 20px;
    padding: 10px;
    color: #fff;
    font-size: 16px;
    width: 250px;
}

AemonCao avatar Jan 17 '18 03:01 AemonCao

Is this working? I'm trying to implement tooltip with dynamic information and need help.

lchigami avatar Aug 02 '18 14:08 lchigami

Add title in node and in css: .node-title { display: none; position: absolute; }

.node-name:hover + .node-title { display: block; }

squalsoft avatar May 31 '20 17:05 squalsoft