jerosoler / Drawflow

Simple flow library 🖥️🖱️
https://jerosoler.github.io/Drawflow/
MIT License
4.42k stars 714 forks source link

How to use scroll bar #792

Closed krefects closed 7 months ago

krefects commented 7 months ago

I'm using this library to create a database diagram, everything works, however I have tables with many columns and they end up being very large, would it be possible to use a scroll bar while maintaining the connections? ![Uploading print.png…]()

krefects commented 7 months ago

print

jerosoler commented 7 months ago

I think it is possible, although it is rare.

Another option is to use a collapside method.

Example:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Document</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/jerosoler/Drawflow/dist/drawflow.min.css" />
  <script src="https://cdn.jsdelivr.net/gh/jerosoler/Drawflow/dist/drawflow.min.js"></script>
  <style>
    #drawflow {
      position: relative;
      width: 100%;
      height: 800px;
      border: 1px solid red;
    }

    .collapse {
        max-height: 50px;
    }
    .collapse .input {
        position: absolute !important;
        left: -14px !important;
        top: 20px !important;;
    }
  </style>
</head>
<body>
  <div>
    <div id="drawflow"></div>
  </div>
  <script>
    var id = document.getElementById("drawflow");
    const editor = new Drawflow(id);
    editor.start();

    function toogleClass(e) {
        const node = e.target.closest(".drawflow_content_node").parentElement;
        const id = node.id;
        node.classList.toggle("collapse");
        editor.updateConnectionNodes(id);

    }
    editor.addNode("github", 0, 1, 150, 300, "github", {}, '');
    editor.addNode("collapse", 20, 1, 400, 300, "", {}, '<button onclick="toogleClass(event)">Toogle</button>');
  </script>
</body>
</html>
krefects commented 7 months ago

Sem título