Comments (7)
Hi!
Thank you for the very detailed and reproducible issue 😊
I'll have a look at this when I have some time but I am quite busy these days 😞
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.
I guess that we could confirm this hypothesis by adding a new element while zoomed in and validating that we see the problem as well.
The goal is then to understand why the positions are not correct when the panzoom is active 🤔
from react-archer.
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
var scale = 1.0
if(this.mainPanzoomRef.current !== null){
scale = 1 / this.mainPanzoomRef.current.state.scale
scale = scale
}
ref={this.mainPanzoomRef}
...
<ArcherContainer scale={scale}>
I replaced the return line in getPointCoordinatesFromAnchorPosition and applied the passed in scale multiplier
react-archer/src/ArcherContainer.js
Line 166 in fdfc213
var retPos = absolutePosition.substract(parentCoordinates);
retPos.x = retPos.x * this.props.scale
retPos.y = retPos.y * this.props.scale
return retPos;
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.
refreshScreen = (): void => {
//this.setState({ ...this.state });
};
from react-archer.
Glad that you have a workaround! I need to think this through and see if there's something cleaner, there must be 🤔
I might have done something wrong with the core of the library itself.
from react-archer.
Any update on this by chance? I'm having the exact same issue:
- I attempted the workaround described above, but didn't have any luck with it
- As an alternative, I called the
refreshScreen
method whenever the zoom level changed in attempt to mimic the window re-sizing, but no luck there either
Going to continue to dig into the calculation in the meantime and see if I can figure anything out!
from react-archer.
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?
from react-archer.
@pierpo Seems to be all browsers - tested in Chrome, Firefox and Safari
from react-archer.
Hi, some modifications or workarounds about this bug ???
from react-archer.
Related Issues (20)
- Ability to set negative offset; HOT 1
- Suggest: Render order of paths HOT 1
- Problem in Creating Dynamic Archer Elements HOT 1
- `endShape` prop does not work properly `ArcherContainer`
- Arrows are disappearing when I click a button HOT 10
- Minified React error #321 in v4.0.0 HOT 13
- throttle on refreshScreen
- Not working with translate property HOT 3
- Is there any other way to add onClick event for each ArcherElement? HOT 2
- Cant access refs inside <ArcherElement> component HOT 2
- In a Next.js app when you go to a page via a <Link /> click the lines don't load, but when you refresh the page the lines work HOT 6
- Remix: react-archer seems to not be compatible with SSR HOT 4
- arrows don't re-render correctly HOT 4
- Feature request: Allow anchors to be placed absolutely or a percentage of total width/height HOT 1
- Support rotating boxes HOT 1
- ArcherContainer content container fixed height '100%' don't work on dynamic content HOT 2
- curved path between short distances HOT 4
- data.map => multiple ArcherElements cause the forwardRef error HOT 1
- Possibly a duplicate regarding flexDirection: row HOT 2
- Is this library support to draw from one box to multiple boxes?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-archer.