navigation-panel.component.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { Component, ViewChild, Input } from '@angular/core';
  2. import { NavigationPanelService } from 'src/services/navigationPanel/navigation-panel.service';
  3. @Component({
  4. selector: 'navigation-panel',
  5. templateUrl: './navigation-panel.component.html',
  6. styleUrl: './navigation-panel.component.scss',
  7. })
  8. export class NavigationPanelComponent {
  9. constructor(private navigation: NavigationPanelService) {}
  10. @Input() showAdditionalNavigation: boolean = true;
  11. @ViewChild('navigationBackdrop') backdrop: any;
  12. @ViewChild('navigationPanel') panel: any;
  13. public ngOnInit(): void {
  14. this.navigation.showNavigationPanel$.subscribe((state) => {
  15. if (state) {
  16. this.openPanel();
  17. } else {
  18. this.closePanel();
  19. }
  20. });
  21. }
  22. public openPanel(): void {
  23. this.backdrop.nativeElement.classList.add('backdrop--open');
  24. this.panel.nativeElement.classList.add('panel--open');
  25. }
  26. public closePanel(): void {
  27. this.backdrop?.nativeElement.classList.remove('backdrop--open');
  28. this.panel?.nativeElement.classList.remove('panel--open');
  29. }
  30. }