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

SVGView ScaleAspectFit broken for non square SVG's #111

Closed
deathByLiche opened this issue Apr 5, 2017 · 6 comments
Closed

SVGView ScaleAspectFit broken for non square SVG's #111

deathByLiche opened this issue Apr 5, 2017 · 6 comments
Assignees
Milestone

Comments

@deathByLiche
Copy link

Svg's rendered in an SVGView using ScaleAspectFit are not scaled properly if the SVG is not approximately a square.

It looks like the svgNode.bounds() is returning a rect that is larger than the svg width and height, which then throws off the scaleAspectFit calculations. For example, an svg with a width of 320 and height of 700 (a tall rectangle) might have the svgNode.bounds() return a rect that is closer to a width of 700 and a height of 700 (a Square).

The algorithm seems to be correct as I commented out the two lines in the render method that calculates the svgWidth and svgHeight based on the node bounds, and replaced the values with the actual width and height of my test svg's and everything worked properly.

@ystrot ystrot added this to the 0.9.0 milestone May 10, 2017
@ystrot
Copy link
Member

ystrot commented May 11, 2017

Sorry for late response. A developer who was assigned to this issue is too busy on another project, so I'm reassigning this ticket. Could you please attach an SVG file with incorrect bounds calculation?

@ystrot ystrot assigned ystrot and unassigned shipinev May 11, 2017
@deathByLiche
Copy link
Author

Absolutely.

This svg is 247 x 344 but the rect returned from it's bounds is ~ 312 x 343, thus throwing off the scaling calculations. If you hardcode the width and height to be 247 x 344 in the scaling algorithm, it scales properly.

bodyMapCard.svg.zip

@ystrot
Copy link
Member

ystrot commented May 11, 2017

Thanks! Reproduced this issue.

@rmtmckenzie
Copy link

Any word on when this will be fixed? I've run into it in one of my projects. I may have time next week to investigate myself if someone can point me in the right direction...

@ystrot
Copy link
Member

ystrot commented Jun 19, 2017

Hi Morgan! Thanks for your readiness to help! However we just fixed this issue in the master. So you can try the latest version using:

pod 'Macaw', :git => 'https://github.com/exyte/Macaw.git'

@ystrot ystrot modified the milestones: 0.8.3, 0.9.0 Jun 19, 2017
@rmtmckenzie
Copy link

I'll give it a test, thanks!

@ystrot ystrot closed this as completed Sep 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants