aboutsummaryrefslogtreecommitdiffstats
path: root/packages/react-docs/src
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-03-08 23:35:33 +0800
committerFabio Berger <me@fabioberger.com>2018-03-08 23:35:33 +0800
commit2011349eb198c2b3649001bfe9bafa3e924dfef6 (patch)
tree583c5e49d1c454298c424d11b434bd9b4aaf7e5e /packages/react-docs/src
parent8057f4a678f5e4c00241ec9b15bd9d4dfc3588df (diff)
downloaddexon-0x-contracts-2011349eb198c2b3649001bfe9bafa3e924dfef6.tar
dexon-0x-contracts-2011349eb198c2b3649001bfe9bafa3e924dfef6.tar.gz
dexon-0x-contracts-2011349eb198c2b3649001bfe9bafa3e924dfef6.tar.bz2
dexon-0x-contracts-2011349eb198c2b3649001bfe9bafa3e924dfef6.tar.lz
dexon-0x-contracts-2011349eb198c2b3649001bfe9bafa3e924dfef6.tar.xz
dexon-0x-contracts-2011349eb198c2b3649001bfe9bafa3e924dfef6.tar.zst
dexon-0x-contracts-2011349eb198c2b3649001bfe9bafa3e924dfef6.zip
Scroll to previous hashed elements when user clicks back button
Diffstat (limited to 'packages/react-docs/src')
-rw-r--r--packages/react-docs/src/ts/components/documentation.tsx10
1 files changed, 10 insertions, 0 deletions
diff --git a/packages/react-docs/src/ts/components/documentation.tsx b/packages/react-docs/src/ts/components/documentation.tsx
index d511bbfb4..b46358159 100644
--- a/packages/react-docs/src/ts/components/documentation.tsx
+++ b/packages/react-docs/src/ts/components/documentation.tsx
@@ -70,6 +70,12 @@ export class Documentation extends React.Component<DocumentationProps, Documenta
isHoveringSidebar: false,
};
}
+ public componentDidMount() {
+ window.addEventListener('hashchange', this._onHashChanged.bind(this), false);
+ }
+ public componentWillUnmount() {
+ window.removeEventListener('hashchange', this._onHashChanged.bind(this), false);
+ }
public componentDidUpdate(prevProps: DocumentationProps, prevState: DocumentationState) {
if (!_.isEqual(prevProps.docAgnosticFormat, this.props.docAgnosticFormat)) {
const hash = window.location.hash.slice(1);
@@ -362,4 +368,8 @@ export class Documentation extends React.Component<DocumentationProps, Documenta
isHoveringSidebar: false,
});
}
+ private _onHashChanged(event: any) {
+ const hash = window.location.hash.slice(1);
+ sharedUtils.scrollToHash(hash, sharedConstants.SCROLL_CONTAINER_ID);
+ }
}