{"size": 844, "ext": "js", "max_stars_repo_path": "src/js/components/navigation.js", "max_stars_repo_name": "lucky-media/lucky-agency-landing", "max_stars_repo_stars_event_min_datetime": "2021-02-12T17:59:44.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T01:04:48.000Z", "max_issues_repo_path": "src/js/components/navigation.js", "max_issues_repo_name": "lucky-media/lucky-agency-landing", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/js/components/navigation.js", "max_forks_repo_name": "lucky-media/lucky-agency-landing", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.1333333333, "max_line_length": 79, "alphanum_fraction": 0.6777251185}
export default class Navigation {
  constructor() {
    this.container = document.querySelector('.navigation');
    this.items = document.getElementById('navigationItems');

    this.btnToggle = document.getElementById('navigationToggle');
    this.openClass = 'navigation--open';
    this.overflowClass = 'overflow-hidden';

    this.btnToggle.addEventListener('click', this.toggleNavigation.bind(this));

    // On resize, close the navigation if open
    window.addEventListener('resize', () => {
      if (this.container.classList.contains(this.openClass)) {
        this.toggleNavigation();
      }
    }, {
      passive: true
    });
  }

  /**
   * Show navigation on mobile
   */
  toggleNavigation() {
    this.container.classList.toggle(this.openClass);
    document.querySelector('body').classList.toggle(this.overflowClass);
  }
}
