jerosoler / Drawflow

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

"view" editor mode disables translate click/drag #848

Closed wildhart closed 2 months ago

wildhart commented 3 months ago

The "view" editor mode introduced in #143 breaks the translate function. I can still zoom with the mouse-wheel, but click/drag on the canvas doesn't translate.

The description of PR #143 states:

As editor_mode set to 'view' there only move canva and zoom available.

So this seems like a bug to me...

I'm using drawflow 0.0.59

jerosoler commented 2 months ago

Simple test with version 0.0.59 and works correctly.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Drawflow</title>
  <link rel="stylesheet" href="https://unpkg.com/drawflow@0.0.59/dist/drawflow.min.css" />
  <script src="https://unpkg.com/drawflow@0.0.59/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.editor_mode = "view";
    editor.start();
    const node1 = editor.addNode('test2', 1,1, 50, 100, 'test2', {}, "Hello World" );
  </script>
</body>
</html>

Could this be your problem?

wildhart commented 2 months ago

Yes, #469 was the culprit, thanks!

I was also adding a class to the container to hide the connector dots in read-only mode.