jerosoler / Drawflow

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

How to initialize canvas position? #583

Closed rhl88 closed 1 year ago

rhl88 commented 1 year ago

After moving the canvas, ajax loads a new one. The canvas is not initialized.

After dragging, the coordinates before ajax loading.

rhl88 commented 1 year ago

video https://youtu.be/Aazl6p0ItVQ

jerosoler commented 1 year ago

For default not saved in export canvas position.

Save canvas position. Load data. Load data position.

Use method:

rhl88 commented 1 year ago

Thank you. After loading, use editor.translate_to(0,0)

editor.translate_to = function(x,y)
 {
  this.canvas_x = x; 
 this.canvas_y = y ;
 let storedZoom = this.zoom;
 this.zoom = 1;
 this.precanvas.style.transform = "translate("+this.canvas_x+"px, "+this.canvas_y+"px) scale("+this.zoom+")";
 this.zoom = storedZoom;
 this.zoom_last_value = 1;
 this.zoom_refresh();
 }