1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2025-01-03 10:25:00 +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) { constructor(props) {
super(props) super(props)
this.state = {
scrolledToCurrent: false
}
this.scrollToCurrent = this.scrollToCurrent.bind(this) this.scrollToCurrent = this.scrollToCurrent.bind(this)
} }
componentDidMount() { componentDidMount() {
this.scrollToCurrent() this.scrollToCurrent()
this.setState({ scrolledToCurrent: true })
} }
componentDidUpdate() { componentDidUpdate() {
this.scrollToCurrent() this.scrollToCurrent()
} }
componentWillUnmount() {
this.setState({ scrolledToCurrent: false })
}
scrollToCurrent = () => { scrollToCurrent = () => {
const current = this.currentItem const current = this.currentItem
const currentLeft = current.getBoundingClientRect().left const currentLeft = current.getBoundingClientRect().left