Skip to content

Instantly share code, notes, and snippets.

@intv0id
Last active May 27, 2019 14:12
Show Gist options
  • Save intv0id/e50d447d3e980e01e58467ca3bbcf265 to your computer and use it in GitHub Desktop.
Save intv0id/e50d447d3e980e01e58467ca3bbcf265 to your computer and use it in GitHub Desktop.
var onEnter, onExit, $d, hovered;
$d = $('.label');
$d.hide();
//hovered = jgraph.makeMaterial(0xffffff);
onEnter = function (node) {
$d.html('<p><b>' + node.name + '</b></p><br><p>' + node.label + '</p>');
$d.show();
node.defaultMaterial = node.material;
node.material = hovered;
};
onExit = function (node) {
$d.empty();
$d.hide();
node.material = node.defaultMaterial;
};
jgraph.onNodeHover(onEnter, onExit);
// Move the text showing name along with the mouse
$(document).mousemove(function (event) {
$d.css({ left: event.pageX + 10, top: event.pageY + 10 });
});
// Pop up a github window if a node is clicked
jgraph.onNodeClick(function (node) {
window.open(node.url, "_blank");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment