-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
No way to center on first render #178
Comments
Hey @japgolly, take a look at this code to see if it helps: https://github.com/RNAcentral/auto-traveler-embed/blob/862f3c809a512b513207f5b8d3ebe10a0d51c907/src/containers/AutoTraveler/components/Results/index.jsx I'm not a React expert, but what I did was call the fitToViewer method on componentDidUpdate. I don't know if it's a good approach, but it works. What I'm trying to do now is to leave the width at 100% instead of a fixed value, any feedback is welcome. Cheers! |
Ah thank you @carlosribas ! That's a great workaround! It still causes two renders to occur, one unfitted, and then the second one fitted so I'll leave this ticket open. :) |
I agree. I would love to know if there is a way to center on first render. |
Hi, Would anyone know how to do the above workaround for a functional implementation? Thanks, |
In case anyone comes here with the same question: I applied the same workaround as below in my functional component: `
` |
Hi! I'm trying to get
ReactSvgPanZoom
to center by default on the first render. I've tried:fitToViewer(INITIAL_VALUE, ALIGN_CENTER, ALIGN_CENTER)
and passing the result asvalue
in theReactSvgPanZoom
propsfitToViewer(v, ALIGN_CENTER, ALIGN_CENTER)
and passing the result asvalue
in theReactSvgPanZoom
props, where I've manually setSVG{Width,Height,MinX,MinY}
andviewer{Width,Height}
myselfThe text was updated successfully, but these errors were encountered: