1
0
mirror of https://github.com/oceanprotocol/docs.git synced 2024-11-02 00:05:35 +01:00

only update url if element exists

This commit is contained in:
Matthias Kretschmann 2019-01-28 16:55:00 +01:00
parent 8923f35d00
commit 942106b88c
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -37,14 +37,16 @@ export default class TocScroll extends React.Component {
}
}
scroll
? this.scrollTo(elem, offset, timeout)
: console.log(`Element not found: ${element}`) // eslint-disable-line
if (scroll) {
this.scrollTo(elem, offset, timeout)
// update browser url
if (typeof window !== 'undefined') {
window.history.pushState({}, null, `#${element}`)
}
} else {
console.log(`Element not found: ${element}`) // eslint-disable-line
}
}
scrollTo(element, offSet = 0, timeout = null) {