projectstorm / react-diagrams

a super simple, no-nonsense diagramming library written in react that just works
https://projectstorm.cloud/react-diagrams
MIT License
8.58k stars 1.17k forks source link

Feature Request: Limit the zoom levels #823

Closed asnaseer-resilient closed 3 years ago

asnaseer-resilient commented 3 years ago

It would be great if we had the capability to limit how far in/out a user could zoom. Our UI/UX designer has requested this on our app which makes use of this wonderful library. He wanted to limit zooms to between 1% and 400%.

renato-bohler commented 3 years ago

This is totally possible. I've done this in my project. You'll need to implement a custom ZoomAction.

On my implementation, the user can have the zoom only at a given set of levels.

You can check out the implementation here:

You can try it out here: https://renato-bohler.github.io/logossim/

asnaseer-resilient commented 3 years ago

@renato-bohler Really appreciate your insights - I managed to accomplish what my UI/UX designer wanted by following your guidance 👍