css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <div class="container">
  <div class="panzoom">
    <div class="diagram">
      <div id="i0"  class="item">Root!</div>
      <div id="i1" class="item">Child 1</div>
      <div  id="i11" class="item">Child 1.1</div>
      <div  id="i12" class="item">Child 1.2</div>
      <div id="i2" class="item">Child 2</div>
      <div id="i21" class="item">Child 2.1</div>
      <div id="i3" class="item">Child 3</div>
    <div class="hint">
        <li>Drag and drop empty space to pan</li>
        <li>Nodes are also draggable</li>
        <li>Mouse wheel to pan up/down</li>
        <li>Shift+Mouse wheel to pan left/right</li>
        <li>Ctrl+Mouse wheel to zoom in/out</li>
        <li><a href="https://jsplumbtoolkit.com/community/doc/home.html">jsPlumb Community Edition</a></li>
        <li><a href="https://github.com/timmywil/jquery.panzoom">jQuery Panzoom plugin</a><br>My <a href="https://github.com/YuriGor/jquery.panzoom/tree/ignoreChildrensEvents">branch</a> used, to avoid children's events conflict, see discussion <a href="https://github.com/timmywil/jquery.panzoom/issues/299">here</a> for details.</li>
        <li><a href="https://github.com/cpettitt/dagre">Dagre for initial auto-layout</a></li>
        <li><a href="https://jqueryui.com/draggable/">jQueryUI Draggable for dragging nodes</a></li>
      <a  target="_blank" href="http://yurigor.com/pan-zoom-jsplumb-dagrejs-jqueryui-draggable/">See my blog for details</a>
              $EntityTypeColor: #00BFFF;
.container {
  background-color: black;
  color: $EntityTypeColor;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  top: 0;

.panzoom {
  position: absolute;
  background-color: rgba(blue,.1);
  left: 50px;
  top: 20px;
  overflow: visible;
  border: 5px dotted rgba(#CCC,.1);
.diagram {
  position: absolute;
.item {
  cursor: pointer;
  position: absolute;
  overflow: hidden;
  border: 1px solid darken($EntityTypeColor,30%);
  padding: 8px;
  border-radius: 3px;
  background-color: rgba($EntityTypeColor, .2);
  &:hover {
    border: 1px solid $EntityTypeColor;

.jsplumb-connector path {    stroke:$EntityTypeColor;
.hint {
  position: absolute;
  color: grey;
  top: -24px;
  h4 {
  a {
    color: red;
    text-decoration: none;
    &:hover {
     text-decoration: underline; 
  li a {
    color: $EntityTypeColor;
              var minScale = 0.4;
var maxScale = 2;
var incScale = 0.1;
var plumb = null;
var $container = $(".container");
$diagram = $container.find(".diagram");
var $panzoom = null;
var links = [
  { from: "i0", to: "i1" },
  { from: "i1", to: "i11" },
  { from: "i1", to: "i12" },
  { from: "i0", to: "i2" },
  { from: "i2", to: "i21" },
  { from: "i0", to: "i3" },

jsPlumb.ready(function() {
  plumb = jsPlumb.getInstance({
    PaintStyle: { strokeWidth: 1 },
    Anchors: [["Left","Right","Bottom"], ["Top","Bottom"]],
    Container: $diagram,
       connector: [ "Flowchart",
          cornerRadius: 3,
       overlays:[["Arrow",{location:1,width:10, length:10}]],
  var dg = new dagre.graphlib.Graph();
  dg.setDefaultEdgeLabel(function() { return {}; });
    function(idx, node) {
      var $n = $(node);
      var box = {
        width  : Math.round($n.outerWidth()),
        height : Math.round($n.outerHeight())
      dg.setNode($n.attr('id'), box);      
    .forEach(function(edge) {dg.setEdge(edge.source.id,edge.target.id);});
  var graphInfo = dg.graph();
    function(n) {
      var node = dg.node(n);
      var top = Math.round(node.y-node.height/2)+'px';
      var left = Math.round(node.x-node.width/2)+'px';
      $('#' + n).css({left:left,top:top});
    $panzoom = $container.find('.panzoom').panzoom({
      minScale: minScale,
      maxScale: maxScale,
      increment: incScale,
      cursor: "",
    .on('mousewheel.focal', function( e ) {
        var delta = e.delta || e.originalEvent.wheelDelta;
        var zoomOut = delta ? delta < 0 : e.originalEvent.deltaY > 0;
        $panzoom.panzoom('zoom', zoomOut, {
           animate: true,
           exponential: false,
        var deltaY = e.deltaY || e.originalEvent.wheelDeltaY || (-e.originalEvent.deltaY);
        var deltaX = e.deltaX || e.originalEvent.wheelDeltaX || (-e.originalEvent.deltaX);
          animate: true,
          relative: true,
    .on("mousedown touchstart",function(ev){
      var matrix = $container.find(".panzoom").panzoom("getMatrix");
      var offsetX = matrix[4];
      var offsetY = matrix[5];
      var dragstart = {x:ev.pageX,y:ev.pageY,dx:offsetX,dy:offsetY};
      $(this).data('dragstart', dragstart);
    .on("mousemove touchmove", function(ev){
      var dragstart = $(this).data('dragstart');
        var deltaX = dragstart.x-ev.pageX;
        var deltaY = dragstart.y-ev.pageY;
        var matrix = $container.find(".panzoom").panzoom("getMatrix");
        matrix[4] = parseInt(dragstart.dx)-deltaX;
        matrix[5] = parseInt(dragstart.dy)-deltaY;
    .on("mouseup touchend touchcancel", function(ev){
  var currentScale = 1;
  $container.find(".diagram .item").draggable({
    start: function(e){
      var pz = $container.find(".panzoom");
      currentScale = pz.panzoom("getMatrix")[0];
      ui.position.left = ui.position.left/currentScale;
      ui.position.top = ui.position.top/currentScale;
    stop: function(e,ui){
      var nodeId = $(this).attr('id');
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................