react-native-svg icon indicating copy to clipboard operation
react-native-svg copied to clipboard

Animated viewBox - transform scale is blury

Open harveyconnor opened this issue 5 years ago • 6 comments
trafficstars

Question

My issue is that whenever I animate my svg with a transform function it ends up being blury when I zoom in. The best alternative to this option would be to zoom in via the viewbox which will also offering a panning function. I'm wondering if anyone has been successful in animating the viewBox?

The closest thing I've gotten to is adding an event listener on the animated value however that doesn't update the viewBox with the new scale adjustments.

Please any suggestions or recommendations are welcome! Thanks!

harveyconnor avatar Sep 10 '20 12:09 harveyconnor

Same with me. @harveyconnor , were you ever able to do that?

guiccbr avatar Nov 29 '21 15:11 guiccbr

@guiccbr nope I could never get it to work. The support for this repo is dead.

harveyconnor avatar Dec 06 '21 03:12 harveyconnor

@harveyconnor , I got something working that was a good alternative to me. Instead of using the transform prop, I used the style prop on a <G>. The style prop is not typed though, but it works. And it's great because it doesn't distort the child paths.

Style also works for <Paths> btw. In my case I'm even using react-native-reanimated to animate stuff, and everything works great.

guiccbr avatar Dec 06 '21 12:12 guiccbr

Hi @guiccbr could you please share a repo with us that replicates what you have created :)

harveyconnor avatar Dec 08 '21 08:12 harveyconnor

I was able to resolve this by simply changing width height within SVG to 100%, wrap the SVG around the Animated.View and use useAnimatedStyle to change width and height. This way I get the smooth zoom effect on svg whereas transform scale results in pixelated zoom.

My problem is I am unabe to do same with custom exiting animation, width and height manipulation not seems to be working there and transform seems to be the only option, is it?

meepak avatar Jan 02 '24 11:01 meepak

whereas transform scale results in pixelated zoom.

Hi! This issue (pixelated zoom) has likely been resolved in #2299 and merged into the main branch. Please feel free to test it and provide feedback before the release.

Thank you!

jakex7 avatar Jun 26 '24 12:06 jakex7