Last active
October 30, 2017 23:02
-
-
Save biyootiful/ed4d4fbd5e6ae4781d942ab18953d3a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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