-
Notifications
You must be signed in to change notification settings - Fork 68
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
react-archer arrow wrong scale after zoom change and window resize #57
Comments
Hi! Thank you for the very detailed and reproducible issue 😊 Feel free to dive in the library's code and have a look too if you want to go faster. My guesses: when you zoom in and out without changing the window size, react-archer does not re-render because nothing changes from its perspective. However, when you resize the window, the main component is re-rendered. see So any re-render while zoomed in becomes buggy, because the computed positions become erroneous. The goal is then to understand why the positions are not correct when the panzoom is active 🤔 |
This may not be relevant to a permanent solution for the react-archer library but I came up with a workaround I'll share in case it is useful. I have only a basic understanding of javascript and so this probably has some issues but it seems to work for my usecase. I got a scale value used in the PanZoom transform and inverted it to later pass into the ArcherContainer
I replaced the return line in getPointCoordinatesFromAnchorPosition and applied the passed in scale multiplier react-archer/src/ArcherContainer.js Line 166 in fdfc213
I commented out the setState call in refreshScreen. Without this uncommented a rerender of the arrows triggered by a button seemed to look like it is the right scale and position however a screen resize still had similar behavior as before, but commenting out this line fixed the issue for me.
|
Glad that you have a workaround! I need to think this through and see if there's something cleaner, there must be 🤔 |
Any update on this by chance? I'm having the exact same issue:
Going to continue to dig into the calculation in the meantime and see if I can figure anything out! |
Hi @tsnolan23 ! I had a quick look but couldn't manage to identify the issue. I had not prioritized since there was a workaround. I don't have much time to investigate unfortunately 😞 Does it happen only on Chrome or on all browsers? |
@pierpo Seems to be all browsers - tested in Chrome, Firefox and Safari |
Hi, some modifications or workarounds about this bug ??? |
Thank you for this arrow library it has been useful but I am struggling to figure out a scaling issue.
I am using react-easy-panzoom as a wrapper component around react-archer elements to be able to pan and zoom around a large flow chart. I have had similar results with different pan-zoom libraries.
At PanZoom zoom level of "1" (no zoom) I can click->drag and pan around the chart and resize the containing window and everything works fine.
The issue is that if I zoom out with the mouse wheel using the PanZoom functionality the react-archer arrows scale properly and I can pan without issue, but then after resizing the window while zoomed out the react-archer arrows seem to rerender at the wrong scale. The further I zoom out and then resize the window the smaller the arrows will scale down to.
https://codesandbox.io/s/react-easy-panzoom-svg-scaling-behavior-g8vcn?fontsize=14
PanZoom zoom level 1 https://i.imgur.com/xr9RRQr.jpg
zoom out https://i.imgur.com/UjHUJ1m.jpg
resize after zoom out https://i.imgur.com/QcGzQWj.jpg
The text was updated successfully, but these errors were encountered: