jerosoler / Drawflow

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

UI becomes unresponsive to adding connections after around 20-30 have been added. #693

Open thatrandomperson5 opened 1 year ago

thatrandomperson5 commented 1 year ago

Like the title says, I can in some places no longer even get a new "thread" using my mouse, and in others it refuses to connect.

jerosoler commented 1 year ago

Hello,

Perhaps the problem is another here an example with 100 nodes and 100 connections.

Does the javascript console show you any errors?

Can you detail the error?

<!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;
      }
      </style>
  </head>
  <body>
    <div>
        <div id="drawflow"></div>  
    </div>
    <script>
    var id = document.getElementById("drawflow");
    const editor = new Drawflow(id);
    editor.start();
    let lastId = 0;
    const nodes = [];
    for (let index = 0; index < 100; index++) {

        const nodeId = editor.addNode('test1', 1, 1, Math.floor(Math.random() * 3000) + 1, Math.floor(Math.random() * 1600) + 1, 'test1', {}, '<div>Num:'+index+'</div>');
        if(lastId !== 0) {
        editor.addConnection(nodeId, lastId, "output_1", "input_1");      
        }
        nodes.push(nodeId);
        lastId = nodeId; 
    }
</script> 
  </body>
</html>
thatrandomperson5 commented 1 year ago

@jerosoler, the one difference of your example was that you had many nodes and many connections. In my situation I had around 5-10 nodes, but more connections total and per-node.

jerosoler commented 1 year ago

how many connections?