animation - Animate route change in react-router-dom switch component -
i'm having hard time animating transition 1 page react-router-dom
. the exmaple fine can't work within switch
component provided react-router-dom
.
i've tried doing around switch
component or inside doesn't (also no warnings or errors in console).
example
class layout extends purecomponent { render() { const { account } = this.props; return ( <div classname="main"> <header image={account.resources.logo} backgroundcolor={account.theme} /> <progressionbar /> <div classname="main__content"> <csstransition classnames="fade" timeout={{ enter: 1500, exit: 500 }}> <switch key={this.props.location.key} location={this.props.location}> <route exact path={`${basepath}start`} component={start} /> <route exact path={`${basepath}questions`} component={questions} /> <route exact path={`${basepath}comments`} component={comments} /> <route exact path={`${basepath}capture`} component={capture} /> <route exact path={`${basepath}disclaimer`} component={disclaimer} /> <route exact path={`${basepath}finish`} component={null} /> </switch> </csstransition> <footer /> </div> </div> ); } }
css
.fade-enter { opacity: 0.01; } .fade-enter.fade-enter-active { opacity: 1; transition: opacity 500ms ease-in; } .fade-exit { opacity: 1; } .fade-exit.fade-exit-active { opacity: 0.01; transition: opacity 300ms ease-in; }
try this:
<csstransition classnames="test" transitionleavetimeout={300}> <switch key={this.props.location.pathname} location={this.props.location}> ... </switch> </csstransition>
Comments
Post a Comment