diff --git a/src/components/molecules/ProjectNav.jsx b/src/components/molecules/ProjectNav.jsx index 324f622..0708339 100644 --- a/src/components/molecules/ProjectNav.jsx +++ b/src/components/molecules/ProjectNav.jsx @@ -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