JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
<script src="http://jsplumb.org/js/jquery.jsPlumb-1.3.16-all-min.js"></script>
<div class="w" id="opened">
Begin
<div class="ep">
</div>
</div>
<div class="w" id="off">
Off
<div class="ep">
</div>
</div>
<div class="w" id="on">
On
<div class="ep">
</div>
</div>
CSS
#opened
{
left: 10em;
top: 5em;
}
#off
{
left: 12em;
top: 15em;
}
#on
{
left: 28em;
top: 15em;
}
.w
{
width: 5em;
padding: 1em;
position: absolute;
border: 1px solid black;
z-index: 4;
border-radius: 1em;
border: 1px solid #346789;
box-shadow: 2px 2px 19px #e0e0e0;
-o-box-shadow: 2px 2px 19px #e0e0e0;
-webkit-box-shadow: 2px 2px 19px #e0e0e0;
-moz-box-shadow: 2px 2px 19px #e0e0e0;
-moz-border-radius: 0.5em;
border-radius: 0.5em;
opacity: 0.8;
filter: alpha(opacity=80);
cursor: move;
}
.ep
{
float: right;
width: 1em;
height: 1em;
background-color: #994466;
cursor: pointer;
}
.labelClass
{
font-size: 20pt;
}
JavaScript
jsPlumb.importDefaults({
Endpoint: ["Dot", { radius: 5}],
HoverPaintStyle: { strokeStyle: "blue", lineWidth: 2 },
ConnectionOverlays: [
["Arrow", { location: 1, id: "arrow", length: 14, foldback: 0.8}]
]
});
jsPlumb.makeTarget($(".w"), {
dropOptions: { hoverClass: "dragHover" },
anchor: "Continuous"
});
$(".ep").each(function (i, e) {
var p = $(e).parent();
jsPlumb.makeSource($(e), {
parent: p,
anchor: "Continuous",
connector: ["StateMachine", { curviness: 20}],
connectorStyle: { strokeStyle: '#42a62c', lineWidth: 2 },
maxConnections: 2,
onMaxConnections: function (info, e) {
alert("Maximum connections (" + info.maxConnections + ") reached");
}
});
});
jsPlumb.bind("connection", function (info) {
});
jsPlumb.draggable($(".w"));
jsPlumb.connect({ source: "opened", target: "off" });
jsPlumb.connect({ source: "off", target: "on", label: "Turn On" });
jsPlumb.connect({ source: "on", target: "off", label: "Turn Off" });