1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-12-31 09:07:38 +01:00

project nav tweaks

This commit is contained in:
Matthias Kretschmann 2018-06-23 16:31:08 +02:00
parent dfe495eeac
commit db6addcbe2
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -20,17 +20,26 @@ class ProjectNav extends Component {
constructor(props) {
super(props)
this.state = {
scrolledToCurrent: false
}
this.scrollToCurrent = this.scrollToCurrent.bind(this)
}
componentDidMount() {
this.scrollToCurrent()
this.setState({ scrolledToCurrent: true })
}
componentDidUpdate() {
this.scrollToCurrent()
}
componentWillUnmount() {
this.setState({ scrolledToCurrent: false })
}
scrollToCurrent = () => {
const current = this.currentItem
const currentLeft = current.getBoundingClientRect().left