mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-01-10 04:25:08 +00:00
Set the correct return type for the 'getSidebar' method
+ Close the navbar on NavigationEnd on mobile devices
This commit is contained in:
parent
4e6207fef5
commit
44663342f4
|
@ -58,7 +58,7 @@ export class FuseSidebarService
|
|||
*
|
||||
* @param key
|
||||
*/
|
||||
getSidebar(key): any
|
||||
getSidebar(key): FuseSidebarComponent
|
||||
{
|
||||
// Check if the sidebar exists
|
||||
if ( !this._registry[key] )
|
||||
|
|
|
@ -10,12 +10,12 @@
|
|||
</div>
|
||||
|
||||
<button mat-button class="toggle-button-navbar mat-icon-button"
|
||||
(click)="toggleSidebarFolded('navbar')" fxHide.lt-lg>
|
||||
(click)="toggleSidebarFolded()" fxHide.lt-lg>
|
||||
<mat-icon>menu</mat-icon>
|
||||
</button>
|
||||
|
||||
<button mat-button class="toggle-button-navbar mat-icon-button"
|
||||
(click)="toggleSidebarOpened('navbar')" fxHide.gt-md>
|
||||
(click)="toggleSidebarOpened()" fxHide.gt-md>
|
||||
<mat-icon>arrow_back</mat-icon>
|
||||
</button>
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { Component, Input, OnDestroy, ViewChild, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, Input, OnDestroy, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
|
||||
import { NavigationEnd, Router } from '@angular/router';
|
||||
import { Subscription } from 'rxjs/Subscription';
|
||||
|
||||
import { FusePerfectScrollbarDirective } from '@fuse/directives/fuse-perfect-scrollbar/fuse-perfect-scrollbar.directive';
|
||||
|
@ -13,7 +14,7 @@ import { FuseNavigationService } from '@fuse/components/navigation/navigation.se
|
|||
styleUrls : ['./navbar.component.scss'],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class FuseNavbarComponent implements OnDestroy
|
||||
export class FuseNavbarComponent implements OnInit, OnDestroy
|
||||
{
|
||||
private fusePerfectScrollbar: FusePerfectScrollbarDirective;
|
||||
|
||||
|
@ -41,7 +42,8 @@ export class FuseNavbarComponent implements OnDestroy
|
|||
|
||||
constructor(
|
||||
private sidebarService: FuseSidebarService,
|
||||
private navigationService: FuseNavigationService
|
||||
private navigationService: FuseNavigationService,
|
||||
private router: Router
|
||||
)
|
||||
{
|
||||
// Navigation data
|
||||
|
@ -51,6 +53,18 @@ export class FuseNavbarComponent implements OnDestroy
|
|||
this.layout = 'vertical';
|
||||
}
|
||||
|
||||
ngOnInit()
|
||||
{
|
||||
this.router.events.subscribe(
|
||||
(event) => {
|
||||
if ( event instanceof NavigationEnd )
|
||||
{
|
||||
this.sidebarService.getSidebar('navbar').close();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
ngOnDestroy()
|
||||
{
|
||||
if ( this.fusePerfectScrollbarUpdateTimeout )
|
||||
|
@ -64,13 +78,13 @@ export class FuseNavbarComponent implements OnDestroy
|
|||
}
|
||||
}
|
||||
|
||||
toggleSidebarOpened(key)
|
||||
toggleSidebarOpened()
|
||||
{
|
||||
this.sidebarService.getSidebar(key).toggleOpen();
|
||||
this.sidebarService.getSidebar('navbar').toggleOpen();
|
||||
}
|
||||
|
||||
toggleSidebarFolded(key)
|
||||
toggleSidebarFolded()
|
||||
{
|
||||
this.sidebarService.getSidebar(key).toggleFold();
|
||||
this.sidebarService.getSidebar('navbar').toggleFold();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user