aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-03-08 23:38:25 +0800
committerFabio Berger <me@fabioberger.com>2018-03-08 23:38:25 +0800
commit4a94a2b4e81d8b5d773ebeaa671b78ac4bf9a408 (patch)
tree74a60bbde0377bcdbf1c5a2b18c7f167bbbf3dc7 /packages/website
parent2011349eb198c2b3649001bfe9bafa3e924dfef6 (diff)
downloaddexon-sol-tools-4a94a2b4e81d8b5d773ebeaa671b78ac4bf9a408.tar.gz
dexon-sol-tools-4a94a2b4e81d8b5d773ebeaa671b78ac4bf9a408.tar.zst
dexon-sol-tools-4a94a2b4e81d8b5d773ebeaa671b78ac4bf9a408.zip
Add support for going back to previous hashes via the browser back button to wiki
Diffstat (limited to 'packages/website')
-rw-r--r--packages/website/ts/pages/wiki/wiki.tsx8
1 files changed, 8 insertions, 0 deletions
diff --git a/packages/website/ts/pages/wiki/wiki.tsx b/packages/website/ts/pages/wiki/wiki.tsx
index 18074c302..f6cff51e4 100644
--- a/packages/website/ts/pages/wiki/wiki.tsx
+++ b/packages/website/ts/pages/wiki/wiki.tsx
@@ -67,6 +67,9 @@ export class Wiki extends React.Component<WikiProps, WikiState> {
isHoveringSidebar: false,
};
}
+ public componentDidMount() {
+ window.addEventListener('hashchange', this._onHashChanged.bind(this), false);
+ }
public componentWillMount() {
// tslint:disable-next-line:no-floating-promises
this._fetchArticlesBySectionAsync();
@@ -74,6 +77,7 @@ export class Wiki extends React.Component<WikiProps, WikiState> {
public componentWillUnmount() {
this._isUnmounted = true;
clearTimeout(this._wikiBackoffTimeoutId);
+ window.removeEventListener('hashchange', this._onHashChanged.bind(this), false);
}
public render() {
const menuSubsectionsBySection = _.isUndefined(this.state.articlesBySection)
@@ -246,4 +250,8 @@ export class Wiki extends React.Component<WikiProps, WikiState> {
isHoveringSidebar: false,
});
}
+ private _onHashChanged(event: any) {
+ const hash = window.location.hash.slice(1);
+ sharedUtils.scrollToHash(hash, sharedConstants.SCROLL_CONTAINER_ID);
+ }
}