diff --git a/src/index.js b/src/index.js index 8248639..06e079c 100644 --- a/src/index.js +++ b/src/index.js @@ -38,7 +38,7 @@ userFactory(store) ReactDOM.render( - + {routesFactory(store)} @@ -49,6 +49,23 @@ userFactory(store) document.getElementById('loader').classList.remove('is-active'); }); +/** + * Scrolls to page's top or #anchor link, if any + */ +function restoreScroll() { + const {hash} = location; + + // Push onto callback queue so it runs after the DOM is updated + setTimeout(() => { + const id = hash.replace('#', ''); + const el = id ? document.getElementById(id) : null; + if (el) { + el.scrollIntoView(); + } else { + window.scrollTo(0, 0); + } + }, 100); +} if (process.env.NODE_ENV !== 'production') { // some shortcuts for testing on localhost diff --git a/src/pages/rules/RulesPage.jsx b/src/pages/rules/RulesPage.jsx index e6ecf92..bcfa491 100644 --- a/src/pages/rules/RulesPage.jsx +++ b/src/pages/rules/RulesPage.jsx @@ -59,8 +59,9 @@ export default function RulesPage() { return (
- {rules.map((block, key) => ( -
+ {rules.map((block, sectionIndex) => ( +
+

{block.title}

@@ -70,8 +71,11 @@ export default function RulesPage() {
) : ''}
    - {block.items.map((item, key) => ( -
  1. {item}
  2. + {block.items.map((item, ruleIndex) => ( +
  3. + + {item} +
  4. ))}
diff --git a/src/routes.js b/src/routes.js index 3548d9d..4368711 100644 --- a/src/routes.js +++ b/src/routes.js @@ -26,11 +26,6 @@ import Finish from 'components/auth/finish/Finish'; import authFlow from 'services/authFlow'; -browserHistory.listen(() => { - // scroll to top on route transition - document.body.scrollTop = document.documentElement.scrollTop = 0; -}); - export default function routesFactory(store) { authFlow.setStore(store);