JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://mking.me/html5-node-diagram/diagram.css">
<script src="http://mking.me/html5-node-diagram/models-no-arrowhead-drag.js"></script>
<div id="stage">
</div>
CSS
html {
height: 100%;
}
body {
-webkit-user-select: none;
-moz-user-select: none;
height: 40%;
margin: 0;
padding: 0;
font-family: helvetica, san-serif;
}
.node {
-webkit-border-radius: 48px;
-moz-border-radius: 48px;
border-radius: 48px;
background: #067195;
/* background-image: url(DC.jpg); */
border: 2px solid #FFF;
box-shadow: 0 0 5px #888;
position: absolute;
top: 0;
left: 0;
z-index: 2;
-webkit-backface-visibility: hidden;
}
.node h4 {
color: #067195;
text-shadow: -1px -1px 0 #ffffff, 1px -1px 0 #ffffff, -1px 1px 0 #ffffff, 1px 1px 0 #ffffff;
margin: 0;
padding: 0;
position: absolute;
width: 56px;
left: 8px;
top: 57px;
bottom: 0;
font-size: 12px;
}
.node.animate {
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.node:hover {
cursor: pointer;
}
.node.dragging {
z-index: 99;
}
.segment {
position: absolute;
top: 0;
left: 0;
background: #bae4b3;
z-index: 1;
-webkit-transform-origin: 0 100%;
-moz-transform-origin: 0 100%;
-ms-transform-origin: 0 100%;
transform-origin: 0 100%;
border: 1px solid white;
border-right: 0;
-webkit-backface-visibility: hidden;
}
.segment .endpoint {
position: absolute;
top: -9px;
}
#stage{
height: 50%;
width: 50%;
}
JavaScript
var stage = $('#stage');
var NODE_DIMENSIONS = {
w: 50,
h: 50
};
var NodeA = new Node({
title: 'NodeA',
stage: stage,
w: NODE_DIMENSIONS.w,
h: NODE_DIMENSIONS.h,
x: 300,
y: 200,
events: {
click: function() {
window.console.log(this);
}
}
}).attach();
var NodeB = new Node({
title: 'NodeB',
stage: stage,
w: NODE_DIMENSIONS.w,
h: NODE_DIMENSIONS.h,
x: 100,
y: 50
}).attach();
var NodeC = new Node({
title: 'NodeC',
stage: stage,
w: NODE_DIMENSIONS.w,
h: NODE_DIMENSIONS.h,
x: 100,
y: 300
}).attach();
var NodeD= new Node({
title: 'NodeD',
stage: stage,
w: NODE_DIMENSIONS.w,
h: NODE_DIMENSIONS.h,
x: 500,
y: 50
}).attach();
new Segment({
h: 5,
stage: stage,
origin: NodeA,
destination: NodeB
}).attach();
new Segment({
h: 5,
stage: stage,
origin: NodeA,
destination: NodeC
}).attach();
new Segment({
h: 5,
stage: stage,
origin: NodeA,
destination: NodeD
}).attach();