chrvadala / react-svg-pan-zoom

:eyes: A React component that adds pan and zoom features to SVG
https://chrvadala.github.io/react-svg-pan-zoom/
MIT License
681 stars 127 forks source link

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

Closed auroranil closed 6 years ago

auroranil commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

Unfortunately at this moment there isn't a method to fit and center. It requires few changes here https://github.com/chrvadala/react-svg-pan-zoom/blob/221a75a8c725f90da87b715bed305088b58b423c/src/features/zoom.js#L49-L51. Probably in the future I will implement it, but actually there isn't any plan. Sorry ;)

auroranil commented 6 years ago

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

neilyoung commented 6 years ago

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

chrvadala commented 6 years ago

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

neilyoung commented 6 years ago

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

chrvadala commented 6 years ago

Some updates here https://github.com/chrvadala/react-svg-pan-zoom/pull/120

chrvadala commented 6 years ago

Feature released with 2.18