Skip to content

Instantly share code, notes, and snippets.

@juukie
Forked from sharathprabhal/FadeInImage.js
Created January 25, 2019 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juukie/ae7d28841c5eabfeda5efa56eb1ea1bc to your computer and use it in GitHub Desktop.
Save juukie/ae7d28841c5eabfeda5efa56eb1ea1bc to your computer and use it in GitHub Desktop.
import React from 'react-native'
var {
Image,
Animated,
View
} = React
module.exports = React.createClass({
getInitialState() {
return {
opacity: new Animated.Value(0)
}
},
onLoad() {
Animated.timing(this.state.opacity, {
toValue: 1,
duration: 250
}).start()
},
render() {
return (
<View
width={this.props.style.width}
height={this.props.style.height}
backgroundColor={'#CCC'}
>
<Animated.Image
resizeMode={'contain'}
key={this.props.key}
style={[{opacity: this.state.opacity}, this.props.style]}
source={this.props.source}
onLoad={this.onLoad} />
</View>
)
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment