import React from 'react';
import Transition from 'react-transition-group/Transition';
const duration = 300;
const defaultStyle = {
transition: `all ${duration}ms ease-in-out`,
opacity: 0,
top: 1000
}
const transitionStyles = {
entering: { opacity: 0, top: 1000 },
entered: { opacity: 1, top: 0 },
};
export const TransitionAnimation = (Module) => {
return class AnimateHOC extends React.Component {
state = {in:false}
componentDidMount() {
this.setState({ in: true })
}
render(){
return(
<Transition in={this.state.in} timeout={duration}>
{(state) => (
<div style={{
...defaultStyle,
...transitionStyles[state]
}}>
<Module {...this.props} />
</div>
)}
</Transition>
)
}
}
}
Created
September 17, 2018 19:10
-
-
Save andrit/1dcae4dd1206f87630bd0777a4568d46 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment