Skip to content

Commit

Permalink
restore scroll position between navigation if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Reeywhaar committed Nov 19, 2018
1 parent 5b48952 commit c1b8e09
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 12 deletions.
46 changes: 40 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"react-redux": "^5.0.7",
"react-router-dom": "^4.3.1",
"react-router-hash-link": "^1.2.1",
"react-router-scroll-4": "^1.0.0-beta.2",
"react-svg-inline": "^2.1.1",
"redux": "^4.0.0",
"sass-loader": "^7.1.0",
Expand Down
23 changes: 17 additions & 6 deletions src/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { waitDOMReady, sleep, scrollIntoView } from "./utils.js";

import Head from "./head.jsx";
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
import { ScrollContext } from "react-router-scroll-4";
import { Provider, connect } from "react-redux";
import AddArticle from "./add.jsx";
import {
Expand Down Expand Up @@ -54,21 +55,31 @@ class App extends Component {
path="/"
exact={true}
render={() => (
<Listing
{...this.props}
ref={ref => (window[listingRef] = ref)}
/>
<ScrollContext>
<Listing
{...this.props}
ref={ref => (window[listingRef] = ref)}
/>
</ScrollContext>
)}
/>
<Route
path="/deleted/"
exact={true}
render={() => <DeletedListing {...this.props} />}
render={() => (
<ScrollContext>
<DeletedListing {...this.props} />
</ScrollContext>
)}
/>
<Route
path="/archive/"
exact={true}
render={() => <ArchiveListing {...this.props} />}
render={() => (
<ScrollContext>
<ArchiveListing {...this.props} />
</ScrollContext>
)}
/>
<Route
path="/add/"
Expand Down

0 comments on commit c1b8e09

Please sign in to comment.