Repository navigation
Get the current ReactFlow map zoom level #2145
|
Hello everyone! Thank you a lot for the support and you did an amazing job with the library! |
Replies: 3 comments 10 replies
|
I managed to get the desired behavior accessing directly the DOM elements by the default reactflow classnames:
And setting the cursor and opacity style properties. Hope this can be useful for anyone else! |
|
You can get the current zoom level from the useReactFlow hook. Here are some other stuff you can get from it: https://reactflow.dev/api-reference/types/react-flow-instance |
|
This is still a problem... there is no apparent way to listen to only the |
I managed to get the desired behavior accessing directly the DOM elements by the default reactflow classnames:
react-flow__controls-zoomin
react-flow__controls-zoomout
And setting the cursor and opacity style properties.
To understand when the maximum zoom or the minimum zoom was reached, I counted the number of clicks necessary to reach the max and minimum levels and used the onZoomIn and onZoomOut callbacks of the react-flow component to set an internal state variable currentZoomLevel and used that to set the style properties.
Hope this can be useful for anyone else!