problem:
components animating in/out leave white space in between transitions.
desired output
- initial view has an img FOO.
- onEvent, mount video BAR. beging fading out img
- after BAR has completed mounting, FOO should have finished fade out
current strategy
- using reactcsstransition group
- component logic resembles this jsfiddle taken from this post's accepted answer
bare skeleton here
foobar class extends Component {
constructor(props){
super(props)
this.state = {
mounted: false
}
}
handleMounted() {
this.setState({
mounted: !this.state.mounted
})
}
renderFOO() {
! this.state.MOUNTED ?
<FOO /> : null
}
renderBAR() {
this.state.MOUNTED ?
<BAR /> : null
}
render() {
<ReactCSSTransitionGroup>
{ this.renderFOO() }
{ this.renderBAR() }
</ReactCSSTransitionGroup>
}
}
psuedocode
- initially render FOO (done)
- onClickEvent, setState for "mounting" for BAR
- when mounting, FOO begins fading out (slowly)
- when mounting, BAR begins to fade in (quicker)
- when BAR video completes, reverse process so FOO mounts while BAR fades out
Thanks everyone! let me know if you need any clarification :)