garblovians / react-native-svg-pan-zoom

Pan-zoom via two-finger "Google Maps"-style pinch and drag gestures
MIT License
26 stars 23 forks source link

Inside <SvgPanZoom> when placing <Svg><Image></Svg> image is not rendered #7

Open ddzirt opened 5 years ago

ddzirt commented 5 years ago

If we add that contains inside into , image will not be rendered.

For example: `<SvgPanZoom canvasHeight={500} canvasWidth={500} minScale={0.5} initialZoom={0.7} onZoom={zoom => { console.log('onZoom:' + zoom); }} canvasStyle={{ backgroundColor: 'yellow' }} viewStyle={{ backgroundColor: 'green' }}

Alert.alert('press')} /> Alert.alert('press')} />

`

while this will work: <Svg viewBox="0 0 100 100" width={width} height={height}> <Rect fill="black" x="0" y="0" width="100" height="100" onPress={() => Alert.alert('press')} /> <Image x="0" y="0" width="100" height="100" href={require('./assets/Kingfisher.jpg')} onPress={() => Alert.alert('press')} /> </Svg>

Aniganesh commented 1 month ago

Not the maintainer but it appears you're using the component wrong. You're supposed to have

<SvgPanZoom ...>
{any svg elements}
</SvgPanZoom>

not

<SvgPanZoom ...>
       <Svg> 
         {any svg elements}
       </Svg>
</SvgPanZoom>

as per the documentation not that the first snippet does not instantiate Svg inside SvgPanZoom.