Adjust animations to number of items

This commit is contained in:
Tom Raithel
2017-03-01 21:40:59 +01:00
parent 6d4f1d0c09
commit a92aeac253
5 changed files with 129 additions and 119 deletions

View File

@@ -37,11 +37,21 @@ class Router extends React.Component {
}
componentWillReceiveProps({ pageName }) {
this.setState({
...this.state,
nextPageName: pageName,
leaving: true,
});
const leaving = getPageByName(this.props.items, pageName) !== getPageByName(this.props.items, this.state.pageName);
if (leaving) {
this.setState({
...this.state,
nextPageName: pageName,
leaving: true,
});
} else {
// stay on same page
this.setState({
...this.state,
pageName,
});
}
}
handlePageLeave = () => {