question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Interesting shrinking behavior with svg images

See original GitHub issue

@spinningarrow I’m using this as a plugin and it works great, thank you! However, I did notice some odd behavior with SVG used as <img src="image.svg" data-action="zoom" width="1024" height="768" />.

See attached GIF example, the first image “Hill Valley” is PNG, the second “Mountain Valley” is SVG and they use the same repeating HTML template and attributes, the only difference is their image format.

I inspected in Dev Tools and see transform: scale3d() injected into the dynamic.zoom-img-wrap img.zoom-img element:

  • For .png @ 1366px viewport: scale3d(1.25586, 1.25586, 1.25586)
  • For .svg @ 1366px viewport: scale3d(0.209961, 0.209961, 0.209961)

Why would they be off by “1”?

With the obvious benefits of SVG in various sizes, it seems this plugin would shine! I thought it could be the viewBox size in the SVG file, but the artboards export dimensions are viewBox="0 0 1024 768"

2018-03-17 14 43 12

Any ideas on a workaround for SVG?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
miguelpppirescommented, May 23, 2018

if you deselect the “responsive” option while you are exporting the svg, it works fine.

1reaction
zachlyoncommented, May 31, 2018

@MikeStardust - That was it!

Also, I compared the Norway flag SVG from the codepen with my SVGs and I see an explicit width and height attributes set, where mine only had viewBox dimensions.

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 1024 768"> ... </svg>

versus

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1024" height="768" viewBox="0 0 1024 768"> ... </svg>

I verified that SVGs from Illustrator’s “Export for Screens” now contain width and height if un-checking “Responsive”.

no-responsive

Read more comments on GitHub >

github_iconTop Results From Across the Web

Shrinking SVG code: path not always bigger
Most of the time the <path> element is used for more or less complex graphics. But in the case of Medium's symbol, it...
Read more >
SVG Style Inheritance and the 'Flash Of Unstyled SVG'
When CSS is disabled or fails to load for any reason—such as when you're on lo-fi, most SVG images, especially inline ones, will...
Read more >
How to Scale SVG | CSS-Tricks
Most of the time, the default behavior works pretty well: the image is scaled until it just fits both the height and width,...
Read more >
Weird shrink from SVG files - Fusion 360 - Autodesk Forums
Guys, I am experiencing a weird issue with svg files which are imported ... Report issues, bugs, and or unexpected behaviors you're seeing....
Read more >
Scaling of SVG backgrounds - CSS: Cascading Style Sheets
Given the flexibility of SVG images, there's a lot to keep in mind when using them as background images with the background-image property, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found