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:
parent
dfe495eeac
commit
db6addcbe2
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user