Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Min/MaxDistance not applying to manual zoom control #217

Open
jsjohann opened this issue Apr 4, 2024 · 0 comments
Open

Min/MaxDistance not applying to manual zoom control #217

jsjohann opened this issue Apr 4, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@jsjohann
Copy link

jsjohann commented Apr 4, 2024

Describe the bug

When setting minDistance and maxDistance on the GraphCanvas element, these settings have only an impact when zooming in/out with the mouse wheel gesture. Now, if you're using manual controls and call ref.current?.zoomIn() or ref.current?.zoomOut(), these settings are ignored and you can zoom in/out beyond these limits.

Steps to Reproduce the Bug or Issue

  1. Set min/maxDistance on the GraphCanvas like:
maxDistance={10000}
minDistance={1000}
  1. Add buttons to control the zoom of the graph which call graphRef.current?.zoomIn() or graphRef.current?.zoomOut()
  2. The view now goes beyond the provided bounds

Expected behavior

When setting min/maxDistance values, these should also apply to programmatically zooming in/out for consistency reasons.

Platform

  • Reagraph Version: 4.15.26
  • OS: macOS
  • Browser: Chrome

Additional context

Looks like that these manual zoom functions are looking for the minZoom and maxZoom values of the graphRef.current.getControls() object. I can manually overwrite these settings to limit the possible zoom but I guess it would be beneficial that the zoom limitations (e.g. setting min/maxDistance) are shared between gesture and 'manual' control. Alternatively, it would be nice to set min/maxZoom on the GraphCanvas as well instead of min/maxDistance to control both zoom limitations.

@amcdnl amcdnl added the bug Something isn't working label Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants