React-diagrams: Zoom-In and Zoom-Out events for DiagramEngine

Created on 15 Jul 2019  路  5Comments  路  Source: projectstorm/react-diagrams

Can anybody tell me how we can manage zoom-in & zoom-out events explicitly?
For example, if I want to zoom-in the engine on the click of button instead of using the mouse wheel?

Thanks in advance.

question

All 5 comments

I second this question, I have been trying to figure this out for awhile now.

@wstuckey You can take reference from below snippet which I tried and see if it helps.
let scaleFactor = 1; function zoomIn() { scaleFactor += (-10 * -0.01); scaleFactor = Math.min(Math.max(.125, scaleFactor), 1.5); this.customRef.style.transform =scale(${scaleFactor}); } function zoomOut() { scaleFactor += (10 * -0.01); scaleFactor = Math.min(Math.max(.125, scaleFactor), 1.5); this.scaleFactor = Math.max(this.scaleFactor, 0.5); this.customRef.style.transform =scale(${scaleFactor}); }

@dylanvorster I am trying to set the zoom with dropdown. It was not working for me in 6.0.2 version.

engine.model.setZoomLevel(25)

@JitendraBhamidipati you mean something like that?

image

I've implemented this on my project (logossim). You can try it out here.

And here's the code for the functions that handles these dropdown items. Basically, it calls engine.getActionEventBus().fireAction with some specific paramaters.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dixitk13 picture dixitk13  路  3Comments

schecter22107 picture schecter22107  路  3Comments

gugaevkirill picture gugaevkirill  路  3Comments

Naveenraj006 picture Naveenraj006  路  3Comments

iddan picture iddan  路  3Comments