Skip to content

Instantly share code, notes, and snippets.

@biyootiful
Last active October 30, 2017 23:02
Show Gist options
  • Save biyootiful/ed4d4fbd5e6ae4781d942ab18953d3a1 to your computer and use it in GitHub Desktop.
Save biyootiful/ed4d4fbd5e6ae4781d942ab18953d3a1 to your computer and use it in GitHub Desktop.
class Pumpkin extends Component {
constructor() {
super();
this.spinValue = new Animated.Value(0);
}
componentDidMount() {
this.spin();
}
spin() {
this.spinValue.setValue(0);
Animated.timing(this.spinValue, {
toValue: 1,
duration: 4000,
easing: Easing.linear
}).start(() => this.spin());
}
render() {
const spin = this.spinValue.interpolate({
inputRange: [0, 1],
outputRange: ["0deg", "360deg"]
});
return (
<Animated.Image
source={require("./img/pumkin.gif")}
style={{
width:200,
height:200,
transform: [{ rotate: spin }]
}}
/>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment