I have 2 issues with the Animated
API.
1st: I am able to show the Image from left to right with the following code. I want to scale the Image from position X=40 (leftPadding), Y=100(topPadding), height:20, width:20
to X=20, Y=10, height:250, width:300
. How do I achieve this?
My code:
import React, { Component } from 'react';
import { StyleSheet, Text, Image, Animated, Easing, View, Button } from 'react-native';
class MyTestComp extends Component {
componentWillMount() {
this.animatedValue = new Animated.Value(0);
}
buttonPress(){
this.animatedValue.setValue(0);
Animated.timing(this.animatedValue,{
toValue:1,
duration:1000,
Easing: Easing
}).start()
}
render() {
const translateX = this.animatedValue.interpolate({
inputRange: [0, 1],
outputRange: [-500, 1]
})
const transform = [{translateX}];
return (
<View>
<Text>MyTestComp</Text>
<Animated.View style={transform}>
<Image
source={require('./assets/17.jpg')}
style={{width:300, height:250}}
/>
</Animated.View>
<View style={{marginTop:10}}>
<Button title="Click Me" onPress={()=> this.buttonPress()} />
</View>
</View>
);
}
}
export default MyTestComp;
2nd: Everytime I run the animation, I'm getting an exception:
I'm not able to find any documentation on this. How do I use the transform
prop.
Many thanks.