reagraph icon indicating copy to clipboard operation
reagraph copied to clipboard

Min/MaxDistance not applying to manual zoom control

Open jsjohann opened this issue 10 months ago • 0 comments

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.

jsjohann avatar Apr 04 '24 12:04 jsjohann