Skip to content
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

Ability to centre or right align for fit SVG to viewer #65

Closed
auroranil opened this issue Dec 3, 2017 · 8 comments
Closed

Ability to centre or right align for fit SVG to viewer #65

auroranil opened this issue Dec 3, 2017 · 8 comments

Comments

@auroranil
Copy link
Contributor

This is for scenarios where the dimensions for the viewer and the canvas are not the same (the canvas is the rect that has a white background by default).

When clicking zoom to fit button, it fits the canvas to the left of the screen. It would be better if there is a way to align this canvas to the centre or to the right (without having to play around with bounds for fitSelectionToViewer method).

@auroranil
Copy link
Contributor Author

This is for scenarios where canvas width is smaller than viewer width when zoom to fit has been applied.

If it is the other way around when zoom to fit has been applied, then it would be nice to vertically align the canvas to the centre or to the bottom of the viewport.

@chrvadala
Copy link
Owner

chrvadala commented Dec 4, 2017

Unfortunately at this moment there isn't a method to fit and center. It requires few changes here

export function fitToViewer(value) {
return fitSelection(value, 0, 0, value.SVGWidth, value.SVGHeight);
}
. Probably in the future I will implement it, but actually there isn't any plan. Sorry ;)

@auroranil auroranil changed the title Ability to centre or right align for fit selection in a bound Ability to centre or right align for fit SVG to viewer Dec 8, 2017
@auroranil
Copy link
Contributor Author

For fitSelection, I realised that it should not try to "align" the canvas in any way. It's only useful for fitToViewer function.

@neilyoung
Copy link

@chrvadala May I ask you if there is any progress in this matter?

@chrvadala
Copy link
Owner

I'll publish a new version soon, but unfortunately this improvement isn't in this milestone..

@neilyoung
Copy link

OK, thanks. Never mind, please don't forget :)

@chrvadala
Copy link
Owner

Some updates here #120

chrvadala pushed a commit that referenced this issue Jul 29, 2018
* Added option to align svg while fitting it to the viewer

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).

* SVG alignment props moved to toolbarProps

Plus fitToViewer() changed to fitToViewer(SVGAlignX, SVGAlignY) in ReactSVGPanZoom

* adds a storybook example

* adds a storybook example

* adds doc
@chrvadala
Copy link
Owner

Feature released with 2.18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants