Skip to content

Commit 516cc0a

Browse files
committed
fix #25
1 parent 9285057 commit 516cc0a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

app/stores/locationStore.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class LocationStore extends EventEmitter {
5555
typeof window.history.pushState !== 'undefined'
5656
) {
5757
try {
58-
window.history.pushState(null, this.getTitle(), newPath);
58+
window.history.replaceState({scroll: [window.scrollX, window.scrollY]}, document.title, window.location.pathname);
59+
window.history.pushState({scroll: [0, 0]}, this.getTitle(), newPath);
5960
} catch (e) {} // Can fail on file:// origins
6061
}
6162
this.emit('change');

app/views/AppView/RouteView.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ var RouteView = React.createClass({
1010

1111
componentDidMount: function() {
1212
this._pageChangeHandler = (function() {
13+
if (
14+
typeof window !== 'undefined' &&
15+
typeof window.history.state !== 'undefined'
16+
) {
17+
window.scrollTo.apply(window, window.history.state.scroll);
18+
}
1319
this.setState({
1420
page: locationStore.getPage()
1521
});

0 commit comments

Comments
 (0)