Skip to content

Instantly share code, notes, and snippets.

@norbajunior
Created November 27, 2017 23:36
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 norbajunior/8a4364d3f7ee5cd72e3450fcbf283abd to your computer and use it in GitHub Desktop.
Save norbajunior/8a4364d3f7ee5cd72e3450fcbf283abd to your computer and use it in GitHub Desktop.
import { Animated } from 'react-native'
class Notification extends Component {
constructor(props) {
super(props)
this.offset = new Animated.Value(props.offset)
}
componentDidMount() {
Animated.sequence([
Animated.delay(this.props.delay),
Animated.spring(this.offset, {
tension: -5,
toValue: 0
}),
Animated.timing(this.offset, {
duration: 1000,
toValue: -80
})
]).start(() => this.props.removeNotification(this.props.id))
}
render() {
const { message, avatar } = this.props
return (
<Animated.View
style={[styles.messageContainerStyle, {
transform: [{
translateY: this.state.offset
}]
}]}
>
<Image source={this.props.avatar} />
<Text>Nova Mensagem</Text>
<Text>{this.props.message}</Text>
</Animated.View>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment