jerosoler / Drawflow

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

how to dynamically increases output ? #581

Closed Co-Maheshh closed 1 year ago

Co-Maheshh commented 1 year ago

My scenerio is that i have a one node in editor when i click on that node one popup is opened. in that pop up we are given number like 2 or 3. if i am added 3 then.it will be immediately add 3 output on that node. how we can do like this.

Thank you in advance.

jerosoler commented 1 year ago

Please read documentation in readme: (Opened 9 issues.)

https://github.com/jerosoler/Drawflow#methods

Method - addNodeOutput - To increase outputs.

HeoYoungHyun commented 1 year ago

Can't I dynamically generate output?

jerosoler commented 1 year ago

Example:

editor.addNodeOutput(5);    
Co-Maheshh commented 1 year ago

How to restrict one input is connected to multiple output ? means input is need to connected to only one output ?

jerosoler commented 1 year ago

Before asking please try searching the issues.

Co-Maheshh commented 1 year ago

i used this method.but after that we need to initialize editor again or directly it added 5 outputs.

editor.addNodeOutput(5);

i am used this but it does not worked for me getting error like this.

image

jerosoler commented 1 year ago

Number 5 it's id of node to add ouput.

Co-Maheshh commented 1 year ago

can you provide one sample example ?

jerosoler commented 1 year ago

Example addoutput to node with id: 1

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <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>
</head>
<div id="drawflow"></div>
  <button onclick="addOuptutToNode()">add</button>
  <style>
    #drawflow { 
      position: relative;
      text-align:initial;
      width: 100%;
      height: 800px;
      border: 1px solid red;
    }
</style>
<script>
    var id = document.getElementById("drawflow");
    const editor = new Drawflow(id);

    editor.start();

    editor.addNode('test1', 1, 1, 200, 300, 'test1', {}, 'Hello World');
    editor.addNode('test1', 1, 1, 400, 300, 'test1', {}, 'Hello World2');
    editor.addNode('test1', 1, 1, 500, 300, 'test1', {}, 'Hello World3');

    function addOuptutToNode() {
        editor.addNodeOutput(1);
        editor.updateConnectionNodes('node-1');
    }
</script>
</body>
</html>
Co-Maheshh commented 1 year ago

Thanks for your constanr support.