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

Unable to use scaleX, scaleY on <View>

Open amitverma opened this issue 11 years ago • 5 comments

I have been trying to use scaleX and scaleY on a <View/> component, but it is not working. Do I need to keep something in mind while using it?

amitverma avatar May 05 '15 09:05 amitverma

@amitverma - the documentation seems to be a bit unclear about this, this is how you need to specify it:

<View style={{flex: 1, transform: [{translateY: 50}, {scaleX: 0.5}, {scaleY: 0.5}]}}>
   <Text>Text here!</Text>
</View>

brentvatne avatar May 05 '15 21:05 brentvatne

Updated docs to remove this, working on fixing it up to better display those options under the transform prop.

@vjeux also informed me of something interesting: the reason that these are in an array in separate objects inside of the transform property is because order matters here - translate followed by scale is different than scale followed by translate.

brentvatne avatar May 06 '15 02:05 brentvatne

thanks @brentvatne for clearing things up. would switching order between scaleX and scaleY also produce different results?

amitverma avatar May 06 '15 08:05 amitverma

@amitverma - nope, those should be the same as they scale the X and Y axis independently and irrespective of aspect ratio. Another interesting thing to know is you can apply transforms multiple times:

transform: [{scaleX: 0.5}, {scaleY: 1.5}, {scaleX: 1.5}] :smile:

brentvatne avatar May 06 '15 17:05 brentvatne

See #1181 for doc fix

brentvatne avatar May 06 '15 19:05 brentvatne