peoplewareDo / nativescript-svg

Nativescript plugin - support for .SVG file format
Other
70 stars 55 forks source link

Aspect Ratio Ignored in iOS #39

Open drewcovi opened 5 years ago

drewcovi commented 5 years ago

Is there any way to enforce aspect ratio in iOS? At present, the nativescript.svg stretches to fill the width of the container and height, completely ignoring both viewbox and preserveaspectratio parameters.

drewcovi commented 5 years ago

@victorsosa any idea what might be going on here? should this plugin get updated to create a container and manually respect the preserveAspectRatio settings?

victorsosa commented 5 years ago

@drewcovi no idea; viewbox and preserveaspectratio parameters? please show me where are those?? or how to use them

drewcovi commented 5 years ago

They’re properties on any given svg element including the Nativescript svg included in this plugin. They’re used to ensure proportional scaling. I’ll hunt down an example of how this was done in React Native land.

victorsosa commented 5 years ago

the nativescript.svg stretches to fill the width of the container and height

that's true

drewcovi commented 5 years ago

@victorsosa darn. it looks like the most routinely maintained library for React Native doesn't use SVGKit, but the approach is still the same. I believe in nativescript one could simply create a parent view that handles centering/scaling.

This is a consequence of SVGKFastImageView (which if it inherits some of imageview I believe defaults to scaling regardless of aspect ratio).

https://github.com/react-native-community/react-native-svg/blob/c415dbd6ae77834f7ea465eee63f0207828e5104/ios/Utils/RNSVGViewBox.m

https://github.com/react-native-community/react-native-svg/blob/f38b44098cfe24b6752e763042f48447ae365ab8/lib/extract/extractViewBox.js

drewcovi commented 5 years ago

@victorsosa seems this is a known issue in SVGKit https://github.com/SVGKit/SVGKit/issues/261