diff options
author | Fabio Berger <me@fabioberger.com> | 2018-03-03 13:07:00 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-03 13:07:00 +0800 |
commit | 4dbb2ed167ff93cc5e5bb0daea5a272eef01baf3 (patch) | |
tree | 93f15ba9ad448d9390db38b76c601ac41e4f4eeb /packages/website/ts/utils | |
parent | 4a57f2a762619932a882d08e62006e83a584a684 (diff) | |
parent | 212d680a477917817138790560d88d06cea5ec6f (diff) | |
download | dexon-0x-contracts-4dbb2ed167ff93cc5e5bb0daea5a272eef01baf3.tar.gz dexon-0x-contracts-4dbb2ed167ff93cc5e5bb0daea5a272eef01baf3.tar.zst dexon-0x-contracts-4dbb2ed167ff93cc5e5bb0daea5a272eef01baf3.zip |
Merge pull request #427 from 0xProject/fix/doc_bugs
Miscellaneous Doc Fixes
Diffstat (limited to 'packages/website/ts/utils')
-rw-r--r-- | packages/website/ts/utils/configs.ts | 2 | ||||
-rw-r--r-- | packages/website/ts/utils/utils.ts | 27 |
2 files changed, 29 insertions, 0 deletions
diff --git a/packages/website/ts/utils/configs.ts b/packages/website/ts/utils/configs.ts index 7e9ba69de..388fc8530 100644 --- a/packages/website/ts/utils/configs.ts +++ b/packages/website/ts/utils/configs.ts @@ -94,6 +94,8 @@ export const configs = { [3]: [`https://ropsten.infura.io/${INFURA_API_KEY}`], [4]: [`https://rinkeby.infura.io/${INFURA_API_KEY}`], } as PublicNodeUrlsByNetworkId, + SCROLL_CONTAINER_ID: 'documentation', + SCROLL_TOP_ID: 'pageScrollTop', SHOULD_DEPRECATE_OLD_WETH_TOKEN: true, SYMBOLS_OF_MINTABLE_KOVAN_TOKENS: ['MKR', 'MLN', 'GNT', 'DGD', 'REP'], SYMBOLS_OF_MINTABLE_RINKEBY_ROPSTEN_TOKENS: [ diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts index c38f84c92..a1e045af7 100644 --- a/packages/website/ts/utils/utils.ts +++ b/packages/website/ts/utils/utils.ts @@ -4,6 +4,7 @@ import deepEqual = require('deep-equal'); import isMobile = require('is-mobile'); import * as _ from 'lodash'; import * as moment from 'moment'; +import { scroller } from 'react-scroll'; import { EtherscanLinkSuffixes, Networks, @@ -290,4 +291,30 @@ export const utils = { ); return isTestNetwork; }, + getCurrentBaseUrl() { + const port = window.location.port; + const hasPort = !_.isUndefined(port); + const baseUrl = `https://${window.location.hostname}${hasPort ? `:${port}` : ''}`; + return baseUrl; + }, + scrollToHash(hash: string, containerId: string): void { + let finalHash = hash; + if (_.isEmpty(hash)) { + finalHash = configs.SCROLL_TOP_ID; // scroll to the top + } + + scroller.scrollTo(finalHash, { + duration: 0, + offset: 0, + containerId, + }); + }, + async onPageLoadAsync(): Promise<void> { + if (document.readyState === 'complete') { + return; // Already loaded + } + return new Promise<void>((resolve, reject) => { + window.onload = () => resolve(); + }); + }, }; |