import { Component, OnInit, HostListener } from '@angular/core';

declare var $: any;
declare const window: any;

@Component({
  selector: 'app-navbar',
  templateUrl: './navbar.component.html',
  styleUrls: ['./navbar.component.scss']
})
export class NavbarComponent implements OnInit {

  isClicked:boolean;

  constructor() { 

    this.isClicked =false;
  }

  

  ngOnInit() {

  
  }


  toggleClick(){
    this.isClicked = !this.isClicked;
  }

  
  @HostListener('window:scroll', [])
  onWindowScroll() {

    const number = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;

    $(window).scroll(function () {
      const sticky = $('.cms-header'),
        scroll = $(window).scrollTop();
      if (scroll > 10) { sticky.addClass('scrolled_navbar'); } else { sticky.removeClass('scrolled_navbar'); }
    });
    window.addEventListener('load', function() {
      const sticky = $('.cms-header'),
        scroll = $(window).scrollTop();
      if (scroll > 10) { sticky.addClass('scrolled_navbar'); } else { sticky.removeClass('scrolled_navbar'); }
    });
  }

}

