Last active
April 9, 2018 21:19
-
-
Save dbismut/79eddd1e6565af7ff5dd887e973ea0f7 to your computer and use it in GitHub Desktop.
Part 2 - Bootstrapping the exiting transition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onExit = () => {} | |
executeExitingTransition = (node, done) => { | |
// we're going to do some work in there! | |
done(); | |
} | |
onAddEndListener = (node, done) => { | |
if (!this.preview) return done(); | |
const { in: inProp } = this.props; | |
if (inProp) { // we're just adding this inProp logic | |
const { image } = this.props.route.data.post; | |
const img = new Image(); | |
img.src = `/img/${image}`; | |
if (!img.complete) { | |
img.onload = () => this.executeEnteringTransition(node, done); | |
return; | |
} | |
this.executeEnteringTransition(node, done); | |
} else { | |
this.executeExitingTransition(node, done); | |
// we're now triggering the exiting transition | |
} | |
}; | |
render() { | |
/* same code */ | |
return ( | |
<CSSTransition | |
{...transitionProps} | |
onEnter={this.onEnter} | |
onExit={this.onExit} // add this prop | |
addEndListener={this.onAddEndListener} | |
classNames="post" | |
> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment