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.

IonicV4 - inline SVG image disappears

See original GitHub issue

Bug report

I am upgrading an application from Ionic-v3 to Ionic-v4. My app has an inline SVG image and is very simply setup.

Expected behaviour

Simple inline SVG image will display and pan/zoom while using IonicV4.

Actual behaviour

It works great in V3 but in V4, upon setting up the library to connect to the SVG, the SVG image disappears.

Steps to reproduce the behaviour

I forked a rough Ionic V4 boilerplate at the following URL. It gives some TypeErrors upon changing code - but that is not the issue. You can just refresh to get rid of those.

https://stackblitz.com/edit/ionic-v4-angular-tabs-svgpanzoom

Tab one has the full setup while tab 2 has svgPanZoom(elm, options) commented out.

In Tab 1, the SVG image no longer displays and interacting with the screen throws errors (ERROR Error: Failed to execute ‘inverse’ on ‘SVGMatrix’: The matrix is not invertible).

In Tab 2, the SVG still displays because it hasn’t been setup.

The only difference between the two tabs is the svgPanZoom init.

Configuration

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

4reactions
bsbechtelcommented, Oct 23, 2019

So I figured out what’s going on here. See this issue. Basically your svg dimensions are not known when the component is initialized, as is the same with all ionic components, because they are based on web components. The easy fix is to wrap your zvg-pan-zoom initializer in a setTimeout function. The right and hard way to do it is to hook into your ionic lifecycle methods or wait for the web component to fire a ready event.

0reactions
bsbechtelcommented, Oct 23, 2019

So I have a project that works on the web, and the implementation is exactly the same as the Ionic implementation, and I’m seeing the same issue with the graphic element being added improperly.

I’ve done a little digging, and with Ionic, so far from what I can tell the getBoundingClientRectNormalized method in svg-utilities is returning 0 values for all properties in Ionic. Not sure what’s causing this yet, but that appears to be the root cause of the issue. image

Edit: The web project uses Angular 8, so that helps narrow the issue to Ionic, as the implementations are otherwise identical.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IonicV4 - inline SVG image disappears · Issue #353 - GitHub
Bug report I am upgrading an application from Ionic-v3 to Ionic-v4. My app has an inline SVG image and is very simply setup....
Read more >
inlineSVG disappears on navigation in ionic - Stack Overflow
I have an image with [inlineSVG]. When I navigate to the page, it appears for few seconds then disappear. .html file of my...
Read more >
Ionic 3 svg image missing on real device
i put my svg files on …/assets/icon/home.svg. when i test on browser, firefox, chrome, safari, it's all working. but on ios real device...
Read more >
5 Gotchas You're Gonna Face Getting Inline SVG ... - CSS-Tricks
Gotcha One: Missing the Target. In order to achieve caching using an external SVG file (you seriously don't want to dump ~1.5kb *...
Read more >
Froala Editor v3.x - ComponentSource
Fixed char counter is missing when the inlineToolbar is enabled. Fixed Ionic4: toolbarBottom option doesn't work. Fixed cannot upload .svg image in the ......
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