{"size": 992, "ext": "js", "max_stars_repo_path": "containers/general/Menu/index.js", "max_stars_repo_name": "zerebral/marketcheck", "max_stars_repo_stars_event_min_datetime": "2021-09-10T05:04:29.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-10T05:04:29.000Z", "max_issues_repo_path": "containers/general/Menu/index.js", "max_issues_repo_name": "zerebral/marketcheck", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "containers/general/Menu/index.js", "max_forks_repo_name": "zerebral/marketcheck", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 20.6666666667, "max_line_length": 64, "alphanum_fraction": 0.6612903226}
import React from 'react'
import autobind from 'class-autobind'
import Menu from '~/general/Menu'
import InnerMenu from '~/general/Menu/InnerMenu'

class MenuContainer extends React.Component {
  constructor () {
    super(...arguments)
    this.state = { active: false }
    autobind(this)
  }

  componentDidMount () {
    this.bindScroll()
  }

  componentWillUnmount () {
    this.unbindScroll()
  }

  bindScroll () {
    window.addEventListener('scroll', this.handleScroll)
  }

  unbindScroll () {
    window.removeEventListener('scroll', this.handleScroll)
  }

  handleScroll () {
    const height = this.menu.clientHeight
    const windowTop = window.pageYOffset

    const hasScrolledPastHeight = windowTop > height
    return this.setState({active: hasScrolledPastHeight})
  }

  render () {
    let { active } = this.state
    return (
      <Menu innerRef={el => { this.menu = el }} active={active}>
        <InnerMenu />
      </Menu>
    )
  }
}

export default MenuContainer
