jerosoler / Drawflow

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

Add Methods for SetZoom and SetTranslate #107

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hey!

Not spoke in a while, Drawflow is still working really well for us!

I was wondering if it was possible for you to add a SetZoom and SetTranslate function.

So the values from the zoom event and the translate event can be saved and reloaded at a later date. This could also be useful for manual movement.

Thanks, Joe

jerosoler commented 3 years ago

Hello @icabbi-joegarlick

I'm glad it worked for you.

I will look to implement them. As long as you can use.

View for setTranslate https://github.com/jerosoler/Drawflow/issues/88

For zoom you can use the functions zoom_in andzoom_out or zoom_refresh.

Jero

ghost commented 3 years ago

Thank you @jerosoler!

Yes I am currently using the zoom functions however id like to use the value outputted from the zoom event.

I tried doing:

editor.zoom = 0.9; editor.zoom_refresh();

however this seems to break zooming. It will only work when editor.zoom = 1.0 anything else breaks zooming.

Thank you for the setTranslate! I should have searched... Could this be added to the main code base?

Joe

jerosoler commented 3 years ago

Maybe you need to play with the variable zoom_last_value

Another way to do it, calculate the value and:

for(var i= 0; i<5; i++){
    editor.zoom_in();
}

The setTranslate function would have to check the function, I don't know if it's completely correct.

Which I have time to review.

ghost commented 3 years ago

Ah, thanks for the reply. Zoom is working now

            const zoomAmount = response.data.data.zoom;

            if (zoomAmount != 1.00) {
              this.editor.zoom_last_value = this.editor.zoom;
              this.editor.zoom = zoomAmount;
              this.editor.zoom_refresh();
            }