Skip to content

Commit 5d31c89

Browse files
authored
Merge pull request #7 from zhirzh/scroll-to-top-on-navigation
Scroll to top of the page when use navigates to a new section
2 parents c3bf5ef + 77b311c commit 5d31c89

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ import './index.css';
1414
import './App.css';
1515
import './syntax.css';
1616

17+
function scrollToTop() {
18+
document.body.scrollTop = document.documentElement.scrollTop = 0;
19+
}
20+
1721
ReactDOM.render(
18-
<Router history={hashHistory}>
22+
<Router history={hashHistory} onUpdate={scrollToTop}>
1923
<Route path="/" component={App}>
2024
<IndexRoute component={Introduction} />
2125
<IndexRedirect to="/introduction" />

0 commit comments

Comments
 (0)