diff options
author | Fabio Berger <me@fabioberger.com> | 2018-03-03 12:36:08 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-03-03 12:36:08 +0800 |
commit | 0afe45b3a830bfefc4f9b51823891b99be5261fa (patch) | |
tree | d79f136cf5df69c3c85557bcd11616ca74ab505b | |
parent | f9a37168b034dd20868d1ffe1d2934db6effd39a (diff) | |
download | dexon-sol-tools-0afe45b3a830bfefc4f9b51823891b99be5261fa.tar dexon-sol-tools-0afe45b3a830bfefc4f9b51823891b99be5261fa.tar.gz dexon-sol-tools-0afe45b3a830bfefc4f9b51823891b99be5261fa.tar.bz2 dexon-sol-tools-0afe45b3a830bfefc4f9b51823891b99be5261fa.tar.lz dexon-sol-tools-0afe45b3a830bfefc4f9b51823891b99be5261fa.tar.xz dexon-sol-tools-0afe45b3a830bfefc4f9b51823891b99be5261fa.tar.zst dexon-sol-tools-0afe45b3a830bfefc4f9b51823891b99be5261fa.zip |
Hash hash instead of prefixedHash to scrollToHash function
-rw-r--r-- | packages/website/ts/pages/documentation/documentation.tsx | 3 | ||||
-rw-r--r-- | packages/website/ts/pages/shared/markdown_link_block.tsx | 3 | ||||
-rw-r--r-- | packages/website/ts/pages/wiki/wiki.tsx | 3 | ||||
-rw-r--r-- | packages/website/ts/utils/utils.ts | 8 |
4 files changed, 9 insertions, 8 deletions
diff --git a/packages/website/ts/pages/documentation/documentation.tsx b/packages/website/ts/pages/documentation/documentation.tsx index 5963fe851..699bef7a8 100644 --- a/packages/website/ts/pages/documentation/documentation.tsx +++ b/packages/website/ts/pages/documentation/documentation.tsx @@ -76,7 +76,8 @@ const styles: Styles = { export class Documentation extends React.Component<DocumentationProps, DocumentationState> { public componentDidUpdate(prevProps: DocumentationProps, prevState: DocumentationState) { if (!_.isEqual(prevProps.docAgnosticFormat, this.props.docAgnosticFormat)) { - utils.scrollToHash(this.props.location.hash, configs.SCROLL_CONTAINER_ID); + const hash = this.props.location.hash.slice(1); + utils.scrollToHash(hash, configs.SCROLL_CONTAINER_ID); } } public render() { diff --git a/packages/website/ts/pages/shared/markdown_link_block.tsx b/packages/website/ts/pages/shared/markdown_link_block.tsx index 45bb41478..ed78e4e53 100644 --- a/packages/website/ts/pages/shared/markdown_link_block.tsx +++ b/packages/website/ts/pages/shared/markdown_link_block.tsx @@ -39,8 +39,7 @@ export class MarkdownLinkBlock extends React.Component<MarkdownLinkBlockProps, M } private _onHashUrlClick(href: string) { const hash = href.split('#')[1]; - const hashWithPrefix = `#${hash}`; - utils.scrollToHash(hashWithPrefix, configs.SCROLL_CONTAINER_ID); + utils.scrollToHash(hash, configs.SCROLL_CONTAINER_ID); utils.setUrlHash(hash); } } diff --git a/packages/website/ts/pages/wiki/wiki.tsx b/packages/website/ts/pages/wiki/wiki.tsx index 66fa960d7..4bb6052a2 100644 --- a/packages/website/ts/pages/wiki/wiki.tsx +++ b/packages/website/ts/pages/wiki/wiki.tsx @@ -213,7 +213,8 @@ export class Wiki extends React.Component<WikiProps, WikiState> { }, async () => { await utils.onPageLoadAsync(); - utils.scrollToHash(this.props.location.hash, configs.SCROLL_CONTAINER_ID); + const hash = this.props.location.hash.slice(1); + utils.scrollToHash(hash, configs.SCROLL_CONTAINER_ID); }, ); } diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts index 27cd87be1..a1e045af7 100644 --- a/packages/website/ts/utils/utils.ts +++ b/packages/website/ts/utils/utils.ts @@ -297,13 +297,13 @@ export const utils = { const baseUrl = `https://${window.location.hostname}${hasPort ? `:${port}` : ''}`; return baseUrl; }, - scrollToHash(hashWithPrefix: string, containerId: string): void { - let hash = hashWithPrefix.slice(1); + scrollToHash(hash: string, containerId: string): void { + let finalHash = hash; if (_.isEmpty(hash)) { - hash = configs.SCROLL_TOP_ID; // scroll to the top + finalHash = configs.SCROLL_TOP_ID; // scroll to the top } - scroller.scrollTo(hash, { + scroller.scrollTo(finalHash, { duration: 0, offset: 0, containerId, |