Created
October 27, 2016 16:57
-
-
Save jrnk/f2fb0693207bc8eab6f49c164fd227c3 to your computer and use it in GitHub Desktop.
Remote image fade in oncomplete - react native
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
import React, { Component } from 'react' | |
import { Animated } from 'react-native' | |
export default class RemoteImage extends Component { | |
constructor(props) { | |
super() | |
this.state = { | |
fadeAnim: new Animated.Value(0) | |
} | |
} | |
_imageLoaded() { | |
Animated.timing( | |
this.state.fadeAnim, | |
{ | |
toValue: 1, | |
duration: 500 | |
}, | |
).start() | |
} | |
render() { | |
return ( | |
<Animated.Image {...this.props} style={[this.props.style, {opacity: this.state.fadeAnim}]} onLoadEnd={() => this._imageLoaded()} /> | |
) | |
} | |
} | |
// use like regular <Image> component: <RemoteImage source={{uri: 'http..'}} style={} /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment