Skip to content

Instantly share code, notes, and snippets.

@jrnk
Created October 27, 2016 16:57
Show Gist options
  • Save jrnk/f2fb0693207bc8eab6f49c164fd227c3 to your computer and use it in GitHub Desktop.
Save jrnk/f2fb0693207bc8eab6f49c164fd227c3 to your computer and use it in GitHub Desktop.
Remote image fade in oncomplete - react native
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