Skip to content
This repository has been archived by the owner on Sep 28, 2021. It is now read-only.

remote SVG image can't be rendered? #449

Open
Xi-gofore opened this issue Feb 2, 2021 · 7 comments
Open

remote SVG image can't be rendered? #449

Xi-gofore opened this issue Feb 2, 2021 · 7 comments

Comments

@Xi-gofore
Copy link

Xi-gofore commented Feb 2, 2021

Does this library support remote SVG image rendering & pan-zooming?

I am developing a react-native mobile app.
Mybackend returns image url like https://foo.com/bar.svg, I tried to render it with this library in the following way:

const svgImage = [{url: image.url}];
<ImageViewer
            enableImageZoom={true}
            ref={() => {}}
            onChange={() => {}}
            renderIndicator={() => null}
            backgroundColor={'transparent'}
              imageUrls={svgImage} />

But when I run the app, it shows me blank screen, no SVG image is rendered.

@blazk0
Copy link

blazk0 commented Feb 5, 2021

You need to wrap it in a Modal otherwise it wont show.

@Xi-gofore
Copy link
Author

Xi-gofore commented Feb 8, 2021

@blazk0 thanks, I tried the following the modal shows but the remote svg is not rendered on screen still.

<View>
  ...
  <Modal visible={true}>
        <ImageViewer
           width={winWidth}
           height={winHeight}
           enableImageZoom={true}
                imageUrls={svgImage} />
        </Modal>
</View>

Where the winWdith and winHeight are the width and height of the mobile simulator screen.

const winWidth = Dimensions.get('window').width;
 const winHeight = Dimensions.get('window').height;

(For example to render a remote SVG like this one https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/Steps.svg )

@blazk0
Copy link

blazk0 commented Feb 8, 2021

@Xi-gofore have you tried giving the svg width and height ?
if it does not show , then try using react native remote svg which gives you Image Component that supports svg.

Just use renderImage Prop in ImageViewer and use that Image Component.

@Xi-gofore
Copy link
Author

Xi-gofore commented Feb 8, 2021

@blazk0 Yes, I have tried giving svg width and height like :

const svgImage = [{ url: svgImg.url, width: winWidth, height: winHeight }];

The svg is not shown either.

The key feature for my project is not only showing the remote SVG image but also having pan-zoom feature. Do you have any suggestion about other libraries? What do you mean react native remote svg exactly? Could you please provide a link about that?

@blazk0
Copy link

blazk0 commented Feb 8, 2021

@Xi-gofore you are just changing the image component, i dont think it will affect the pan zoom feature.

here is the link : react-native-remote-svg

@Xi-gofore
Copy link
Author

@blazk0 I tried that library, yes it renders the remote svg but no pan-zoom feature, but you said you don't think it affects pan zoom feature, how can I have the pan-zoom?

@blazk0
Copy link

blazk0 commented Feb 9, 2021

@Xi-gofore have you downloaded this lib ?

this package is dependent on it

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants