-
-
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
Added option to align svg while fitting it to the viewer (#65) #120
Conversation
Alignment can be passed as optional props to ReactSVGPanZoom and Toolbar components or as arguments to the base fitToViewer function. Default alignment values are provided (aligning to top left, as before).
The prop names are probably misleading, now that I think of it. |
Thanks for your PR. It's a really useful feature and will close this issue I agree that is better to renames these two new props, because after the change of the method I think that we cold introduce a more general property that is |
Oh sure, it's better to have BTW, thanks for the awesome project! - really useful! 😃 |
You are right, probably there're other props that they would be better moved into |
Plus fitToViewer() changed to fitToViewer(SVGAlignX, SVGAlignY) in ReactSVGPanZoom
Right, obviously it's better to defer moving other props till the next major release. |
@@ -531,6 +532,12 @@ ReactSVGPanZoom.propTypes = { | |||
//Turn off zoom on double click | |||
disableDoubleClickZoomWithToolAuto: PropTypes.bool, | |||
|
|||
//toolbar props | |||
toolbarProps: PropTypes.shape({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't restrict the shape of toolbarProps
here in order not to restrict props for custom toolbars.
But it's surely safer this way :)
Thanks for your PR. I'm going to release with 2.18 version |
Feature released with 2.18. Thanks ;) |
Alignment can be passed as optional props
SVGAlignX
andSVGAlignY
to ReactSVGPanZoom and Toolbar components; or via arguments to the basefitToViewer
function.(What is passed to ReactSVGPanZoom will also be passed to the toolbar.)
Default alignment values are provided - aligning to top left, as before.
I will need the ability to fit and center svgs in one of my projects, so I thought I might as well write a bit more general solution for left/center/top horizontal alignment and top/center/bottom vertical alignment..