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

Fix: IE11 SVGs without defined width and height default to 0x0 #333

Merged
merged 4 commits into from
Aug 24, 2017
Merged

Fix: IE11 SVGs without defined width and height default to 0x0 #333

merged 4 commits into from
Aug 24, 2017

Conversation

Minh-Ng
Copy link
Contributor

@Minh-Ng Minh-Ng commented Aug 23, 2017

Follow up to #324

In chrome, Images without a defined width and height default to 300x150 (width x height).
(https://css-tricks.com/scale-svg/)
(https://connect.microsoft.com/IE/feedbackdetail/view/925655/svg-image-has-0x0-size-in-ie11)

Proposed workaround (and it is truly not ideal as is with most workarounds):
Load the source as text and attempt to parse it as an SVG. If the parsing succeeds, use the aspect ratio from the viewBox to scale the SVG within the 300x150 boundary. The height is the limiting axis in this case so we can use the aspect ratio to scale the width.
If the parsing fails, assume the image is not an SVG and assign it a size of 300x150 by default.

@Minh-Ng Minh-Ng merged commit bebdcec into box:master Aug 24, 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

Successfully merging this pull request may close these issues.

2 participants