1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

only keep scroll-position for back/forward actions

This commit is contained in:
ivaosthu 2016-12-29 14:01:03 +01:00
parent ed073230fc
commit 98abaa921b

View File

@ -93,12 +93,19 @@ export default class App extends Component {
} }
render () { render () {
const shouldUpdateScroll = (prevRouterProps, { location }) => {
if (prevRouterProps && location.pathname !== prevRouterProps.location.pathname) {
return location.action === 'POP';
} else {
return [0, 0];
}
};
const createListItem = (path, caption, icon) => const createListItem = (path, caption, icon) =>
<a <Link
href={this.context.router.createHref(path)} to={path}
className={this.context.router.isActive(path) ? style.active : ''}> className={this.context.router.isActive(path) ? style.active : ''}>
{icon && <Icon name={icon} />} {caption} {icon && <Icon name={icon} />} {caption}
</a>; </Link>;
return ( return (
<div style={{}}> <div style={{}}>
@ -119,7 +126,7 @@ export default class App extends Component {
{createListItem('/applications', 'Applications', 'apps')} {createListItem('/applications', 'Applications', 'apps')}
</Navigation> </Navigation>
</Drawer> </Drawer>
<ScrollContainer scrollKey={window.location.pathname}> <ScrollContainer scrollKey="container" shouldUpdateScroll={shouldUpdateScroll}>
<Content> <Content>
<Grid shadow={1} style={{ maxWidth: '1200px', margin: '0 auto' }}> <Grid shadow={1} style={{ maxWidth: '1200px', margin: '0 auto' }}>
<Cell col={12}> <Cell col={12}>